This commit is contained in:
tooomm 2026-06-21 03:00:19 +08:00 committed by GitHub
commit 1d2345049b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 34 deletions

View file

@ -1,8 +1,9 @@
.git/ # Add (Ignore) everything in root for minimum image
build/ /*
.github/
.tx/ # Exclude (Allow) only folder & files required for building Servatrice
cockatrice/ !cmake/
doc/ !libcockatrice_*/
oracle/ !servatrice/
Dockerfile !CMakeLists.txt
!LICENSE

View file

@ -1,43 +1,54 @@
# -------- Build Stage -------- # -------- Build Stage --------
FROM ubuntu:26.04 AS build FROM debian:13-slim AS build
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \ # Install build dependencies
build-essential \ RUN apt-get update \
cmake \ && apt-get install -y --no-install-recommends \
file \ cmake \
g++ \ g++ \
git \ libmariadb-dev-compat \
libmariadb-dev-compat \ libprotobuf-dev \
libprotobuf-dev \ libqt6sql6-mysql \
libqt6sql6-mysql \ ninja-build \
qt6-websockets-dev \ protobuf-compiler \
protobuf-compiler \ qt6-tools-dev \
qt6-tools-dev \ qt6-tools-dev-tools \
qt6-tools-dev-tools qt6-websockets-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy repo source not excluded in .dockerignore
WORKDIR /src WORKDIR /src
COPY . . COPY . .
RUN mkdir build && cd build && \
cmake .. -DWITH_SERVER=1 -DWITH_CLIENT=0 -DWITH_ORACLE=0 && \ # Configure CMake
make -j$(nproc) && \ RUN cmake -S . -B build -G Ninja \
make install -DWITH_SERVER=1 -DWITH_CLIENT=0 -DWITH_ORACLE=0
# Build and install Servatrice
RUN cmake --build build --parallel $(nproc) \
&& cmake --install build
# -------- Runtime Stage (clean) -------- # -------- Runtime Stage (clean) --------
FROM ubuntu:26.04 FROM debian:13-slim
RUN apt-get update && apt-get install -y --no-install-recommends \ # Install runtime dependencies
libprotobuf32t64 \ # Is libprotobuf-lite32t64 enough?
libqt6sql6-mysql \ RUN apt-get update \
libqt6websockets6 \ && apt-get install -y --no-install-recommends \
&& apt-get clean \ libprotobuf32t64 \
libqt6sql6-mysql \
libqt6websockets6 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Only copy installed binaries, not source # Copy only resulting binaries from Build Stage
COPY --from=build /usr/local /usr/local COPY --from=build /usr/local/bin/servatrice /usr/local/bin/servatrice
# Create and run as non-root user
RUN useradd -m servatrice
USER servatrice
WORKDIR /home/servatrice WORKDIR /home/servatrice
EXPOSE 4748 EXPOSE 4748