-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (47 loc) · 2.19 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (47 loc) · 2.19 KB
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
FROM arm64v8/buildpack-deps:jammy-curl AS chisel
RUN apt-get update && apt-get install -y file
RUN curl --fail --show-error --location --output chisel.tar.gz https://github.com/canonical/chisel/releases/download/v1.4.2/chisel_v1.4.2_linux_arm64.tar.gz \
&& chisel_sha384='216f10d4cc461411558fa4ac03fc24e104589126f87657457877389ae8015e1eac4299fcd8557c0dfea3d33342aa3297' \
&& echo "$chisel_sha384 chisel.tar.gz" | sha384sum -c - \
&& tar --gzip --extract --no-same-owner --file chisel.tar.gz --directory /usr/bin/ \
&& rm chisel.tar.gz \
&& curl --fail --show-error --location --output /usr/bin/chisel-wrapper https://raw.githubusercontent.com/canonical/rocks-toolbox/v1.2.0/chisel-wrapper \
&& chmod 755 /usr/bin/chisel-wrapper
RUN groupadd \
--gid=1654 \
app \
&& useradd --no-log-init \
--uid=1654 \
--gid=1654 \
--shell /bin/false \
app \
&& install --directory --mode 0755 --owner 1654 --group 1654 "/rootfs/home/app" \
&& mkdir --parents "/rootfs/etc" \
&& rootOrAppRegex='^\(root\|app\):' \
&& cat /etc/passwd | grep $rootOrAppRegex > "/rootfs/etc/passwd" \
&& cat /etc/group | grep $rootOrAppRegex > "/rootfs/etc/group"
RUN mkdir --parents /rootfs/var/lib/dpkg/ \
&& chisel-wrapper --generate-dpkg-status /rootfs/var/lib/dpkg/status -- \
--release ubuntu-22.04 --root /rootfs \
base-files_base \
base-files_release-info \
ca-certificates_data \
libc6_libs \
libgcc-s1_libs \
libssl3_libs \
libstdc++6_libs \
zlib1g_libs
FROM scratch
COPY --from=chisel /rootfs /
ENV \
# UID of the non-root user 'app'
APP_UID=1654 \
# Configure web servers to bind to port 8080 when present
ASPNETCORE_HTTP_PORTS=8080 \
# Enable detection of running in a container
DOTNET_RUNNING_IN_CONTAINER=true \
# Set the invariant mode since ICU package isn't included (see https://github.com/dotnet/announcements/issues/20)
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
# Workaround for https://github.com/moby/moby/issues/38710
COPY --from=chisel --chown=$APP_UID:$APP_UID /rootfs/home/app /home/app
USER $APP_UID