-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathDockerfile
270 lines (187 loc) · 6.89 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#--------------------------------------
# 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"]
COPY src/ /
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: curl
#--------------------------------------
FROM build as testa
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}
# 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}
#--------------------------------------
# test: python
#--------------------------------------
FROM build as testb
# renovate: datasource=github-releases depName=python packageName=containerbase/python-prebuild
ARG PYTHON_VERSION=3.11.4
RUN install-tool python
RUN set -ex; [ $(stat --format '%u' "/usr/local/bin/python") -eq ${USER_ID} ]
RUN set -ex; \
nginx && su -c 'SSL_CERT_FILE=/test/ca.pem python request.py' ${USER_NAME}
#--------------------------------------
# test: node
#--------------------------------------
FROM build as testc
# renovate: datasource=node
RUN install-tool node v18.17.0
RUN set -ex; \
nginx && su -c 'NODE_EXTRA_CA_CERTS=/test/ca.pem node request.mjs' ${USER_NAME}
#--------------------------------------
# test: php
#--------------------------------------
FROM build as testd
# 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} ]
RUN set -ex; \
nginx && su -c 'SSL_CERT_FILE=/test/ca.pem php request.php' ${USER_NAME}
#--------------------------------------
# test: ruby
#--------------------------------------
FROM build as teste
# 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; \
nginx && su -c 'SSL_CERT_FILE=/test/ca.pem ruby request.rb' ${USER_NAME}
#--------------------------------------
# test: powershell
#--------------------------------------
FROM build as testf
# renovate: datasource=github-releases packageName=PowerShell/PowerShell
RUN install-tool powershell v7.3.6
RUN set -ex; cat /etc/hosts; \
nginx && SSL_CERT_FILE=/test/ca.pem pwsh -c "&{ \$ErrorActionPreference='Stop'; invoke-webrequest https://buildkitsandbox }"
#--------------------------------------
# test: terraform
#--------------------------------------
FROM ubuntu:focal as testg
ARG USER_NAME=terraform
ARG USER_ID=1005
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_ID}
SHELL ["/bin/sh", "-c"]
# renovate: datasource=docker packageName=hashicorp/terraform versioning=docker
RUN install-tool terraform 1.5.4
WORKDIR /tmp
RUN mkdir $HOME/.tf-cache && TF_PLUGIN_CACHE_DIR=$HOME/.tf-cache terraform init
#--------------------------------------
# test: ignore tools
#--------------------------------------
FROM build as testh
RUN prepare-tool docker
# TODO: move to prepare of git-lfs
# renovate: datasource=github-tags packageName=git/git
RUN install-tool git v2.41.0
USER 1000
ARG IGNORED_TOOLS=powershell,node
# renovate: datasource=github-releases packageName=fluxcd/flux2
RUN install-tool flux v2.0.1
# renovate: datasource=github-releases packageName=git-lfs/git-lfs
RUN install-tool git-lfs v3.4.0
# renovate: datasource=github-releases packageName=PowerShell/PowerShell
RUN install-tool powershell v7.3.6
# renovate: datasource=node
RUN install-tool node v18.17.0
# renovate: datasource=github-releases packageName=moby/moby
RUN install-tool docker v24.0.5
#--------------------------------------
# test: bin path has 775
#--------------------------------------
FROM base as testi
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: vendir, helmfile, kustomize
#--------------------------------------
FROM base as testj
# 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 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 /.dummy /.dummy
COPY --from=testc /.dummy /.dummy
COPY --from=testd /.dummy /.dummy
COPY --from=teste /.dummy /.dummy
COPY --from=testf /.dummy /.dummy
COPY --from=testg /.dummy /.dummy
COPY --from=testh /.dummy /.dummy
COPY --from=testi /.dummy /.dummy
COPY --from=testj /.dummy /.dummy