-
Notifications
You must be signed in to change notification settings - Fork 40
/
Dockerfile
254 lines (178 loc) · 7.15 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#--------------------------------------
# Image: base
#--------------------------------------
FROM ubuntu:focal as base
RUN touch /.dummy
ARG APT_HTTP_PROXY
ARG CONTAINERBASE_DEBUG
ENV BASH_ENV=/usr/local/etc/env
SHELL ["/bin/bash" , "-c"]
ARG TARGETARCH
COPY dist/docker/ /
COPY dist/cli/containerbase-cli-${TARGETARCH} /usr/local/containerbase/bin/containerbase-cli
RUN install-containerbase
#--------------------------------------
# build
#--------------------------------------
FROM base as build
# install nginx for request testing
RUN install-apt nginx
COPY test/latest/src/ /
WORKDIR /test
# create test certs
RUN set -ex; \
openssl genrsa 2048 > ca.key; \
openssl genrsa 2048 > renovate.key; \
openssl req -config ca.conf -x509 -new -nodes -key ca.key -out ca.pem; \
openssl req -config cert.conf -new -nodes -key renovate.key -out renovate.csr; \
openssl x509 -req -in renovate.csr -CA ca.pem -CAkey ca.key -out renovate.pem -extfile cert.conf -extensions v3_req; \
rm ca.key; \
cat renovate.pem ca.pem > renovate-chain.pem;
# install root ca
# RUN set -ex \
# && cp ca.pem /usr/local/share/ca-certificates/renovate-ca.crt \
# && update-ca-certificates
#--------------------------------------
# test: custom root ca
#--------------------------------------
FROM build as testa
# renovate: datasource=node
RUN install-tool node v20.11.1
# renovate: datasource=github-releases packageName=containerbase/python-prebuild
RUN install-tool php 7.4.14
RUN set -ex; [ $(stat --format '%u' "/usr/local/bin/php") -eq ${USER_ID} ]
# renovate: datasource=github-releases packageName=PowerShell/PowerShell
RUN install-tool powershell v7.4.1
# renovate: datasource=github-releases depName=python packageName=containerbase/python-prebuild
ARG PYTHON_VERSION=3.12.2
RUN install-tool python
RUN set -ex; [ $(stat --format '%u' "/usr/local/bin/python") -eq ${USER_ID} ]
# Do not renovate ruby 2.x
RUN install-tool ruby 2.6.4
RUN set -ex; [ $(stat --format '%u' "/usr/local/bin/ruby") -eq ${USER_ID} ]
RUN set -ex; \
openssl x509 -noout -text -in ca.pem; \
openssl x509 -noout -text -in renovate.pem;
RUN set -ex; \
nginx; \
su -c 'SSL_CERT_FILE=/test/ca.pem curl -svo /dev/null https://localhost' ${USER_NAME}; \
su -c 'SSL_CERT_FILE=/test/ca.pem curl -svo /dev/null https://buildkitsandbox' ${USER_NAME}; \
su -c 'SSL_CERT_FILE=/test/ca.pem node request.mjs' ${USER_NAME}; \
su -c 'NODE_EXTRA_CA_CERTS=/test/ca.pem node request.mjs' ${USER_NAME}; \
su -c 'SSL_CERT_FILE=/test/ca.pem php request.php' ${USER_NAME}; \
SSL_CERT_FILE=/test/ca.pem pwsh -c "&{ \$ErrorActionPreference='Stop'; invoke-webrequest https://buildkitsandbox }"; \
su -c 'SSL_CERT_FILE=/test/ca.pem python request.py' ${USER_NAME}; \
su -c 'SSL_CERT_FILE=/test/ca.pem ruby request.rb' ${USER_NAME}; \
true
# install root ca
RUN set -ex \
&& cp ca.pem /usr/local/share/ca-certificates/renovate-ca.crt \
&& update-ca-certificates
# use global root certs
RUN set -ex; \
nginx; \
su -c 'curl -svo /dev/null https://buildkitsandbox' ${USER_NAME}; \
su -c 'node request.mjs' ${USER_NAME}; \
su -c 'npm_config_registry=https://localhost npm ping' ${USER_NAME}; \
su -c 'php request.php' ${USER_NAME}; \
pwsh -c "&{ \$ErrorActionPreference='Stop'; invoke-webrequest https://buildkitsandbox }"; \
su -c 'python request.py' ${USER_NAME}; \
su -c 'ruby request.rb' ${USER_NAME}; \
true
#--------------------------------------
# test: gitpod
#--------------------------------------
FROM ubuntu:focal as testb-gitpod
ARG USER_NAME=gitpod
ARG USER_ID=33333
ARG PRIMARY_GROUP_ID=${USER_ID}
ARG APT_HTTP_PROXY
ARG CONTAINERBASE_DEBUG
# Set env and shell
ENV BASH_ENV=/usr/local/etc/env PATH=/home/$USER_NAME/bin:$PATH
SHELL ["/bin/bash" , "-c"]
COPY --from=build /test/ca.pem /usr/local/share/ca-certificates/renovate-ca.crt
# Set up containerbase
COPY --from=build /usr/local/bin/ /usr/local/bin/
COPY --from=build /usr/local/containerbase/ /usr/local/containerbase/
RUN install-containerbase
# validate custom cert
COPY --from=build /test/renovate.pem /renovate.pem
RUN openssl verify /renovate.pem
# Test start
RUN touch /.dummy
USER $USER_NAME
SHELL ["/bin/sh", "-c"]
RUN set -ex; id | grep "uid=${USER_ID}(${USER_NAME}) gid=${PRIMARY_GROUP_ID}(${USER_NAME}) groups=${USER_ID}(${USER_NAME}),0(root)"
# renovate: datasource=docker packageName=hashicorp/terraform versioning=docker
RUN install-tool terraform 1.7.3
WORKDIR /tmp
RUN mkdir $HOME/.tf-cache && TF_PLUGIN_CACHE_DIR=$HOME/.tf-cache terraform init
#--------------------------------------
# test: ignore tools
#--------------------------------------
FROM build as testc
RUN prepare-tool docker
# TODO: move to prepare of git-lfs
# renovate: datasource=github-tags packageName=git/git
RUN install-tool git v2.43.1
USER 1000
RUN set -ex; id; id | grep "uid=${USER_ID}(${USER_NAME}) gid=0(root) groups=0(root),999(docker),${USER_ID}(${USER_NAME})"
ARG IGNORED_TOOLS=powershell,node
# renovate: datasource=github-releases packageName=fluxcd/flux2
RUN install-tool flux v2.2.3
# renovate: datasource=github-releases packageName=git-lfs/git-lfs
RUN install-tool git-lfs v3.4.1
# renovate: datasource=github-releases packageName=PowerShell/PowerShell
RUN install-tool powershell v7.4.1
# renovate: datasource=node
RUN install-tool node v20.11.1
# renovate: datasource=github-releases packageName=moby/moby
RUN install-tool docker v25.0.3
#--------------------------------------
# test: bin path has 775
#--------------------------------------
FROM base as testd
RUN [ $(stat --format '%a' "/usr/local/bin") -eq 775 ]
RUN prepare-tool all
RUN set -ex; [ -d /usr/local/erlang ] && echo "works" || exit 1;
#--------------------------------------
# test: bazelisk, bun, vendir, helmfile, kustomize
#--------------------------------------
FROM base as teste
# renovate: datasource=github-releases packageName=bazelbuild/bazelisk
RUN install-tool bazelisk v1.19.0
# renovate: datasource=npm
RUN install-tool bun 1.0.26
# renovate: datasource=github-releases packageName=gleam-lang/gleam
RUN install-tool gleam 0.34.1
# renovate: datasource=github-releases packageName=vmware-tanzu/carvel-vendir
ARG VENDIR_VERSION=0.32.2
# renovate: datasource=github-releases packageName=helmfile/helmfile
ARG HELMFILE_VERSION=0.150.0
# renovate: datasource=github-releases packageName=kubernetes-sigs/kustomize
ARG KUSTOMIZE_VERSION=5.0.0
RUN install-tool vendir "v${VENDIR_VERSION}"
RUN install-tool helmfile "v${HELMFILE_VERSION}"
RUN install-tool kustomize "${KUSTOMIZE_VERSION}"
RUN set -ex; vendir --version
RUN set -ex; helmfile version
RUN set -ex; kustomize version
SHELL [ "/bin/sh", "-c" ]
RUN vendir --version | grep "${VENDIR_VERSION}"
RUN helmfile version | grep "${HELMFILE_VERSION}"
RUN kustomize version | grep "${KUSTOMIZE_VERSION}"
USER 1000
RUN bazel --version
RUN vendir --version | grep "${VENDIR_VERSION}"
RUN helmfile version | grep "${HELMFILE_VERSION}"
RUN kustomize version | grep "${KUSTOMIZE_VERSION}"
#--------------------------------------
# final
#--------------------------------------
FROM base
COPY --from=testa /.dummy /.dummy
COPY --from=testb-gitpod /.dummy /.dummy
COPY --from=testc /.dummy /.dummy
COPY --from=testd /.dummy /.dummy
COPY --from=teste /.dummy /.dummy