-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (64 loc) · 2.67 KB
/
Dockerfile
File metadata and controls
86 lines (64 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
# syntax=docker/dockerfile:1
ARG ALPINE_VERSION=3.22
ARG RUST_IMAGE=rustlang/rust:nightly-alpine3.22
FROM alpine:${ALPINE_VERSION} AS release-binary
ARG NODEGET_VERSION=latest
ARG NODEGET_RELEASE_REPO=GenshinMinecraft/NodeGet
ARG TARGETARCH
ARG TARGETVARIANT
RUN apk add --no-cache ca-certificates curl
RUN set -eux; \
docker_target="${TARGETARCH}${TARGETVARIANT}"; \
if [ -z "${docker_target}" ]; then \
docker_target="$(apk --print-arch)"; \
fi; \
case "${docker_target}" in \
amd64* | x86_64) asset="nodeget-server-linux-x86_64-musl" ;; \
arm64* | aarch64) asset="nodeget-server-linux-aarch64-musl" ;; \
armv7) asset="nodeget-server-linux-armv7-musleabihf" ;; \
*) \
echo "Unsupported Docker target: ${docker_target}. Supported: linux/amd64, linux/arm64, linux/arm/v7" >&2; \
exit 1; \
;; \
esac; \
if [ "${NODEGET_VERSION}" = "latest" ]; then \
release_path="latest/download"; \
else \
release_path="download/${NODEGET_VERSION}"; \
fi; \
mkdir -p /out; \
curl -fsSL --retry 5 --retry-delay 2 \
"https://github.com/${NODEGET_RELEASE_REPO}/releases/${release_path}/${asset}" \
-o /out/nodeget-server; \
chmod 0755 /out/nodeget-server
FROM ${RUST_IMAGE} AS source-binary
WORKDIR /src
RUN apk add --no-cache build-base clang clang-dev git musl-dev pkgconf
COPY . .
RUN cargo build --package nodeget-server --profile minimal --locked \
&& mkdir -p /out \
&& cp target/minimal/nodeget-server /out/nodeget-server \
&& chmod 0755 /out/nodeget-server
FROM alpine:${ALPINE_VERSION} AS runtime-base
LABEL org.opencontainers.image.title="NodeGet Server"
LABEL org.opencontainers.image.description="NodeGet server runtime image based on Alpine Linux"
LABEL org.opencontainers.image.source="https://github.com/GenshinMinecraft/NodeGet"
LABEL org.opencontainers.image.licenses="AGPL-3.0"
RUN apk add --no-cache ca-certificates tzdata \
&& update-ca-certificates \
&& mkdir -p /etc/nodeget /var/lib/nodeget
COPY docker/entrypoint.sh /usr/local/bin/nodeget-entrypoint
RUN chmod 0755 /usr/local/bin/nodeget-entrypoint
WORKDIR /etc/nodeget
ENV NODEGET_PORT="2211" \
NODEGET_LOG_FILTER="info" \
NODEGET_CONFIG_PATH="/etc/nodeget/config.toml" \
NODEGET_DATABASE_URL="sqlite:///var/lib/nodeget/nodeget.db?mode=rwc"
EXPOSE 2211
ENTRYPOINT ["/usr/local/bin/nodeget-entrypoint"]
CMD ["serve"]
FROM runtime-base AS runtime-release
COPY --from=release-binary /out/nodeget-server /usr/local/bin/nodeget-server
FROM runtime-base AS runtime-source
COPY --from=source-binary /out/nodeget-server /usr/local/bin/nodeget-server
FROM runtime-release AS runtime