-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.release
More file actions
42 lines (39 loc) · 2.03 KB
/
Copy pathDockerfile.release
File metadata and controls
42 lines (39 loc) · 2.03 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
# Sub2Port release image: pull a prebuilt static binary from GitHub Releases instead of
# compiling from source. Fast (no Go/Node toolchain, no mihomo recompile) and the
# runtime is byte-for-byte the same as the dev Dockerfile's final stage, so the
# container behaves identically either way.
#
# Select a version at build time (default: latest release):
# docker build -f Dockerfile.release --build-arg SUB2PORT_VERSION=v0.1.0 -t sub2port:release .
FROM alpine:3.20
# TARGETARCH is provided by BuildKit (amd64/arm64) and matches the release asset
# suffix. SUB2PORT_VERSION is a release tag, or "latest" for the newest release.
ARG TARGETARCH
ARG SUB2PORT_VERSION=latest
ARG REPO=MMortise/Sub2Port
# ca-certificates + tzdata + su-exec mirror the dev runtime; curl is installed as a
# throwaway just to fetch the binary, then removed so the image stays slim.
RUN apk add --no-cache ca-certificates tzdata su-exec \
&& adduser -D -u 10001 s2p \
&& mkdir -p /data && chown s2p:s2p /data \
&& apk add --no-cache --virtual .fetch curl \
&& arch="${TARGETARCH:-amd64}" \
&& if [ "$SUB2PORT_VERSION" = "latest" ]; then \
url="https://github.com/${REPO}/releases/latest/download/sub2port-linux-${arch}"; \
else \
url="https://github.com/${REPO}/releases/download/${SUB2PORT_VERSION}/sub2port-linux-${arch}"; \
fi \
&& echo "fetching ${url}" \
&& curl -fL --retry 3 -o /usr/local/bin/sub2port "$url" \
&& chmod +x /usr/local/bin/sub2port \
&& apk del .fetch
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
VOLUME /data
# Web UI (27000) + proxy mapping ports (27001-27020).
EXPOSE 27000 27001-27020
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://127.0.0.1:27000/api/health >/dev/null 2>&1 || exit 1
# Start as root only to chown the bind mount; the entrypoint su-exec's to s2p.
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["/usr/local/bin/sub2port", "-config", "/data/config.yaml"]