-
Notifications
You must be signed in to change notification settings - Fork 245
/
Dockerfile
444 lines (398 loc) · 35.4 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
########################################################################################################################
# Introduction
########################################################################################################################
# This is a multi-stage build, which eventually results in a squashed image.
# The image intended for release/use is the one obtained using `docker build --target=superchain ...`.
#
# Stages are as follows
# 1. [bindist] Prepare a bunch of binary distributions
# 2. [staging] Prepare the superchain staging image
# 3. [superchain] Squash into a single layer
# 4. [test] Run tests on the superchain stage
#
# Multi-stage build allows several of these steps to run in parallel up to some point. It makes the build cache usage
# more efficient, and allows us to run cross-architecture builds in the most efficient possible manner, by running the
# "platform-independent" elements within the build platform, which does not require any kind of emulation.
ARG DEBIAN_VERSION="bookworm"
########################################################################################################################
# NOTE: This uses public.ecr.aws/docker/library/debian instead of public.ecr.aws/debian/debian (which would be
# preferred) due to an ECR Public issue currently blocking the use of the later.
#
# See: https://github.com/aws/containers-roadmap/issues/2023
########################################################################################################################
########################################################################################################################
# Prepare install images of "manual" binary distributions (runs on BUILD platform for speed)
########################################################################################################################
FROM --platform=${BUILDPLATFORM} public.ecr.aws/docker/library/debian:${DEBIAN_VERSION}-slim as bindist
# Build & target platforms, they are provided by buildx and will look like "linux/amd64" or "linux/arm64"
ARG BUILDPLATFORM
ARG TARGETPLATFORM
# Setting defaults for backwards compatibility with "docker build" (see https://github.com/docker/buildx/issues/510)
ENV BUILDPLATFORM=${BUILDPLATFORM:-linux/amd64} \
TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
ARG DEBIAN_VERSION="bookworm"
# We require a couple of tools to be available in order to work here...
RUN echo "deb http://deb.debian.org/debian ${DEBIAN_VERSION}-backports main" \
> "/etc/apt/sources.list.d/${DEBIAN_VERSION}-backports.list" \
&& apt-get update \
&& apt-get install -y gpg tar zsh \
# We need a "recent" (>= 7.71) version of curl for --retry-all-errors, so we get it from backports...
&& apt-get install -y -t "${DEBIAN_VERSION}-backports" curl
# We'll be using zsh substitutions, so ensuring this is the shell we use
SHELL ["/bin/zsh", "-c"]
# Prepare maven binary distribution
ARG M2_VERSION="3.9.4"
ENV M2_DISTRO="https://downloads.apache.org/maven/maven-3"
RUN set -eo pipefail \
&& curl -fSsL "${M2_DISTRO}/${M2_VERSION}/binaries/apache-maven-${M2_VERSION}-bin.tar.gz" \
-o /tmp/apache-maven.tar.gz \
&& curl -fSsL "${M2_DISTRO}/${M2_VERSION}/binaries/apache-maven-${M2_VERSION}-bin.tar.gz.asc" \
-o /tmp/apache-maven.tar.gz.asc \
&& mkdir -p /tmp/gpg-maven && chmod go-rwx /tmp/gpg-maven \
&& curl -fSsL "https://downloads.apache.org/maven/KEYS" | gpg --homedir /tmp/gpg-maven --import \
&& gpg --homedir /tmp/gpg-maven --verify /tmp/apache-maven.tar.gz.asc /tmp/apache-maven.tar.gz \
&& mkdir -p /opt/apache/maven \
&& tar xzf /tmp/apache-maven.tar.gz -C /opt/apache/maven --strip-components=1
# Prepare .NET Core distribution
ARG DOTNET_CHANNEL="6.0"
ENV DOTNET_FEED="https://dotnetcli.blob.core.windows.net/dotnet"
RUN DOTNET_VERSION=$(curl -fSsL "${DOTNET_FEED}/Sdk/${DOTNET_CHANNEL}/latest.version") \
&& DOTNET_ASSET="dotnet-sdk-${DOTNET_VERSION}-linux-${${TARGETPLATFORM#linux/}/amd64/x64}.tar.gz" \
&& curl -fSsL "${DOTNET_FEED}/Sdk/${DOTNET_VERSION}/${DOTNET_ASSET}" -o /tmp/dotnet.tar.gz \
&& mkdir -p /opt/microsoft/dotnet \
&& tar zxf /tmp/dotnet.tar.gz -C /opt/microsoft/dotnet
# Prepare PowerShell LTS distribution
ENV POWERSHELL_RELEASES="https://github.com/PowerShell/PowerShell/releases"
RUN POWERSHELL_RELEASE=$(curl -X GET -fSsIL "https://aka.ms/powershell-release?tag=lts" -o /dev/null \
--retry 5 --retry-all-errors -w %{url_effective}) \
&& POWERSHELL_VERSION=${POWERSHELL_RELEASE#${POWERSHELL_RELEASES}/tag/v} \
&& ASSET="powershell-${POWERSHELL_VERSION}-linux-${${TARGETPLATFORM#linux/}/amd64/x64}.tar.gz" \
&& curl -fSsL "${POWERSHELL_RELEASES}/download/v${POWERSHELL_VERSION}/${ASSET}" --retry 5 --retry-all-errors \
-o /tmp/powershell.tar.gz \
&& mkdir -p /opt/microsoft/powershell \
&& tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell \
&& chmod +x /opt/microsoft/powershell/pwsh
# Prepare Go distribution
ARG GO_VERSION="1.18.5"
RUN curl -fSsL "https://golang.org/dl/go${GO_VERSION}.linux-${TARGETPLATFORM#linux/}.tar.gz" -o /tmp/go.tar.gz \
&& mkdir -p /opt/golang/go \
&& tar -xzf /tmp/go.tar.gz -C /opt/golang/go --strip-components=1
########################################################################################################################
# Set up the image
########################################################################################################################
FROM public.ecr.aws/docker/library/debian:${DEBIAN_VERSION}-slim as staging
# Build & target platforms, they are provided by buildx and will look like "linux/amd64" or "linux/arm64"
ARG BUILDPLATFORM
ARG TARGETPLATFORM
# Setting defaults for backwards compatibility with "docker build" (see https://github.com/docker/buildx/issues/510)
ENV BUILDPLATFORM=${BUILDPLATFORM:-linux/amd64} \
TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
ARG DEBIAN_VERSION="bookworm"
SHELL ["/bin/bash", "-c"]
# Set locale and some other interesting environment variables
ENV LANG="C.UTF-8" \
LC_ALL="C.UTF-8" \
CHARSET="UTF-8" \
\
DOTNET_RUNNING_IN_CONTAINER="true" \
DOTNET_USE_POLLING_FILE_WATCHER="true" \
NUGET_XMLDOC_MODE="skip" \
\
M2_HOME="/opt/apache/maven" \
M2="/opt/apache/maven/bin" \
\
GOROOT="/opt/golang/go"
# Installing the system dependencies we need...
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y install --no-install-recommends \
apt-transport-https \
build-essential \
ca-certificates \
curl \
dirmngr \
git \
gnupg \
gzip \
libffi-dev \
libicu-dev \
libssl-dev \
openssh-client \
openssl \
rsync \
sudo \
unzip \
zip \
acl \
&& rm -rf /var/lib/apt/lists/*
# Install mono
COPY superchain/gpg/mono.asc /tmp/mono.asc
RUN apt-key add /tmp/mono.asc && rm /tmp/mono.asc \
# Mono only provides a Debian Buster (10) distribution point, but it works with subsequent debians, too...
&& echo "deb https://download.mono-project.com/repo/debian stable-buster main" \
> /etc/apt/sources.list.d/mono-official-stable.list \
&& apt-get update \
&& apt-get -y install mono-devel \
&& rm -rf /var/lib/apt/lists/*
# Install Rust (required for https://pypi.org/project/cryptography/ in certain circumstances... like ARM64 arch)
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo
RUN set -eo pipefail \
&& curl -fSsL "https://sh.rustup.rs" | sh -s -- -y --no-modify-path --profile=minimal \
&& echo "source ${CARGO_HOME}/env" >> /etc/profile.d/cargo.sh \
&& chmod -R a+rw ${CARGO_HOME}
ENV PATH=$PATH:${CARGO_HOME}/bin
# Install Python 3 and pipx
# Starting in 'bookworm', 'pip install' needs special coercing (and 'apt-get install pipx' would be recommended)
# but that flag is not recognized yet in older distros.
RUN apt-get update \
&& apt-get -y install python3-dev python3-pip python3-venv \
&& coercepip='--break-system-packages' \
&& if [[ ${DEBIAN_VERSION} == "buster" || ${DEBIAN_VERSION} == "bullseye" ]]; then coercepip=''; fi \
&& python3 -m pip install ${coercepip} pipx "pip>=23.3.1" "setuptools>=68.0.0" "wheel>=0.41.3" \
&& rm -rf /var/lib/apt/lists/*
# Install Python tools globally using pipx (install globally)
ENV PIPX_HOME=/opt/pipx
ENV PIPX_BIN_DIR=/usr/local/bin
RUN pipx install black \
&& pipx install twine \
&& pipx install aws-sam-cli
# Install AWS CLI v2
ENV AWS_CLI_V2_URL='https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip'
RUN curl "${AWS_CLI_V2_URL}" -o "/tmp/awscliv2.zip" \
&& unzip /tmp/awscliv2.zip -d /tmp/awscliv2 \
&& /tmp/awscliv2/aws/install -b /usr/local/bin --update \
&& rm -rf /tmp/awscliv2*
# Install JDK8 (Amazon Corretto 8)
COPY superchain/gpg/corretto.asc /tmp/corretto.asc
RUN apt-key add /tmp/corretto.asc && rm /tmp/corretto.asc \
&& echo "deb https://apt.corretto.aws stable main" > /etc/apt/sources.list.d/amazon-corretto.list \
&& apt-get update \
&& mkdir -p /usr/share/man/man1 \
&& apt-get -y install java-20-amazon-corretto-jdk \
&& rm -rf /usr/share/man/man1 \
&& rm -rf /var/lib/apt/lists/*
# Install Docker
COPY superchain/gpg/docker.asc /tmp/docker.asc
RUN apt-key add /tmp/docker.asc && rm /tmp/docker.asc \
&& echo "deb https://download.docker.com/linux/debian ${DEBIAN_VERSION} stable" > /etc/apt/sources.list.d/docker.list \
&& apt-get update \
&& apt-get -y install docker-ce docker-ce-cli containerd.io \
&& rm -rf /var/lib/apt/lists/*
VOLUME /var/lib/docker
# Install GitHub CLI
ARG GITHUB_CLI_VERSION="1.13.1"
RUN BASE="https://github.com/cli/cli/releases/download" \
&& echo "${BASE}/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_${TARGETPLATFORM#linux/}.deb" \
&& curl -fSsL "${BASE}/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_${TARGETPLATFORM#linux/}.deb" \
-o /tmp/gh.deb \
&& apt-get update \
&& apt-get -y install /tmp/gh.deb \
&& rm /tmp/gh.deb \
&& rm -rf /var/lib/apt/lists/*
# Install .NET Core and PowerShell
COPY --from=bindist /opt/microsoft/dotnet /opt/microsoft/dotnet
RUN ln -s /opt/microsoft/dotnet/dotnet /usr/bin/dotnet
COPY --from=bindist /opt/microsoft/powershell /opt/microsoft/powershell
RUN ln -s /opt/microsoft/powershell/pwsh /usr/bin/pwsh
# Install Maven
COPY --from=bindist /opt/apache/maven ${M2_HOME}
COPY superchain/m2-settings.xml /root/.m2/settings.xml
# Install Go
COPY --from=bindist /opt/golang/go ${GOROOT}
# Install Node (configurable with '--build-arg NODE_MAJOR_VERSION=xxx') and yarn
# (Put this as late as possible in the Dockerfile so we get to reuse the layer cache
# for most of the multiple builds).
ARG NODE_MAJOR_VERSION="18"
COPY superchain/gpg/nodesource.asc /tmp/nodesource.asc
COPY superchain/gpg/yarn.asc /tmp/yarn.asc
RUN apt-key add /tmp/nodesource.asc && rm /tmp/nodesource.asc \
&& echo "deb https://deb.nodesource.com/node_${NODE_MAJOR_VERSION}.x nodistro main" \
> /etc/apt/sources.list.d/nodesource.list \
# Increase priority of the nodesource package
&& echo "Package: nodejs" > /etc/apt/preferences.d/nodejs \
&& echo 'Pin: origin deb.nodesource.com"' >> /etc/apt/preferences.d/nodejs \
&& echo "Pin-Priority: 600" >> /etc/apt/preferences.d/nodejs \
&& apt-key add /tmp/yarn.asc && rm /tmp/yarn.asc \
&& echo "deb https://dl.yarnpkg.com/debian stable main" > /etc/apt/sources.list.d/yarnpkg.list \
&& apt-get update \
&& apt-get -y install nodejs yarn \
&& rm -rf /var/lib/apt/lists/*
# Install Amazon SSM agent (allows debugging of builds via `codebuild-breakpoint`, https://go.aws/3TVW7vL)
RUN apt-get update \
&& apt-get -y install --no-install-recommends curl \
&& curl -fSsL "https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_${TARGETPLATFORM#linux/}/amazon-ssm-agent.deb"\
-o /tmp/amazon-ssm-agent.deb \
&& dpkg -i /tmp/amazon-ssm-agent.deb \
&& systemctl enable amazon-ssm-agent \
&& rm -rf /var/lib/apt/lists/*
COPY --chown=superchain:superchain superchain/amazon-ssm-agent.json /etc/amazon/ssm/amazon-ssm-agent.json
# Install some configuration
COPY superchain/ssh_config /root/.ssh/config
RUN chmod 600 /root/.ssh/config
# Create the image's non-root user, and enable no-password sudo
RUN groupadd --gid 1001 superchain \
&& useradd --shell /bin/bash --comment "Docker User" --uid 1001 --gid 1001 --no-log-init --groups sudo superchain \
&& echo "%sudo ALL = (ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/nopasswd \
&& echo "superchain ALL = (ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/nopasswd \
&& chmod 0440 /etc/sudoers.d/nopasswd
COPY --chown=superchain:superchain superchain/m2-settings.xml /home/superchain/.m2/settings.xml
COPY --chown=superchain:superchain superchain/ssh_config /home/superchain/.ssh/config
RUN chmod 600 /home/superchain/.ssh/config
# Create the attributions document
RUN RUST_DOCS="${RUSTUP_HOME}/toolchains/$(rustup show active-toolchain | cut -d' ' -f 1)/share/doc" \
&& RUSTUP_VERSION=$(rustup --version 2>/dev/null | cut -d' ' -f2) \
&& echo "This public.ecr.aws/jsii/superchain image includes the following third-party software/licensing:" > /NOTICE \
&& echo "" >> /NOTICE \
# Start with the packages that didn't come from "apt-get" or don't have a copyright file
&& echo "################################################################################" >> /NOTICE \
&& echo "docker-ce:" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ NOTICE ------------------------------------" >> /NOTICE \
&& curl -fSsL "https://github.com/docker/cli/raw/master/NOTICE" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE ------------------------------------" >> /NOTICE \
&& curl -fSsL "https://github.com/docker/cli/raw/master/LICENSE" >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "docker-ce-cli:" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ NOTICE ------------------------------------" >> /NOTICE \
&& curl -fSsL "https://github.com/moby/moby/raw/master/NOTICE" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE ------------------------------------" >> /NOTICE \
&& curl -fSsL "https://github.com/moby/moby/raw/master/LICENSE" >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "dotnet:" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE ------------------------------------" >> /NOTICE \
&& cat /opt/microsoft/dotnet/LICENSE.txt >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ THIRD-PARTY NOTICES ------------------------------------" >> /NOTICE \
&& cat /opt/microsoft/dotnet/ThirdPartyNotices.txt >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "gh:" >> /NOTICE \
&& curl -fSsL "https://github.com/cli/cli/raw/trunk/LICENSE" >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "go:" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE ------------------------------------" >> /NOTICE \
&& cat ${GOROOT}/LICENSE >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ PATENTS ------------------------------------" >> /NOTICE \
&& cat ${GOROOT}/PATENTS >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "java-20-amazon-corretto-jdk:" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE ------------------------------------" >> /NOTICE \
&& cat /usr/lib/jvm/java-20-amazon-corretto/LICENSE >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ THIRD-PARTY NOTICES ------------------------------------" >> /NOTICE \
&& cat /usr/lib/jvm/java-20-amazon-corretto/ADDITIONAL_LICENSE_INFO >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "maven:" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ NOTICE ------------------------------------" >> /NOTICE \
&& cat ${M2_HOME}/NOTICE >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE ------------------------------------" >> /NOTICE \
&& cat ${M2_HOME}/LICENSE >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "cargo:" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE (APACHE) ------------------------------------" >> /NOTICE \
&& cat ${RUST_DOCS}/cargo/LICENSE-APACHE >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE (MIT) ------------------------------------" >> /NOTICE \
&& cat ${RUST_DOCS}/cargo/LICENSE-MIT >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ THIRD-PARTY LICENSES ------------------------------------" >> /NOTICE \
&& cat ${RUST_DOCS}/cargo/LICENSE-THIRD-PARTY >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "rust:" >> /NOTICE \
&& cat ${RUST_DOCS}/rust/COPYRIGHT >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "rustup:" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE (APACHE) ------------------------------------" >> /NOTICE \
&& curl -fSsL "https://github.com/rust-lang/rustup/raw/${RUSTUP_VERSION}/LICENSE-APACHE" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE (MIT) ------------------------------------" >> /NOTICE \
&& curl -fSsL "https://github.com/rust-lang/rustup/raw/${RUSTUP_VERSION}/LICENSE-MIT" >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
&& echo "powershell:" >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ LICENSE ------------------------------------" >> /NOTICE \
&& cat /opt/microsoft/powershell/LICENSE.txt >> /NOTICE \
&& echo "" >> /NOTICE \
&& echo "------------------------------------ THIRD-PARTY NOTICES ------------------------------------" >> /NOTICE \
&& cat /opt/microsoft/powershell/ThirdPartyNotices.txt >> /NOTICE \
&& echo "################################################################################" >> /NOTICE \
# Clean up
&& unset RUST_DOCS RUSTUP_VERSION \
# And then aggregate everything that came from dpkg which ships a copyright file
&& for PKG in $(dpkg-query --show --showformat='${package}\n'); do \
if [[ -f "/usr/share/doc/${PKG}/copyright" ]]; then \
echo "${PKG}:" >> /NOTICE \
&& cat /usr/share/doc/${PKG}/copyright >> /NOTICE \
&& echo '################################################################################' >> /NOTICE \
;fi \
;done
# Add the source used to build this Docker image (to facilitate re-builds, forensics)
# Keep this at the end for max caching.
COPY superchain /docker-source
CMD ["/bin/bash"]
########################################################################################################################
# Creating squashed image
########################################################################################################################
FROM scratch as superchain
# Set locale and some other interesting environment variables
ENV LANG="C.UTF-8" \
LC_ALL="C.UTF-8" \
CHARSET="UTF-8" \
\
JAVA_HOME="/usr/lib/jvm/java-20-amazon-corretto" \
\
DOTNET_CLI_TELEMETRY_OPTOUT="true" \
DOTNET_RUNNING_IN_CONTAINER="true" \
DOTNET_NOLOGO="true" \
DOTNET_USE_POLLING_FILE_WATCHER="true" \
NUGET_XMLDOC_MODE="skip" \
\
M2_HOME="/opt/apache/maven" \
M2="/opt/apache/maven/bin" \
MAVEN_OPTS="-Xms256m -Xmx512m" \
\
GOROOT="/opt/golang/go" \
RUSTUP_HOME="/usr/local/rustup" \
CARGO_HOME="/usr/local/cargo"
ENV PATH="${PATH}:${CARGO_HOME}/bin:${GOROOT}/bin:${M2}"
COPY --from=staging / /
VOLUME /var/lib/docker
## Image Metadata
ARG BUILD_TIMESTAMP
ARG COMMIT_ID
LABEL org.opencontainers.image.created=${BUILD_TIMESTAMP} \
org.opencontainers.image.title="jsii/superchain" \
org.opencontainers.image.description="An image to build cross-language artifacts with AWS jsii" \
org.opencontainers.image.url="https://github.com/aws/jsii/tree/main/superchain" \
org.opencontainers.image.source="https://github.com/aws/jsii.git" \
org.opencontainers.image.revision=$COMMIT_ID \
org.opencontainers.image.authors="Amazon Web Services (https://aws.amazon.com)"
USER superchain:superchain
CMD ["/bin/bash"]
########################################################################################################################
# Running tests
########################################################################################################################
FROM superchain as test
ENV CI=true
COPY --chown=superchain:superchain . /tmp/source
VOLUME /var/lib/docker
WORKDIR /tmp/source
# Make sure we start fresh (symlinks from outside the build may cause issues, e.g: python venvs)
RUN git clean -fqdx
# Install all dependencies again
RUN yarn install --frozen-lockfile
# Build the code
RUN yarn build
# Test the code
RUN yarn test