-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
121 lines (115 loc) · 5.24 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
# syntax=docker/dockerfile:1.13.0@sha256:426b85b823c113372f766a963f68cfd9cd4878e1bcc0fda58779127ee98a28eb
ARG BASE=distcc
FROM ksmanis/stage3:20250203@sha256:be7c50b025889c63e09dd1b05f47c35bb1175769e64c732497c7c54f5d9a80f7 AS distcc
ARG CROSSDEV_TARGETS=
RUN --mount=type=bind,from=ksmanis/gentoo-distcc:tcp,source=/var/cache/binpkgs,target=/cache \
--mount=type=bind,from=ksmanis/portage,source=/var/db/repos/gentoo,target=/var/db/repos/gentoo \
set -eux; \
cp -av /cache/. /var/cache/binpkgs; \
getuto; \
export EMERGE_DEFAULT_OPTS="--buildpkg --color=y --getbinpkg --quiet-build --tree --verbose"; \
emerge --info; \
emerge distcc; \
distcc --version; \
if [ -n "${CROSSDEV_TARGETS}" ]; then \
emerge crossdev; \
crossdev --version; \
mkdir -p /var/db/repos/crossdev/metadata; \
echo 'masters = gentoo' > /var/db/repos/crossdev/metadata/layout.conf; \
mkdir -p /var/db/repos/crossdev/profiles; \
echo 'crossdev' > /var/db/repos/crossdev/profiles/repo_name; \
chown -R portage:portage /var/db/repos/crossdev; \
mkdir -p /etc/portage/repos.conf; \
printf '[crossdev]\nlocation = /var/db/repos/crossdev\npriority = 10\nmasters = gentoo\nauto-sync = no\n' > /etc/portage/repos.conf/crossdev.conf; \
for target in ${CROSSDEV_TARGETS}; do \
crossdev --portage '--buildpkg --usepkg' --stable --target "${target}"; \
done; \
fi; \
emerge --oneshot gentoolkit; \
eclean packages; \
CLEAN_DELAY=0 emerge --depclean gentoolkit; \
find /var/cache/distfiles/ -mindepth 1 -delete -print; \
rm -rf /etc/portage/gnupg/
FROM distcc AS distcc-ccache
RUN --mount=type=bind,from=ksmanis/gentoo-distcc:tcp-ccache,source=/var/cache/binpkgs,target=/cache \
--mount=type=bind,from=ksmanis/portage,source=/var/db/repos/gentoo,target=/var/db/repos/gentoo \
set -eux; \
cp -av /cache/. /var/cache/binpkgs; \
getuto; \
export EMERGE_DEFAULT_OPTS="--buildpkg --color=y --getbinpkg --quiet-build --tree --verbose"; \
emerge --info; \
emerge ccache; \
ccache --version; \
emerge --oneshot gentoolkit; \
eclean packages; \
CLEAN_DELAY=0 emerge --depclean gentoolkit; \
find /var/cache/distfiles/ -mindepth 1 -delete -print; \
rm -rf /etc/portage/gnupg/
ARG CCACHE_DIR=/var/cache/ccache
ENV CCACHE_DIR="$CCACHE_DIR"
ENV PATH="/usr/lib/ccache/bin${PATH:+:$PATH}"
RUN set -eux; \
printf 'CCACHE_DIR="%s"\nPATH="/usr/lib/ccache/bin"\n' "$CCACHE_DIR" > /etc/env.d/02distcc-ccache; \
env-update; \
mkdir -p "${CCACHE_DIR}"; \
chmod 0775 "${CCACHE_DIR}"; \
chown distcc:distcc "${CCACHE_DIR}"
VOLUME ["$CCACHE_DIR"]
# hadolint ignore=DL3006
FROM $BASE AS distcc-tcp
ARG TARGETPLATFORM
# renovate: datasource=github-tags depName=krallin/tini
ARG TINI_VERSION=0.19.0
ARG TINI_GPGKEY=595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7
RUN set -eux; \
case "$TARGETPLATFORM" in \
"linux/386") TINI_ARCH="i386" ;; \
"linux/amd64") TINI_ARCH="amd64" ;; \
"linux/arm/v6" | "linux/arm/v7") TINI_ARCH="armhf" ;; \
"linux/arm64") TINI_ARCH="arm64" ;; \
"linux/ppc64le") TINI_ARCH="ppc64le" ;; \
*) echo "Error: Unsupported TARGETPLATFORM '$TARGETPLATFORM'" >&2; exit 1 ;; \
esac; \
curl -fL "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-${TINI_ARCH}" -o /usr/local/bin/tini; \
curl -fL "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-${TINI_ARCH}.asc" -o /usr/local/bin/tini.asc; \
curl -fL "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-${TINI_ARCH}.sha256sum" -o /usr/local/bin/tini.sha256sum; \
GNUPGHOME="$(mktemp -d)"; \
export GNUPGHOME; \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${TINI_GPGKEY}"; \
gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini; \
gpgconf --kill all; \
sed -i "s#tini-${TINI_ARCH}#/usr/local/bin/tini#" /usr/local/bin/tini.sha256sum; \
sha256sum --check --strict /usr/local/bin/tini.sha256sum; \
rm -rf "${GNUPGHOME}" /usr/local/bin/tini.asc /usr/local/bin/tini.sha256sum; \
chmod +x /usr/local/bin/tini; \
tini --version
COPY docker-entrypoint-tcp.sh /usr/local/bin/docker-entrypoint.sh
COPY healthcheck-tcp.sh /usr/local/bin/healthcheck.sh
# distccd exits with code 143 for SIGTERM; remap it to 0
ENTRYPOINT ["tini", "-e", "143", "--", "docker-entrypoint.sh"]
EXPOSE 3632
HEALTHCHECK CMD ["healthcheck.sh"]
USER distcc
# hadolint ignore=DL3006
FROM $BASE AS distcc-ssh
ENV SSH_USERNAME=distcc-ssh
COPY docker-entrypoint-ssh.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 22
HEALTHCHECK CMD </dev/tcp/localhost/22 || exit 1
# hadolint ignore=DL3006
FROM $BASE AS distcc-tcp-test
ARG TEST_USERNAME=notroot
RUN useradd -G distcc ${TEST_USERNAME}
WORKDIR /home/${TEST_USERNAME}/
USER ${TEST_USERNAME}
COPY --chown=${TEST_USERNAME} tests/test.c ./
COPY --chown=${TEST_USERNAME} tests/test.sh ./
ENV DISTCC_BACKOFF_PERIOD=0
ENV DISTCC_FALLBACK=0
ENV DISTCC_VERBOSE=1
CMD ["./test.sh"]
FROM distcc-tcp-test AS distcc-ssh-test
ARG TEST_USERNAME=notroot
COPY --chown=${TEST_USERNAME} --chmod=600 tests/ssh_config .ssh/config
COPY --chown=${TEST_USERNAME} --chmod=600 tests/ssh_ed25519_key .ssh/id_ed25519