-
Notifications
You must be signed in to change notification settings - Fork 41
/
Dockerfile
240 lines (171 loc) · 5.2 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
ARG BASE_IMAGE=containerbase
#--------------------------------------
# Image: containerbase
#--------------------------------------
FROM ghcr.io/containerbase/ubuntu:24.04 AS containerbase
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
ARG APT_HTTP_PROXY
ARG CONTAINERBASE_CDN
ARG CONTAINERBASE_DEBUG
ARG CONTAINERBASE_LOG_LEVEL
RUN install-containerbase
# Used for tests
# renovate: datasource=github-tags packageName=git/git
RUN install-tool git v2.47.0
#--------------------------------------
# Image: base
#--------------------------------------
FROM ${BASE_IMAGE} AS base
RUN touch /.dummy
ARG APT_HTTP_PROXY
ARG CONTAINERBASE_CDN
ARG CONTAINERBASE_DEBUG
ARG CONTAINERBASE_LOG_LEVEL
COPY --chown=12021:0 test/java/test test
WORKDIR /test
#--------------------------------------
# build: Java LTS base
#--------------------------------------
FROM base AS build
RUN prepare-tool java
RUN set -ex; \
ls -la $USER_HOME; \
[ $(stat --format '%a' "${USER_HOME}/.gradle") -eq 777 ]; \
[ $(stat --format '%a' "${USER_HOME}/.m2") -eq 777 ]; \
true
RUN set -ex; \
ls -la /tmp; \
find /tmp -mindepth 1 -maxdepth 1; \
true
RUN [ "$(find /tmp -mindepth 1 -maxdepth 1 | wc -l)" -eq 1 ]
# renovate: datasource=java-version packageName=java-jre
RUN install-tool java 21.0.5+11.0.LTS
RUN set -ex; \
ls -la /tmp; \
true
RUN [ "$(find /tmp -mindepth 1 -maxdepth 1 | wc -l)" -eq 1 ]
#--------------------------------------
# test: Java 11 LTS + Gradle 6
#--------------------------------------
FROM build AS test-gradle-a
RUN install-tool java 11.0.23+9
RUN prepare-tool gradle
USER 12021
# stay on v6
RUN install-tool gradle 6.9
# disable renovate: datasource=gradle-version versioning=gradle
RUN install-tool gradle 6.9.4
RUN set -ex; \
gradle --version;
RUN set -ex; \
git init .; \
touch settings.gradle; \
gradle wrapper; \
git diff; \
./gradlew --version
RUN gradle --version
#--------------------------------------
# test: Java 21 LTS + Gradle 8
#--------------------------------------
FROM base AS test-gradle-b
# renovate: datasource=java-version packageName=java-jre
RUN install-tool java-jre 21.0.5+11.0.LTS
# renovate: datasource=gradle-version versioning=gradle
RUN install-tool gradle 8.11.1
USER 12021
RUN set -ex; \
gradle --version;
RUN set -ex; \
git init .; \
touch settings.gradle; \
gradle wrapper; \
git diff; \
./gradlew --version
SHELL [ "/bin/sh", "-c" ]
RUN gradle --version
#--------------------------------------
# test: Java 8 LTS + Gradle 7
#--------------------------------------
FROM build AS test-gradle-c
# need to stay old
RUN install-tool java 8.0.342+7
# disable renovate: datasource=gradle-version versioning=gradle
RUN install-tool gradle 7.6.1
RUN set -ex; \
ls -la /root/; \
ls -la /opt/containerbase/; \
ls -la /tmp/containerbase/cache/; \
ls -la /tmp/containerbase/cache/.gradle; \
true
# test openshift userid missmatch
USER 1001
RUN gradle --version
#--------------------------------------
# test: Java 17 LTS (non-root)
#--------------------------------------
FROM base AS test-gradle-d
RUN prepare-tool java gradle
# test openshift userid missmatch
USER 1001
# renovate: datasource=java-version depName=java
ARG JAVA_JDK_VERSION=21.0.5+11.0.LTS
RUN install-tool java-jdk
# test latest gradle
RUN install-tool gradle latest
RUN gradle --version
# fail if java version mismatch
RUN gradle --version | grep "${JAVA_VERSION}"
#--------------------------------------
# test: maven
#--------------------------------------
FROM build AS test-maven-a
# test openshift userid missmatch
USER 1001
# test archive.apache.org, failing too often
# RUN install-tool maven 3.1.0-alpha-1
RUN install-tool maven 3.5.4
# renovate: datasource=maven packageName=org.apache.maven:maven
RUN install-tool maven 3.9.9
RUN set -ex; \
mkdir -p /tmp/mvn && cd /tmp/mvn; \
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false;
#--------------------------------------
# test: Scala / sbt
#--------------------------------------
FROM build AS test-others
WORKDIR /
# not required / used for sbt
# renovate: datasource=github-releases packageName=scala/scala
RUN install-tool scala v2.13.15
# renovate: datasource=github-releases packageName=sbt/sbt
RUN install-tool sbt v1.10.5
RUN install-tool gradle 8.8-rc-2
# doesn't work for arbitrary users
USER 12021
WORKDIR /test
RUN set -ex; \
cd sbt; \
ls -la; env; \
sbt compile
#--------------------------------------
# test: Resolve latest versions
#--------------------------------------
FROM base AS test-latest-version
RUN install-tool java-jre
RUN install-tool gradle
RUN install-tool maven
#--------------------------------------
# final
#--------------------------------------
FROM base
COPY --from=test-gradle-a /.dummy /.dummy
COPY --from=test-gradle-b /.dummy /.dummy
COPY --from=test-gradle-c /.dummy /.dummy
COPY --from=test-gradle-d /.dummy /.dummy
COPY --from=test-maven-a /.dummy /.dummy
COPY --from=test-others /.dummy /.dummy
COPY --from=test-latest-version /.dummy /.dummy