forked from containerbase/base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
204 lines (145 loc) · 4.28 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
#--------------------------------------
# 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
# Used for tests
# renovate: datasource=github-tags packageName=git/git
RUN install-tool git v2.42.1
COPY --chown=1000:0 test/java/test test
WORKDIR /test
#--------------------------------------
# build: Java LTS base
#--------------------------------------
FROM base as build
RUN prepare-tool java
RUN [ "$(find /tmp -type f | wc -l)" -eq 0 ]
RUN set -ex; \
ls -la /tmp; \
find /tmp -type f; \
exit 0
# TODO: only lts
# renovate: datasource=adoptium-java packageName=java-jre
RUN install-tool java 11.0.21+9
RUN set -ex; \
ls -la /tmp; \
find /tmp -type f; \
exit 0
RUN [ "$(find /tmp -type f | wc -l)" -eq 0 ]
#--------------------------------------
# test: gradle 6
#--------------------------------------
FROM build as test-gradle-a
RUN prepare-tool gradle
RUN set -ex; \
ls -la $USER_HOME; \
[ $(stat --format '%a' "${USER_HOME}/.gradle") -eq 775 ]; \
[ $(stat --format '%a' "${USER_HOME}/.m2") -eq 775 ]; \
exit 0
USER 1000
# 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=adoptium-java packageName=java-jre
RUN install-tool java-jre 21.0.1+12.0.LTS
# renovate: datasource=gradle-version versioning=gradle
RUN install-tool gradle 8.4
USER 1000
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 + gradle 7
#--------------------------------------
FROM build as test-gradle-c
# need to stay old
# disable renovate: datasource=adoptium-java packageName=java-jre
RUN install-tool java 8.0.342+7
# disable renovate: datasource=gradle-version versioning=gradle
RUN install-tool gradle 7.6.1
# test openshift userid missmatch
USER 1001
RUN gradle --version
#--------------------------------------
# test: java 17 (non-root)
#--------------------------------------
FROM base as test-gradle-d
RUN prepare-tool java gradle
# test openshift userid missmatch
USER 1001
# renovate: datasource=adoptium-java depName=java
ARG JAVA_JDK_VERSION=17.0.9+9
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
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.5
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.12
# renovate: datasource=github-releases packageName=sbt/sbt
RUN install-tool sbt v1.9.7
# doesn't work for arbitrary users
USER 1000
WORKDIR /test
RUN set -ex; \
cd sbt; \
ls -la; env; \
sbt compile
#--------------------------------------
# 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