|
| 1 | +# Upstream publishes quay.io/outline/shadowbox for amd64 only, although its |
| 2 | +# own Taskfile already knows how to target arm64. This rebuilds the same |
| 3 | +# release as a multi-arch image; the layout follows upstream's |
| 4 | +# src/shadowbox/Taskfile.yml `docker:build`. |
| 5 | +ARG VERSION=v1.12.3 |
| 6 | +ARG COMMIT=067d0d47aedac94a3888a127fa6c65f2f53b9987 |
| 7 | + |
| 8 | +FROM --platform=$BUILDPLATFORM node:18.18.0-alpine3.18@sha256:a315556d82ef54561e54fca7d8ee333382de183d4e56841dcefcd05b55310f46 AS source |
| 9 | +ARG VERSION |
| 10 | +ARG COMMIT |
| 11 | +RUN apk add --no-cache git |
| 12 | +RUN git clone --branch server-${VERSION} --depth 1 https://github.com/OutlineFoundation/outline-server /src \ |
| 13 | + && test "$(git -C /src rev-parse HEAD)" = "${COMMIT}" |
| 14 | + |
| 15 | +# main.js is a single webpack bundle with no native addons, so it is built |
| 16 | +# once on the build platform and shared by every target. |
| 17 | +FROM source AS app |
| 18 | +ARG VERSION |
| 19 | +WORKDIR /src |
| 20 | +RUN npm ci --ignore-scripts |
| 21 | +RUN SB_VERSION=${VERSION} npx webpack --config=src/shadowbox/webpack.config.js \ |
| 22 | + --output-path=/out/opt/outline-server/app --mode=production \ |
| 23 | + && cp src/shadowbox/package.json /out/opt/outline-server/ |
| 24 | + |
| 25 | +FROM --platform=$BUILDPLATFORM golang:1.27-alpine@sha256:8a5910f31396cd4d89662f56c68b3ae31d374308270a1c3bd96672ee5ed43414 AS ss-server |
| 26 | +ARG TARGETOS |
| 27 | +ARG TARGETARCH |
| 28 | +COPY --from=source /src /src |
| 29 | +WORKDIR /src |
| 30 | +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -trimpath \ |
| 31 | + -ldflags='-s -w -X main.version=embedded' \ |
| 32 | + -o /out/opt/outline-server/bin/ github.com/Jigsaw-Code/outline-ss-server/cmd/outline-ss-server |
| 33 | + |
| 34 | +# Version and checksums are upstream's, from third_party/Taskfile.yml. |
| 35 | +FROM --platform=$BUILDPLATFORM node:18.18.0-alpine3.18@sha256:a315556d82ef54561e54fca7d8ee333382de183d4e56841dcefcd05b55310f46 AS prometheus |
| 36 | +ARG TARGETARCH |
| 37 | +ARG PROMETHEUS_VERSION=2.37.1 |
| 38 | +RUN case "${TARGETARCH}" in \ |
| 39 | + amd64) sum=753f66437597cf52ada98c2f459aa8c03745475c249c9f2b40ac7b3919131ba6 ;; \ |
| 40 | + arm64) sum=b59a66fb5c7ec5acf6bf426793528a5789a1478a0dad8c64edc2843caf31b1b8 ;; \ |
| 41 | + *) echo "unsupported TARGETARCH ${TARGETARCH}" >&2; exit 1 ;; \ |
| 42 | + esac \ |
| 43 | + && name=prometheus-${PROMETHEUS_VERSION}.linux-${TARGETARCH} \ |
| 44 | + && wget -q -O /tmp/p.tgz https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/${name}.tar.gz \ |
| 45 | + && echo "${sum} /tmp/p.tgz" | sha256sum -c - \ |
| 46 | + && mkdir -p /out/opt/outline-server/bin \ |
| 47 | + && tar -xzf /tmp/p.tgz -C /out/opt/outline-server/bin --strip-components=1 ${name}/prometheus |
| 48 | + |
| 49 | +FROM node:18.18.0-alpine3.18@sha256:a315556d82ef54561e54fca7d8ee333382de183d4e56841dcefcd05b55310f46 |
| 50 | +ARG VERSION |
| 51 | +LABEL shadowbox.github.release=${VERSION} |
| 52 | +# The user management service doesn't quit with SIGTERM. |
| 53 | +STOPSIGNAL SIGKILL |
| 54 | +# curl detects the public IP; coreutils gives update_mmdb.sh a `date --date`. |
| 55 | +RUN apk add --no-cache --upgrade coreutils curl |
| 56 | +COPY --from=app /out / |
| 57 | +COPY --from=ss-server /out / |
| 58 | +COPY --from=prometheus /out / |
| 59 | +COPY --from=source /src/src/shadowbox/scripts /scripts |
| 60 | +COPY --from=source /src/src/shadowbox/scripts/update_mmdb.sh /etc/periodic/weekly/update_mmdb.sh |
| 61 | +COPY --from=source /src/src/shadowbox/docker/cmd.sh /cmd.sh |
| 62 | +RUN mkdir -p /root/shadowbox/persisted-state && /etc/periodic/weekly/update_mmdb.sh |
| 63 | +WORKDIR /opt/outline-server |
| 64 | +CMD ["/cmd.sh"] |
0 commit comments