-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile.alpine-liberica
More file actions
85 lines (71 loc) · 2.97 KB
/
Dockerfile.alpine-liberica
File metadata and controls
85 lines (71 loc) · 2.97 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
# syntax=docker/dockerfile:1.7
# STAGE 1: Builder
FROM alpine:3.23 AS builder
RUN apk add --no-cache curl 7zip dos2unix
WORKDIR /build
# Download and extract Hytale Downloader
RUN curl -L -o hytale.zip https://downloader.hytale.com/hytale-downloader.zip && \
7z x hytale.zip -y -o./hytale -mmt=on && \
mv ./hytale/hytale-downloader-linux-amd64 ./hytale-downloader && \
chmod +x ./hytale-downloader && rm -rf hytale hytale.zip
# Prepare scripts
COPY scripts/ ./scripts/
COPY entrypoint.sh .
RUN find scripts -type f -name "*.sh" -exec dos2unix {} + && \
dos2unix entrypoint.sh && chmod -R +x scripts && chmod +x entrypoint.sh
# STAGE 2: Final Runtime
FROM bellsoft/liberica-openjre-alpine-musl:25.0.1-11
# Build arguments for customizable UID/GID
ARG UID=1000
ARG GID=1000
# Build arguments
ARG BUILDTIME=local
ARG VERSION=local
ARG REVISION=local
# OCI Metadata
LABEL org.opencontainers.image.title="Hytale Server" \
org.opencontainers.image.description="Hytale Docker server image with non-root execution, UDP optimization, and diagnostics." \
org.opencontainers.image.authors="deinfreu" \
org.opencontainers.image.url="https://github.com/deinfreu/hytale-server-container" \
org.opencontainers.image.source="https://github.com/deinfreu/hytale-server-container" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${REVISION}" \
org.opencontainers.image.created="${BUILDTIME}" \
org.opencontainers.image.licenses="Apache-2.0"
# Runtime configuration
ENV USER=container \
HOME=/home/container \
UID=1000 \
GID=1000 \
SCRIPTS_PATH="/usr/local/bin/scripts" \
SERVER_PORT=5520 \
SERVER_IP="" \
JAVA_ARGS="" \
PROD=FALSE \
DEBUG=FALSE
# Install dependencies
RUN apk add --no-cache tini su-exec curl iproute2 ca-certificates tzdata jq libc6-compat libstdc++ gcompat 7zip coreutils
# Setup User (with UID/GID conflict handling)
RUN if getent passwd ${UID} > /dev/null 2>&1; then \
EXISTING_USER=$(getent passwd ${UID} | cut -d: -f1); \
deluser ${EXISTING_USER} && \
addgroup -S -g ${GID} ${USER} && \
adduser -S -D -h ${HOME} -u ${UID} -G ${USER} ${USER}; \
else \
addgroup -S -g ${GID} ${USER} && \
adduser -S -D -h ${HOME} -u ${UID} -G ${USER} ${USER}; \
fi
# Copy artifacts from builder
COPY --from=builder --chown=root:root /build/hytale-downloader /usr/local/bin/hytale-downloader
COPY --from=builder --chown=${USER}:${USER} /build/scripts/ /usr/local/bin/scripts/
COPY --from=builder --chown=${USER}:${USER} /build/entrypoint.sh /entrypoint.sh
# Image metadata file
RUN printf "buildtime=%s\nversion=%s\nrevision=%s\n" "${BUILDTIME}" "${VERSION}" "${REVISION}" > /etc/image.properties
# Final setup
WORKDIR ${HOME}
USER ${USER}
EXPOSE ${SERVER_PORT}/udp
STOPSIGNAL SIGTERM
HEALTHCHECK --interval=30s --timeout=5s --start-period=2m --retries=3 CMD ss -ulpn | grep -q ":${SERVER_PORT}" || exit 1
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/bin/sh", "/entrypoint.sh"]