-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
87 lines (77 loc) · 2.67 KB
/
Dockerfile
File metadata and controls
87 lines (77 loc) · 2.67 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
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
ARG ALPINE_VERSION
FROM alpine:${ALPINE_VERSION} AS build-stage
ARG TARGETARCH
ARG TARGETVARIANT
ARG ALPINE_RELEASE
ENV REL=${ALPINE_RELEASE}
ENV ROOTFS=/root-out
ENV MIRROR=http://dl-cdn.alpinelinux.org/alpine
ENV PACKAGES=alpine-baselayout,\
alpine-keys,\
apk-tools,\
busybox,\
libc-utils
# set version for s6 overlay
ARG S6_OVERLAY_VERSION="3.2.0.2"
ARG S6_OVERLAY_ARCH
# build rootfs and add s6 overlay
RUN \
apk add --no-cache \
bash \
curl \
xz && \
if [ ${TARGETARCH}${TARGETVARIANT} == amd64 ]; then ARCH=x86_64; \
elif [ ${TARGETARCH}${TARGETVARIANT} == arm64 ]; then ARCH=aarch64; fi && \
if [ -z ${S6_OVERLAY_ARCH+x} ]; then S6_OVERLAY_ARCH=${ARCH}; fi && \
mkdir -p "$ROOTFS/etc/apk" && \
{ \
echo "$MIRROR/$REL/main"; \
echo "$MIRROR/$REL/community"; \
} > "$ROOTFS/etc/apk/repositories" && \
apk --root "$ROOTFS" --no-cache --keys-dir /etc/apk/keys add --arch $ARCH --initdb ${PACKAGES//,/ } && \
sed -i -e 's/^root::/root:!:/' /root-out/etc/shadow && \
curl -sLO --output-dir /tmp "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" && \
tar -C /root-out -Jxpf /tmp/s6-overlay-noarch.tar.xz && \
curl -sLO --output-dir /tmp "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz" && \
tar -C /root-out -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz && \
curl -sLO --output-dir /tmp "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz" && \
tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz && \
curl -sLO --output-dir /tmp "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz" && \
tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz
# runtime stage
FROM scratch
COPY --from=build-stage /root-out/ /
ENV PS1="$(whoami)@$(hostname):$(pwd)\\$" \
HOME="/root" \
TERM="xterm" \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" \
S6_BEHAVIOUR_IF_STAGE2_FAILS="2" \
S6_VERBOSITY="1"
# install packages
RUN \
apk update && apk add --no-cache \
alpine-release \
bash \
ca-certificates \
coreutils \
curl \
jq \
netcat-openbsd \
procps-ng \
shadow \
tzdata && \
# create user and make folders
groupmod -g 1000 users && \
useradd -u 901 -U -d /config -s /bin/false disty && \
usermod -G users disty && \
mkdir -p \
/app \
/config \
/defaults && \
# cleanup
rm -rf \
/tmp/* \
/var/cache/apk/*
# add local files
COPY src/ /
ENTRYPOINT ["/init"]