-
-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathDockerfile
More file actions
112 lines (94 loc) · 5.13 KB
/
Copy pathDockerfile
File metadata and controls
112 lines (94 loc) · 5.13 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
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
# syntax=docker/dockerfile:1
ARG PYTHON_VERSION=3.13
# ──────────────────────────────────────────────────────────────────────────────
# Build stage
#
# Bullseye's glibc 2.31 is what tags the wheels manylinux_2_31, so keep it.
# ──────────────────────────────────────────────────────────────────────────────
FROM python:${PYTHON_VERSION}-slim-bullseye AS builder
# Install the LLVM toolchain and build dependencies.
ARG LLVM_VERSION=20
RUN apt-get update -y -qq \
&& apt-get install -y -qq --no-install-recommends \
autoconf automake build-essential ca-certificates git gnupg libtool \
lsb-release software-properties-common wget \
&& wget -q https://apt.llvm.org/llvm.sh \
&& chmod +x llvm.sh \
&& ./llvm.sh ${LLVM_VERSION} \
&& apt-get install -y -qq --no-install-recommends \
libc++-${LLVM_VERSION}-dev libc++abi-${LLVM_VERSION}-dev clang-tools-${LLVM_VERSION} \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100 \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} 100 \
&& update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-${LLVM_VERSION} 100 \
&& update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-${LLVM_VERSION} 100 \
&& rm -rf /var/lib/apt/lists/* llvm.sh
# Set default compiler and target platform tag for Python wheels.
ENV CC=clang \
CXX=clang++ \
AUDITWHEEL_PLAT=manylinux_2_31_x86_64 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Define working directory for the source code.
WORKDIR /usr/src/endstone
# install C++ deps first so this layer caches across source-only changes
COPY .conanrc .conanrc
COPY .conan2/remotes.json .conan2/remotes.json
COPY .conan2/profiles/default .conan2/profiles/default
COPY conanfile.py conanfile.py
RUN python -m pip install --upgrade pip \
&& pip install conan cmake ninja \
&& conan install . --build=missing
# Copy the rest of the project files.
COPY . .
# Build, repair and test the project.
RUN --mount=type=secret,id=sentry-auth-token,env=SENTRY_AUTH_TOKEN \
pip install wheel setuptools pytest uv \
&& python -m pip wheel . --no-deps --wheel-dir=dist --verbose \
&& uv run --script scripts/repair_wheel.py -o endstone -p endstone -w wheelhouse dist/*.whl \
&& pip install wheelhouse/*-${AUDITWHEEL_PLAT}.whl \
&& pytest tests
# ──────────────────────────────────────────────────────────────────────────────
# Runtime stage
# ──────────────────────────────────────────────────────────────────────────────
FROM python:${PYTHON_VERSION}-slim-bookworm AS final
LABEL org.opencontainers.image.title="Endstone" \
org.opencontainers.image.description="A plugin API for Bedrock Dedicated Servers, supporting both Python and C++." \
org.opencontainers.image.source="https://github.com/EndstoneMC/endstone" \
org.opencontainers.image.documentation="https://endstone.dev" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.vendor="EndstoneMC" \
maintainer="Endstone <hello@endstone.dev>"
ENV PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PUID=1000 \
PGID=1000 \
TZ=UTC
# runtime deps and the unprivileged service user
# libcurl4 provides libcurl.so.4 for the Bedrock server binary
RUN apt-get update -y -qq \
&& apt-get install -y -qq --no-install-recommends gosu tzdata libcurl4 \
&& apt-get clean -y -qq \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid 1000 endstone \
&& useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash endstone \
&& mkdir -p /data \
&& chown endstone:endstone /data
# Install the repaired wheel built in the previous stage.
COPY --from=builder /usr/src/endstone/wheelhouse /tmp/wheelhouse
RUN pip install /tmp/wheelhouse/*.whl \
&& rm -rf /tmp/wheelhouse
# Install the container scripts outside /data so a bind mount cannot hide them.
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY docker/healthcheck.py /usr/local/bin/healthcheck.py
RUN chmod +x /usr/local/bin/entrypoint.sh
# /data holds the world, plugins and configuration — mount it to persist them.
WORKDIR /data
VOLUME ["/data"]
# Expose the Bedrock server ports (IPv4 and IPv6).
EXPOSE 19132/udp 19133/udp
# Report liveness by pinging the server over RakNet.
HEALTHCHECK --interval=30s --timeout=5s --start-period=120s --retries=5 \
CMD ["python", "/usr/local/bin/healthcheck.py"]
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["endstone", "--server-folder", "/data", "--yes"]