From 6e812cb739664324ac1bbea11978940c4e1ad6e1 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 13:26:29 +0100 Subject: [PATCH 01/31] Add Docker support and CI workflow Introduces Dockerfile, .dockerignore, and compose.yaml for containerization and deployment. Adds a GitHub Actions workflow for automated Docker builds and pushes. Updates .gitignore to exclude build artifacts. --- .dockerignore | 43 +++++++++++++++++ .github/workflows/docker.yml | 79 ++++++++++++++++++++++++++++++ .gitignore | 3 ++ Dockerfile | 94 ++++++++++++++++++++++++++++++++++++ compose.yaml | 32 ++++++++++++ 5 files changed, 251 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile create mode 100644 compose.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..2e813a3d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,43 @@ +# Build artifacts +bin/ +build/ +cmake-build-*/ +*.orig + +# Git +.git/ +.gitignore +.gitattributes + +# IDE +.idea/ +.vs/ +*.user +*.suo +*.sln.docstates + +# Documentation +*.md +!README.md +docs/ + +# CI/CD +.github/ + +# Docker +Dockerfile +.dockerignore +compose.yaml +docker-compose*.yml + +# Scripts (not needed in image) +scripts/ + +# Tests +test/ + +# Other +*.toml +Resources/ +run-in-env.sh + diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..20297db4 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,79 @@ +name: Docker Build + +on: + push: + branches: + - 'develop' + - 'minor' + tags: + - 'v*' + pull_request: + +env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_FORCE_SYSTEM_BINARIES: 1 + CMAKE_BUILD_TYPE: "Release" + DEBIAN_FRONTEND: "noninteractive" + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: 'recursive' + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha,prefix={{branch}}- + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: ${{ matrix.platform }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + BUILDKIT_INLINE_CACHE=1 + + - name: Image digest + run: echo ${{ steps.meta.outputs.digest }} + diff --git a/.gitignore b/.gitignore index 4b06a998..7f6bc79c 100644 --- a/.gitignore +++ b/.gitignore @@ -478,3 +478,6 @@ callgrind.* notes/* compile_commands.json nohup.out + + +build/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..db016d37 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,94 @@ +# Build stage +FROM debian:12-slim AS builder + +# Build environment variables +ENV VCPKG_BINARY_SOURCES="clear;x-gha,readwrite" \ + VCPKG_FORCE_SYSTEM_BINARIES=1 \ + CMAKE_BUILD_TYPE=Release \ + DEBIAN_FRONTEND=noninteractive + +# Install build dependencies +RUN apt-get update -y && \ + apt-get install -y \ + liblua5.3-0 \ + liblua5.3-dev \ + curl \ + zip \ + unzip \ + tar \ + cmake \ + make \ + git \ + g++ \ + ninja-build \ + binutils \ + && rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /build + +# Copy source files +COPY .git .git +COPY vcpkg vcpkg + +# Initialize Git submodules (vcpkg, etc.) if needed +# If vcpkg doesn't exist, clone it directly +RUN git submodule update --init --recursive || true; \ + +# Copy source files +COPY . . + +# Bootstrap vcpkg +RUN ./vcpkg/bootstrap-vcpkg.sh + +# Configure CMake +RUN cmake . -B bin \ + -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" \ + -DBeamMP-Server_ENABLE_LTO=ON + +# Build server +RUN cmake --build bin --parallel -t BeamMP-Server + +# Extract debug information +RUN objcopy --only-keep-debug bin/BeamMP-Server bin/BeamMP-Server.debug && \ + objcopy --add-gnu-debuglink bin/BeamMP-Server bin/BeamMP-Server.debug + +# Strip binary +RUN strip -s bin/BeamMP-Server + +# Lightweight runtime stage +FROM debian:12-slim + +# Install runtime dependencies only +RUN apt-get update -y && \ + apt-get install -y \ + liblua5.3-0 \ + curl \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Create non-root user for security +RUN useradd -m -u 1000 beammp && \ + mkdir -p /app /config /resources && \ + chown -R beammp:beammp /app /config /resources + +# Copy binary from build stage +COPY --from=builder /build/bin/BeamMP-Server /app/BeamMP-Server + +# Set working directory +WORKDIR /app + +# Non-root user +USER beammp + +# Expose default port (can be overridden) +EXPOSE 30814 + +# Entry point +ENTRYPOINT ["/app/BeamMP-Server"] + +# Default arguments (can be overridden) +CMD ["--config=/config/ServerConfig.toml", "--working-directory=/app"] + diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..5b374fb8 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,32 @@ +version: '3.8' + +services: + beammp-server: + build: + context: . + dockerfile: Dockerfile + image: beammp-server:latest + container_name: beammp-server + restart: unless-stopped + ports: + - "30814:30814/tcp" + - "30814:30814/udp" + volumes: + # Mount configuration directory + - ./config:/config:ro + # Mount resources directory (mods, plugins, etc.) + - ./resources:/resources:ro + # Mount working directory for logs and data + - ./data:/app + environment: + - TZ=UTC + # Optional: limit resources + # deploy: + # resources: + # limits: + # cpus: '2' + # memory: 512M + # reservations: + # cpus: '0.5' + # memory: 128M + From 1e0fd1da68a13db26109a4a998c87f0bdbd53dd9 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 13:27:50 +0100 Subject: [PATCH 02/31] Add docker-support branch to workflow triggers The GitHub Actions workflow will now run on pushes to the docker-support branch, enabling CI/CD for Docker-related changes. --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 20297db4..934c4b9f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,6 +5,7 @@ on: branches: - 'develop' - 'minor' + - 'docker-support' tags: - 'v*' pull_request: From e42b41c736307c2ce07447ebb5496b26442bb5e6 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 14:21:53 +0100 Subject: [PATCH 03/31] Refactor Docker build and update CI caching Improves Dockerfile with multi-stage builds, BuildKit caching, and more granular dependency installation. Updates GitHub Actions workflow to use registry-based build cache. Refines .dockerignore and compose.yaml for better Docker context and volume management. Enhances CMake Git submodule logic to avoid errors outside git checkouts. --- .dockerignore | 41 +++------ .github/workflows/docker.yml | 8 +- Dockerfile | 158 ++++++++++++++++++----------------- cmake/Git.cmake | 41 ++++++--- compose.yaml | 8 +- 5 files changed, 133 insertions(+), 123 deletions(-) diff --git a/.dockerignore b/.dockerignore index 2e813a3d..9a8b0757 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,43 +1,26 @@ -# Build artifacts -bin/ +.git/ build/ cmake-build-*/ -*.orig - -# Git -.git/ -.gitignore -.gitattributes +bin/ +out/ +.cache/ +**/.DS_Store # IDE .idea/ .vs/ *.user *.suo -*.sln.docstates - -# Documentation -*.md -!README.md -docs/ -# CI/CD +# CI .github/ -# Docker -Dockerfile -.dockerignore -compose.yaml -docker-compose*.yml - -# Scripts (not needed in image) +# Scripts (pas nécessaires au build Docker ici) scripts/ -# Tests -test/ - -# Other -*.toml -Resources/ -run-in-env.sh +# Docs (garde README si tu veux) +*.md +!README.md +# Docker files (garde ce dont tu as besoin) +docker-compose*.yml \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 934c4b9f..c5a18949 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -70,8 +70,12 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: | + type=gha + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache + cache-to: | + type=gha,mode=max + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max build-args: | BUILDKIT_INLINE_CACHE=1 diff --git a/Dockerfile b/Dockerfile index db016d37..412f34ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,94 +1,100 @@ -# Build stage +# syntax=docker/dockerfile:1.6 + FROM debian:12-slim AS builder -# Build environment variables -ENV VCPKG_BINARY_SOURCES="clear;x-gha,readwrite" \ - VCPKG_FORCE_SYSTEM_BINARIES=1 \ - CMAKE_BUILD_TYPE=Release \ - DEBIAN_FRONTEND=noninteractive +ARG VCPKG_COMMIT=5bf0c55239da398b8c6f450818c9e28d36bf9966 +ARG BUILD_PARALLEL=2 +ARG ENABLE_LTO=ON -# Install build dependencies -RUN apt-get update -y && \ - apt-get install -y \ - liblua5.3-0 \ - liblua5.3-dev \ - curl \ - zip \ - unzip \ - tar \ - cmake \ - make \ - git \ - g++ \ - ninja-build \ - binutils \ +ENV DEBIAN_FRONTEND=noninteractive \ + CMAKE_BUILD_TYPE=Release \ + VCPKG_FORCE_SYSTEM_BINARIES=1 \ + VCPKG_FEATURE_FLAGS=manifests + +WORKDIR /work + +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + zip unzip tar \ + git \ + cmake \ + ninja-build \ + build-essential \ + pkg-config \ + liblua5.3-0 liblua5.3-dev \ + binutils \ && rm -rf /var/lib/apt/lists/* -# Set working directory -WORKDIR /build - -# Copy source files -COPY .git .git -COPY vcpkg vcpkg - -# Initialize Git submodules (vcpkg, etc.) if needed -# If vcpkg doesn't exist, clone it directly -RUN git submodule update --init --recursive || true; \ - -# Copy source files -COPY . . - -# Bootstrap vcpkg -RUN ./vcpkg/bootstrap-vcpkg.sh - -# Configure CMake -RUN cmake . -B bin \ - -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" \ - -DBeamMP-Server_ENABLE_LTO=ON - -# Build server -RUN cmake --build bin --parallel -t BeamMP-Server - -# Extract debug information -RUN objcopy --only-keep-debug bin/BeamMP-Server bin/BeamMP-Server.debug && \ - objcopy --add-gnu-debuglink bin/BeamMP-Server bin/BeamMP-Server.debug - -# Strip binary -RUN strip -s bin/BeamMP-Server - -# Lightweight runtime stage -FROM debian:12-slim - -# Install runtime dependencies only -RUN apt-get update -y && \ - apt-get install -y \ +# vcpkg doit être un vrai repo git (manifest/versioning) +RUN git clone https://github.com/microsoft/vcpkg /work/vcpkg && \ + cd /work/vcpkg && \ + git checkout ${VCPKG_COMMIT} && \ + ./bootstrap-vcpkg.sh -disableMetrics + +ENV VCPKG_ROOT=/work/vcpkg + +# Copie du projet (inclut les tests) +COPY vcpkg.json ./ +COPY deps/ ./deps/ +COPY cmake/ ./cmake/ +COPY CMakeLists.txt ./ +COPY include/ ./include/ +COPY src/ ./src/ +COPY test/ ./test/ + +# 1) Build serveur (LTO configurable) +RUN --mount=type=cache,target=/root/.cache/vcpkg,sharing=locked \ + --mount=type=cache,target=/work/vcpkg/downloads,sharing=locked \ + --mount=type=cache,target=/work/vcpkg/buildtrees,sharing=locked \ + --mount=type=cache,target=/work/vcpkg/packages,sharing=locked \ + --mount=type=cache,target=/work/build-server,sharing=locked \ + mkdir -p /work/out && \ + cmake -S /work -B /work/build-server -G Ninja \ + -DCMAKE_TOOLCHAIN_FILE=/work/vcpkg/scripts/buildsystems/vcpkg.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" \ + -DBeamMP-Server_ENABLE_LTO=${ENABLE_LTO} \ + && cmake --build /work/build-server --parallel ${BUILD_PARALLEL} -t BeamMP-Server \ + && objcopy --only-keep-debug /work/build-server/BeamMP-Server /work/build-server/BeamMP-Server.debug \ + && strip --strip-unneeded /work/build-server/BeamMP-Server \ + && objcopy --add-gnu-debuglink=/work/build-server/BeamMP-Server.debug /work/build-server/BeamMP-Server \ + && install -m 0755 /work/build-server/BeamMP-Server /work/out/BeamMP-Server + +# 2) Build tests (LTO OFF pour réduire la RAM) +RUN --mount=type=cache,target=/root/.cache/vcpkg,sharing=locked \ + --mount=type=cache,target=/work/vcpkg/downloads,sharing=locked \ + --mount=type=cache,target=/work/vcpkg/buildtrees,sharing=locked \ + --mount=type=cache,target=/work/vcpkg/packages,sharing=locked \ + --mount=type=cache,target=/work/build-tests,sharing=locked \ + cmake -S /work -B /work/build-tests -G Ninja \ + -DCMAKE_TOOLCHAIN_FILE=/work/vcpkg/scripts/buildsystems/vcpkg.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBeamMP-Server_ENABLE_LTO=OFF \ + && cmake --build /work/build-tests --parallel 1 -t BeamMP-Server-tests + +# Note: on copie l'artefact final dans /work/out pour qu'il soit présent dans les couches suivantes +# même si /work/build-server est un cache BuildKit. + +FROM debian:12-slim AS runtime + +RUN apt-get update && apt-get install -y --no-install-recommends \ liblua5.3-0 \ curl \ ca-certificates \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* -# Create non-root user for security RUN useradd -m -u 1000 beammp && \ - mkdir -p /app /config /resources && \ + mkdir -p /app /app/data /config /resources && \ chown -R beammp:beammp /app /config /resources -# Copy binary from build stage -COPY --from=builder /build/bin/BeamMP-Server /app/BeamMP-Server +COPY --from=builder /work/build-server/BeamMP-Server /app/BeamMP-Server -# Set working directory WORKDIR /app - -# Non-root user USER beammp -# Expose default port (can be overridden) EXPOSE 30814 - -# Entry point ENTRYPOINT ["/app/BeamMP-Server"] - -# Default arguments (can be overridden) -CMD ["--config=/config/ServerConfig.toml", "--working-directory=/app"] - +CMD ["--config=/config/ServerConfig.toml", "--working-directory=/app"] \ No newline at end of file diff --git a/cmake/Git.cmake b/cmake/Git.cmake index d88f5a04..aaf96769 100644 --- a/cmake/Git.cmake +++ b/cmake/Git.cmake @@ -1,21 +1,38 @@ -find_package(Git) +find_package(Git QUIET) + +# Only try to update submodules if: +# - the option is enabled +# - git is available +# - we are in a real git checkout (".git" exists) if(${PROJECT_NAME}_CHECKOUT_GIT_SUBMODULES) if(Git_FOUND) - message(STATUS "Git found, submodule update and init") - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE GIT_SUBMOD_RESULT) - if(NOT GIT_SUBMOD_RESULT EQUAL "0") - message(SEND_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules. This may result in missing dependencies.") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") + message(STATUS "Git found, submodule update and init") + execute_process( + COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE GIT_SUBMOD_RESULT + ) + if(NOT GIT_SUBMOD_RESULT EQUAL 0) + message(SEND_ERROR + "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules. " + "This may result in missing dependencies." + ) + endif() + else() + message(STATUS "No .git directory found - skipping submodule update (assume submodules are already present).") endif() else() - message(SEND_ERROR "git required for checking out submodules, but not found. Submodules will not be checked out - this may result in missing dependencies.") + message(SEND_ERROR + "git required for checking out submodules, but not found. Submodules will not be checked out - " + "this may result in missing dependencies." + ) endif() endif() -if(Git_FOUND) - +if(Git_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") + # If you compute PRJ_GIT_HASH somewhere else, keep that logic there. else() - message(STATUS "Git not found - the version will not include a git hash.") + message(STATUS "Git not found (or not a git checkout) - the version will not include a git hash.") set(PRJ_GIT_HASH "unknown") -endif() +endif() \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 5b374fb8..1f79ec4e 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,5 +1,3 @@ -version: '3.8' - services: beammp-server: build: @@ -13,13 +11,15 @@ services: - "30814:30814/udp" volumes: # Mount configuration directory - - ./config:/config:ro + - ./config:/config # Mount resources directory (mods, plugins, etc.) - ./resources:/resources:ro # Mount working directory for logs and data - - ./data:/app + - ./data:/app/data environment: - TZ=UTC + # Optionnel: renseigne ton AuthKey BeamMP ici pour démarrer automatiquement + # - BEAMMP_AUTHKEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # Optional: limit resources # deploy: # resources: From ea917f2647a729fefb95ebd9e05ee643e2c5ccf5 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 15:14:12 +0100 Subject: [PATCH 04/31] Set IMAGE_NAME dynamically in Docker workflow Moves IMAGE_NAME definition from env to a workflow step, setting it to the lowercased repository name using bash. This improves flexibility and ensures consistent image naming. --- .github/workflows/docker.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c5a18949..7ae23f4e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,7 +16,6 @@ env: CMAKE_BUILD_TYPE: "Release" DEBIAN_FRONTEND: "noninteractive" REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} jobs: build: @@ -30,6 +29,11 @@ jobs: - linux/amd64 - linux/arm64 steps: + - name: Set image name + id: image + shell: bash + run: | + echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" - name: Checkout repository uses: actions/checkout@v4 with: From 11971a53100741b744825a374d48e139e34b36ad Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 15:18:09 +0100 Subject: [PATCH 05/31] Update Docker workflow to set IMAGE_NAME in env Changed the Docker GitHub Actions workflow to set IMAGE_NAME using the @L parameter expansion and store it in GITHUB_ENV instead of GITHUB_OUTPUT. Also added a step to echo the IMAGE_NAME environment variable. --- .github/workflows/docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7ae23f4e..b92b6d11 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -33,7 +33,8 @@ jobs: id: image shell: bash run: | - echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" + echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}" + echo "IMAGE_NAME: ${{ env.IMAGE_NAME }}" - name: Checkout repository uses: actions/checkout@v4 with: From 129751d129339f03c7d2897d177f2fe4af9e6212 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 15:33:30 +0100 Subject: [PATCH 06/31] Update BeamMP-Server copy path in Dockerfile Changed the COPY source from /work/build-server/BeamMP-Server to /work/out/BeamMP-Server to reflect the new build artifact location. This ensures the final artifact is correctly copied during the Docker build process. --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 412f34ed..ce2707b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -90,7 +90,9 @@ RUN useradd -m -u 1000 beammp && \ mkdir -p /app /app/data /config /resources && \ chown -R beammp:beammp /app /config /resources -COPY --from=builder /work/build-server/BeamMP-Server /app/BeamMP-Server +# /work/build-server est un cache BuildKit (non persisté dans les layers), +# l'artefact final est copié dans /work/out pendant le build. +COPY --from=builder /work/out/BeamMP-Server /app/BeamMP-Server WORKDIR /app USER beammp From 1647e6b8016bf62c1204d9cf9ddd6fc001e6ca87 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 15:54:43 +0100 Subject: [PATCH 07/31] Split Docker build workflow by architecture Refactored the GitHub Actions workflow to separate Docker image builds for amd64 and arm64 architectures into distinct jobs. This improves build clarity and allows for targeted platform builds on appropriate runners. --- .github/workflows/docker.yml | 88 ++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 48 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b92b6d11..eaf6d70b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,79 +11,71 @@ on: pull_request: env: - VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" - VCPKG_FORCE_SYSTEM_BINARIES: 1 - CMAKE_BUILD_TYPE: "Release" - DEBIAN_FRONTEND: "noninteractive" REGISTRY: ghcr.io jobs: - build: + build-amd64: runs-on: ubuntu-latest permissions: contents: read packages: write - strategy: - matrix: - platform: - - linux/amd64 - - linux/arm64 steps: + - uses: actions/checkout@v4 + - name: Set image name - id: image - shell: bash - run: | - echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}" - echo "IMAGE_NAME: ${{ env.IMAGE_NAME }}" - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: 'recursive' - fetch-depth: 0 + run: echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - uses: docker/setup-buildx-action@v3 - - name: Log in to Container Registry + - uses: docker/login-action@v3 if: github.event_name != 'pull_request' - uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker + - uses: docker/metadata-action@v5 id: meta - uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha,prefix={{branch}}- - type=raw,value=latest,enable={{is_default_branch}} - - name: Build and push Docker image - uses: docker/build-push-action@v5 + - uses: docker/build-push-action@v5 with: context: . - file: ./Dockerfile - platforms: ${{ matrix.platform }} + platforms: linux/amd64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: | - type=gha - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache - cache-to: | - type=gha,mode=max - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max - build-args: | - BUILDKIT_INLINE_CACHE=1 - - name: Image digest - run: echo ${{ steps.meta.outputs.digest }} + build-arm64: + runs-on: ubuntu-24.04-arm + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - name: Set image name + run: echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV + + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + if: github.event_name != 'pull_request' + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From f06543d1c9e15c18efbe73505bdb8e3b5c72d476 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 16:03:44 +0100 Subject: [PATCH 08/31] Refactor Docker workflow to use matrix build Consolidated separate amd64 and arm64 jobs into a single matrix-based 'build' job for multi-architecture Docker image builds. This simplifies the workflow, reduces duplication, and ensures both architectures are built consistently. Also added recursive submodule checkout and standardized registry/image references. --- .github/workflows/docker.yml | 55 ++++++++++++------------------------ 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index eaf6d70b..973c051a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,46 +14,27 @@ env: REGISTRY: ghcr.io jobs: - build-amd64: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v4 - - - name: Set image name - run: echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV - - - uses: docker/setup-buildx-action@v3 - - - uses: docker/login-action@v3 - if: github.event_name != 'pull_request' - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + build: + strategy: + matrix: + include: + - arch: amd64 + platform: linux/amd64 + runner: ubuntu-latest + - arch: arm64 + platform: linux/arm64 + runner: ubuntu-24.04-arm + + runs-on: ${{ matrix.runner }} - build-arm64: - runs-on: ubuntu-24.04-arm permissions: contents: read packages: write + steps: - uses: actions/checkout@v4 + with: + submodules: recursive - name: Set image name run: echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV @@ -63,19 +44,19 @@ jobs: - uses: docker/login-action@v3 if: github.event_name != 'pull_request' with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/metadata-action@v5 id: meta with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ghcr.io/${{ env.IMAGE_NAME }} - uses: docker/build-push-action@v5 with: context: . - platforms: linux/arm64 + platforms: ${{ matrix.platform }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From fccea15d4768556401dfbef190460236d0b31dc1 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 16:26:09 +0100 Subject: [PATCH 09/31] Update docker/build-push-action to v6 in workflow Bump the docker/build-push-action version from v5 to v6 in the GitHub Actions workflow to use the latest features and improvements. --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 973c051a..824323f6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -53,7 +53,7 @@ jobs: with: images: ghcr.io/${{ env.IMAGE_NAME }} - - uses: docker/build-push-action@v5 + - uses: docker/build-push-action@v6 with: context: . platforms: ${{ matrix.platform }} From 6fa4a5e6cd23c1b8e0a4ab3b6632b6bb787890de Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 16:47:42 +0100 Subject: [PATCH 10/31] Add Docker build cache configuration to workflow Configured the GitHub Actions Docker workflow to use registry-based build cache with cache-from and cache-to options. This should improve build times by leveraging cached layers across builds. --- .github/workflows/docker.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 824323f6..9de80112 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -59,4 +59,6 @@ jobs: platforms: ${{ matrix.platform }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }} + cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }},mode=max \ No newline at end of file From d182a9b454f2ab9b3f68fb9d6ffedfaafee2e533 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 16:48:48 +0100 Subject: [PATCH 11/31] Disable provenance and SBOM in Docker build Added 'provenance: false' and 'sbom: false' to the Docker build step in the GitHub Actions workflow to prevent generation of provenance and SBOM artifacts. --- .github/workflows/docker.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9de80112..a506b309 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -61,4 +61,6 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }} - cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }},mode=max \ No newline at end of file + cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }},mode=max + provenance: false + sbom: false \ No newline at end of file From a566097d495dcf1ed1c9733773cca62f6ffc44cc Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 18:03:45 +0100 Subject: [PATCH 12/31] Clean up Dockerfile comments and update copy note Removed outdated and redundant comments, including French notes, from the Dockerfile. Updated the artifact copy comment to clarify the use of BuildKit cache and artifact location. --- Dockerfile | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index ce2707b3..e3a04f87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,3 @@ -# syntax=docker/dockerfile:1.6 - FROM debian:12-slim AS builder ARG VCPKG_COMMIT=5bf0c55239da398b8c6f450818c9e28d36bf9966 @@ -28,7 +26,6 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ binutils \ && rm -rf /var/lib/apt/lists/* -# vcpkg doit être un vrai repo git (manifest/versioning) RUN git clone https://github.com/microsoft/vcpkg /work/vcpkg && \ cd /work/vcpkg && \ git checkout ${VCPKG_COMMIT} && \ @@ -36,7 +33,6 @@ RUN git clone https://github.com/microsoft/vcpkg /work/vcpkg && \ ENV VCPKG_ROOT=/work/vcpkg -# Copie du projet (inclut les tests) COPY vcpkg.json ./ COPY deps/ ./deps/ COPY cmake/ ./cmake/ @@ -45,7 +41,6 @@ COPY include/ ./include/ COPY src/ ./src/ COPY test/ ./test/ -# 1) Build serveur (LTO configurable) RUN --mount=type=cache,target=/root/.cache/vcpkg,sharing=locked \ --mount=type=cache,target=/work/vcpkg/downloads,sharing=locked \ --mount=type=cache,target=/work/vcpkg/buildtrees,sharing=locked \ @@ -63,7 +58,6 @@ RUN --mount=type=cache,target=/root/.cache/vcpkg,sharing=locked \ && objcopy --add-gnu-debuglink=/work/build-server/BeamMP-Server.debug /work/build-server/BeamMP-Server \ && install -m 0755 /work/build-server/BeamMP-Server /work/out/BeamMP-Server -# 2) Build tests (LTO OFF pour réduire la RAM) RUN --mount=type=cache,target=/root/.cache/vcpkg,sharing=locked \ --mount=type=cache,target=/work/vcpkg/downloads,sharing=locked \ --mount=type=cache,target=/work/vcpkg/buildtrees,sharing=locked \ @@ -75,9 +69,6 @@ RUN --mount=type=cache,target=/root/.cache/vcpkg,sharing=locked \ -DBeamMP-Server_ENABLE_LTO=OFF \ && cmake --build /work/build-tests --parallel 1 -t BeamMP-Server-tests -# Note: on copie l'artefact final dans /work/out pour qu'il soit présent dans les couches suivantes -# même si /work/build-server est un cache BuildKit. - FROM debian:12-slim AS runtime RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -90,8 +81,7 @@ RUN useradd -m -u 1000 beammp && \ mkdir -p /app /app/data /config /resources && \ chown -R beammp:beammp /app /config /resources -# /work/build-server est un cache BuildKit (non persisté dans les layers), -# l'artefact final est copié dans /work/out pendant le build. +# /work/build-server is a BuildKit cache mount (not persisted in layers), so copy from /work/out. COPY --from=builder /work/out/BeamMP-Server /app/BeamMP-Server WORKDIR /app From 44431bc7fec8c7e80b5aa2a24cddc16a46a56570 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 18:04:13 +0100 Subject: [PATCH 13/31] Update BeamMP server image in compose.yaml Changed the Docker image reference from 'beammp-server:latest' to 'ghcr.io/BeamMP/beammp-server' to use the official image from GitHub Container Registry. --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 1f79ec4e..086d66db 100644 --- a/compose.yaml +++ b/compose.yaml @@ -3,7 +3,7 @@ services: build: context: . dockerfile: Dockerfile - image: beammp-server:latest + image: ghcr.io/BeamMP/beammp-server container_name: beammp-server restart: unless-stopped ports: From dc4670b14787d1316a20f5d4d0e855e541e1fc99 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 18:05:29 +0100 Subject: [PATCH 14/31] Remove commented configuration from compose.yaml Cleaned up the Docker Compose file by removing unused and commented-out environment variables and resource limits for improved readability. --- compose.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/compose.yaml b/compose.yaml index 086d66db..d44bbe22 100644 --- a/compose.yaml +++ b/compose.yaml @@ -18,15 +18,4 @@ services: - ./data:/app/data environment: - TZ=UTC - # Optionnel: renseigne ton AuthKey BeamMP ici pour démarrer automatiquement - # - BEAMMP_AUTHKEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - # Optional: limit resources - # deploy: - # resources: - # limits: - # cpus: '2' - # memory: 512M - # reservations: - # cpus: '0.5' - # memory: 128M From c9aaee55e5712ef0a9e40407650bbc1c5eb07a08 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 18:06:05 +0100 Subject: [PATCH 15/31] Remove 'docker-support' branch from workflow triggers The GitHub Actions workflow will no longer run for pushes to the 'docker-support' branch. This streamlines workflow execution to only relevant branches and tags. --- .github/workflows/docker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a506b309..c056e729 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,7 +5,6 @@ on: branches: - 'develop' - 'minor' - - 'docker-support' tags: - 'v*' pull_request: From 554ee51579acfa276590de3e8ddfb9cd0e4fc740 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 18:35:57 +0100 Subject: [PATCH 16/31] Fix image name casing in Docker Compose file Updated the image name in compose.yaml from 'BeamMP' to 'beammp' to ensure consistency and avoid potential issues with case sensitivity in Docker image references. --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index d44bbe22..8a1feed1 100644 --- a/compose.yaml +++ b/compose.yaml @@ -3,7 +3,7 @@ services: build: context: . dockerfile: Dockerfile - image: ghcr.io/BeamMP/beammp-server + image: ghcr.io/beammp/beammp-server container_name: beammp-server restart: unless-stopped ports: From 593d05abcebf8429d2f51fd10e92db167fca41cd Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 19:22:55 +0100 Subject: [PATCH 17/31] Update Docker CMD and resource volume paths Removed the --working-directory flag from the Dockerfile CMD. Updated compose.yaml to mount resources to /app/Resources instead of /resources and removed the data volume mount. --- Dockerfile | 2 +- compose.yaml | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e3a04f87..56f0d905 100644 --- a/Dockerfile +++ b/Dockerfile @@ -89,4 +89,4 @@ USER beammp EXPOSE 30814 ENTRYPOINT ["/app/BeamMP-Server"] -CMD ["--config=/config/ServerConfig.toml", "--working-directory=/app"] \ No newline at end of file +CMD ["--config=/config/ServerConfig.toml"] \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 8a1feed1..98be412e 100644 --- a/compose.yaml +++ b/compose.yaml @@ -13,9 +13,7 @@ services: # Mount configuration directory - ./config:/config # Mount resources directory (mods, plugins, etc.) - - ./resources:/resources:ro - # Mount working directory for logs and data - - ./data:/app/data + - ./Resources:/app/Resources environment: - TZ=UTC From 9c5fbd120df61ee719ddde55bde593490f561a26 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 11 Jan 2026 19:24:25 +0100 Subject: [PATCH 18/31] Add .env example and update Docker config Added a .env.example file to document environment variables. Updated .gitignore to exclude .env and build/ directories. Modified compose.yaml to use the .env file for environment variables. --- .env.example | 12 ++++++++++++ .gitignore | 4 +++- compose.yaml | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..ce7291fb --- /dev/null +++ b/.env.example @@ -0,0 +1,12 @@ +BEAMMP_DEBUG= +BEAMMP_PRIVATE= +BEAMMP_PORT= +BEAMMP_MAX_CARS= +BEAMMP_MAX_PLAYERS= +BEAMMP_MAP= +BEAMMP_NAME= +BEAMMP_DESCRIPTION= +BEAMMP_TAGS= +BEAMMP_RESOURCE_FOLDER= +BEAMMP_AUTH_KEY= +BEAMMP_LOG_CHAT= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7f6bc79c..ed5ec8df 100644 --- a/.gitignore +++ b/.gitignore @@ -479,5 +479,7 @@ notes/* compile_commands.json nohup.out +build/ -build/ \ No newline at end of file +#Ignore Docker env file +.env \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 98be412e..6e515c7b 100644 --- a/compose.yaml +++ b/compose.yaml @@ -14,6 +14,8 @@ services: - ./config:/config # Mount resources directory (mods, plugins, etc.) - ./Resources:/app/Resources + env_file: + - .env environment: - TZ=UTC From eb87c3db622d02a467de2aec261de86b274024f8 Mon Sep 17 00:00:00 2001 From: Fournet Enzo <63660254+enzofrnt@users.noreply.github.com> Date: Sun, 11 Jan 2026 22:38:13 +0100 Subject: [PATCH 19/31] Improve docker workflow (#1) * Update docker.yml * Create docker-test.yml * Update Docker workflow authentication to GitHub Container Registry Changed Docker login in docker-test.yml to use GitHub Container Registry credentials instead of Docker Hub. Removed unused REGISTRY environment variable from docker.yml for consistency. * Update docker-test.yml * Update docker.yml * Update docker.yml * Refactor Docker workflow for native multi-arch builds Removed the separate docker-test workflow and consolidated multi-architecture Docker image building into a single, improved workflow. The new workflow uses matrix builds for amd64 and arm64, explicit runners, and streamlined manifest creation, improving maintainability and native support for multi-arch images. * Update Docker workflow name and trigger branches Renames the workflow to 'Docker Build and Publish (native multi-arch)' and removes the 'improve-docker-workflow' branch from the push trigger. * Add pull_request trigger to Docker workflow The GitHub Actions workflow for Docker now runs on pull requests in addition to pushes to main, minor branches, and tags. This ensures Docker-related checks are performed for incoming pull requests. * Update docker.yml * Update docker.yml --- .github/workflows/docker.yml | 87 +++++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 12 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c056e729..e830304b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,4 @@ -name: Docker Build +name: Docker Build and Publish (native multi-arch) on: push: @@ -14,18 +14,19 @@ env: jobs: build: + name: Build ${{ matrix.arch }} + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: include: - arch: amd64 platform: linux/amd64 - runner: ubuntu-latest + runner: ubuntu-24.04 - arch: arm64 platform: linux/arm64 runner: ubuntu-24.04-arm - runs-on: ${{ matrix.runner }} - permissions: contents: read packages: write @@ -35,31 +36,93 @@ jobs: with: submodules: recursive - - name: Set image name + - name: Set image name (lowercase) run: echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 - if: github.event_name != 'pull_request' with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/metadata-action@v5 id: meta with: - images: ghcr.io/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + suffix=-${{ matrix.arch }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} - uses: docker/build-push-action@v6 with: context: . platforms: ${{ matrix.platform }} - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }} - cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }},mode=max + + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }} + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }},mode=max + provenance: false - sbom: false \ No newline at end of file + sbom: false + + merge: + runs-on: ubuntu-24.04 + needs: [build] + permissions: + contents: read + packages: write + + steps: + - name: Set image name (lowercase) + run: echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV + + - uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Create multi-arch manifests + env: + TAGS: ${{ steps.meta.outputs.tags }} + run: | + set -euo pipefail + + while IFS= read -r tag; do + [ -n "$tag" ] || continue + + echo "Merging: $tag" + docker buildx imagetools create \ + -t "$tag" \ + "${tag}-amd64" \ + "${tag}-arm64" + done <<< "$TAGS" + + - name: Inspect + run: | + # Affiche les détails de l'image créée pour vérification + # On utilise le premier tag de la liste pour l'inspection + TAG_TO_INSPECT=$(echo "${{ steps.meta.outputs.tags }}" | head -n 1) + docker buildx imagetools inspect $TAG_TO_INSPECT || true \ No newline at end of file From c957523fa899c65ea3a8110e3a01481f3d0ef892 Mon Sep 17 00:00:00 2001 From: Fournet Enzo <63660254+enzofrnt@users.noreply.github.com> Date: Mon, 12 Jan 2026 11:36:18 +0100 Subject: [PATCH 20/31] docker: add Lua + LuaRocks support (#2) * docker: add LuaRocks support Install lua5.3/luarocks (+ build deps) in runtime image; mount /resources RW in compose example for plugin rock installs. * Update docker.yml * Update docker.yml * Update docker.yml * Add --export-dynamic linker flag to CMake builds Updated the Dockerfile to include the -Wl,--export-dynamic linker flag in both server and test CMake build steps. This ensures that dynamic symbols are exported, which may be required for certain runtime features or debugging. --- .github/workflows/docker.yml | 1 + Dockerfile | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e830304b..c28bb771 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,6 +3,7 @@ name: Docker Build and Publish (native multi-arch) on: push: branches: + - 'docker-suppor-lua-rocks' - 'develop' - 'minor' tags: diff --git a/Dockerfile b/Dockerfile index 56f0d905..83b1fca1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,7 @@ RUN --mount=type=cache,target=/root/.cache/vcpkg,sharing=locked \ cmake -S /work -B /work/build-server -G Ninja \ -DCMAKE_TOOLCHAIN_FILE=/work/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_EXE_LINKER_FLAGS="-Wl,--export-dynamic" \ -DCMAKE_CXX_FLAGS="-O3 -g -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,-z,noseparate-code -ffunction-sections -fdata-sections -Wl,--gc-sections" \ -DBeamMP-Server_ENABLE_LTO=${ENABLE_LTO} \ && cmake --build /work/build-server --parallel ${BUILD_PARALLEL} -t BeamMP-Server \ @@ -66,6 +67,7 @@ RUN --mount=type=cache,target=/root/.cache/vcpkg,sharing=locked \ cmake -S /work -B /work/build-tests -G Ninja \ -DCMAKE_TOOLCHAIN_FILE=/work/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_EXE_LINKER_FLAGS="-Wl,--export-dynamic" \ -DBeamMP-Server_ENABLE_LTO=OFF \ && cmake --build /work/build-tests --parallel 1 -t BeamMP-Server-tests @@ -73,6 +75,13 @@ FROM debian:12-slim AS runtime RUN apt-get update && apt-get install -y --no-install-recommends \ liblua5.3-0 \ + lua5.3 \ + luarocks \ + build-essential \ + pkg-config \ + liblua5.3-dev \ + git \ + unzip \ curl \ ca-certificates \ && rm -rf /var/lib/apt/lists/* From 3572255b70534b77b092b354081ef208bdf1348d Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Mon, 12 Jan 2026 11:39:43 +0100 Subject: [PATCH 21/31] Remove obsolete branch from Docker workflow The 'docker-suppor-lua-rocks' branch was removed from the workflow trigger list, likely because it is no longer in use or relevant for Docker build and publish actions. --- .github/workflows/docker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c28bb771..e830304b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,6 @@ name: Docker Build and Publish (native multi-arch) on: push: branches: - - 'docker-suppor-lua-rocks' - 'develop' - 'minor' tags: From 4edcbc039b8b2ff7ba4e7f9142108988ffe0f3cf Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Mon, 12 Jan 2026 12:59:35 +0100 Subject: [PATCH 22/31] Update .env.example with default BeamMP values Set default values for BeamMP environment variables in .env.example to provide clearer configuration guidance for new users. --- .env.example | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index ce7291fb..55c5b3d4 100644 --- a/.env.example +++ b/.env.example @@ -1,12 +1,12 @@ -BEAMMP_DEBUG= -BEAMMP_PRIVATE= -BEAMMP_PORT= -BEAMMP_MAX_CARS= -BEAMMP_MAX_PLAYERS= -BEAMMP_MAP= -BEAMMP_NAME= -BEAMMP_DESCRIPTION= +BEAMMP_DEBUG=false +BEAMMP_PRIVATE=true +BEAMMP_PORT=30814 +BEAMMP_MAX_CARS=1 +BEAMMP_MAX_PLAYERS=8 +BEAMMP_MAP=/levels/gridmap_v2/info.json +BEAMMP_NAME=BeamMP Server +BEAMMP_DESCRIPTION="BeamMP Default Description" BEAMMP_TAGS= -BEAMMP_RESOURCE_FOLDER= +BEAMMP_RESOURCE_FOLDER=Resources BEAMMP_AUTH_KEY= -BEAMMP_LOG_CHAT= \ No newline at end of file +BEAMMP_LOG_CHAT=true \ No newline at end of file From e7ab5800f5e61555b05f8b5551b5b0ff674811e3 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Mon, 12 Jan 2026 13:00:18 +0100 Subject: [PATCH 23/31] Use BEAMMP_PORT env variable for port mapping Replaced hardcoded port values with the BEAMMP_PORT environment variable in the Docker Compose file to allow configurable port mapping for the beammp-server service. --- compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 6e515c7b..a72d4949 100644 --- a/compose.yaml +++ b/compose.yaml @@ -7,8 +7,8 @@ services: container_name: beammp-server restart: unless-stopped ports: - - "30814:30814/tcp" - - "30814:30814/udp" + - "${BEAMMP_PORT}:${BEAMMP_PORT}/tcp" + - "${BEAMMP_PORT}:${BEAMMP_PORT}/udp" volumes: # Mount configuration directory - ./config:/config From 719cfaf97fbb2ae1c355b2f2082495651dc4c491 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Sun, 8 Mar 2026 13:52:55 +0100 Subject: [PATCH 24/31] Tidy Docker files, workflow comments, and ignores Minor cleanup across Docker-related files and CI workflow for clarity and consistency: - .dockerignore: simplified comments and ensured docs/ scripts entries are listed (keeps README.md). - .github/workflows/docker.yml: translated French comments to English for the Inspect step. - .gitignore: fixed spacing in Docker env file comment. - Dockerfile: removed an outdated comment line (no functional change to the COPY/WORKDIR steps). These are non-functional cleanup changes to improve readability and consistency. --- .dockerignore | 6 +++--- .github/workflows/docker.yml | 4 ++-- .gitignore | 2 +- Dockerfile | 1 - 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index 9a8b0757..0ddf0317 100644 --- a/.dockerignore +++ b/.dockerignore @@ -15,12 +15,12 @@ out/ # CI .github/ -# Scripts (pas nécessaires au build Docker ici) +# Scripts scripts/ -# Docs (garde README si tu veux) +# Docs *.md !README.md -# Docker files (garde ce dont tu as besoin) +# Docker files docker-compose*.yml \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e830304b..bdb6dd2c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -122,7 +122,7 @@ jobs: - name: Inspect run: | - # Affiche les détails de l'image créée pour vérification - # On utilise le premier tag de la liste pour l'inspection + # Display the created image details for verification + # Use the first tag from the list for inspection TAG_TO_INSPECT=$(echo "${{ steps.meta.outputs.tags }}" | head -n 1) docker buildx imagetools inspect $TAG_TO_INSPECT || true \ No newline at end of file diff --git a/.gitignore b/.gitignore index ed5ec8df..31ecbcbe 100644 --- a/.gitignore +++ b/.gitignore @@ -481,5 +481,5 @@ nohup.out build/ -#Ignore Docker env file +# Ignore Docker env file .env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 83b1fca1..e2dcef60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -90,7 +90,6 @@ RUN useradd -m -u 1000 beammp && \ mkdir -p /app /app/data /config /resources && \ chown -R beammp:beammp /app /config /resources -# /work/build-server is a BuildKit cache mount (not persisted in layers), so copy from /work/out. COPY --from=builder /work/out/BeamMP-Server /app/BeamMP-Server WORKDIR /app From e9a549d2641e9407d28d75d8c0d1e2ced4b13ad6 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Mon, 9 Mar 2026 19:04:03 +0100 Subject: [PATCH 25/31] Add provider disable flag and remove config mount Update .env.example to include BEAMMP_PROVIDER_DISABLE_CONFIG so the provider config can be disabled via env. Simplify compose.yaml by removing the ./config volume mount and the explicit TZ environment entry while keeping the Resources volume and .env file reference. --- .env.example | 3 ++- compose.yaml | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 55c5b3d4..e015e316 100644 --- a/.env.example +++ b/.env.example @@ -9,4 +9,5 @@ BEAMMP_DESCRIPTION="BeamMP Default Description" BEAMMP_TAGS= BEAMMP_RESOURCE_FOLDER=Resources BEAMMP_AUTH_KEY= -BEAMMP_LOG_CHAT=true \ No newline at end of file +BEAMMP_LOG_CHAT=true +BEAMMP_PROVIDER_DISABLE_CONFIG=true \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index a72d4949..e31a8140 100644 --- a/compose.yaml +++ b/compose.yaml @@ -10,12 +10,8 @@ services: - "${BEAMMP_PORT}:${BEAMMP_PORT}/tcp" - "${BEAMMP_PORT}:${BEAMMP_PORT}/udp" volumes: - # Mount configuration directory - - ./config:/config # Mount resources directory (mods, plugins, etc.) - ./Resources:/app/Resources env_file: - .env - environment: - - TZ=UTC From 9066648d9a2a9b499749ed3e351ba3a4715336c5 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Wed, 18 Mar 2026 08:00:32 +0100 Subject: [PATCH 26/31] Remove Resources volume mount from compose.yaml Remove the bind mount that mounted ./Resources into /app/Resources in compose.yaml. This stops the host Resources directory from being injected into the container (avoiding accidental overrides, permission/sync issues). Ports and env_file entries are unchanged; if runtime resources are still required, consider baking them into the image or adding a controlled volume. --- compose.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/compose.yaml b/compose.yaml index e31a8140..abdf8370 100644 --- a/compose.yaml +++ b/compose.yaml @@ -9,9 +9,6 @@ services: ports: - "${BEAMMP_PORT}:${BEAMMP_PORT}/tcp" - "${BEAMMP_PORT}:${BEAMMP_PORT}/udp" - volumes: - # Mount resources directory (mods, plugins, etc.) - - ./Resources:/app/Resources env_file: - .env From c117b1b763a42e6b5e4a641ef31b7d6729c5f76b Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Wed, 18 Mar 2026 08:01:42 +0100 Subject: [PATCH 27/31] Document BeamMP Server env link in .env.example Add a top-line comment to .env.example that points to the official BeamMP Server environment variable documentation (https://docs.beammp.com/server/manual/#env). This helps users locate authoritative guidance for configuring environment variables. --- .env.example | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.example b/.env.example index e015e316..039bab85 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ +# Official environment variables for BeamMP Server: https://docs.beammp.com/server/manual/#env BEAMMP_DEBUG=false BEAMMP_PRIVATE=true BEAMMP_PORT=30814 From fe93f0798270916b254bfa36e91140509af8e1f5 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Wed, 18 Mar 2026 08:02:55 +0100 Subject: [PATCH 28/31] Set BEAMMP_PROVIDER_DISABLE_CONFIG in compose Remove BEAMMP_PROVIDER_DISABLE_CONFIG from .env.example and add it to the service environment in compose.yaml so the container receives the variable explicitly. .env.example retains BEAMMP_LOG_CHAT=true. This ensures the provider disable flag is injected at runtime via Docker Compose rather than left in the example env file. --- .env.example | 3 +-- compose.yaml | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 039bab85..269cbd50 100644 --- a/.env.example +++ b/.env.example @@ -10,5 +10,4 @@ BEAMMP_DESCRIPTION="BeamMP Default Description" BEAMMP_TAGS= BEAMMP_RESOURCE_FOLDER=Resources BEAMMP_AUTH_KEY= -BEAMMP_LOG_CHAT=true -BEAMMP_PROVIDER_DISABLE_CONFIG=true \ No newline at end of file +BEAMMP_LOG_CHAT=true \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index abdf8370..88a8cd26 100644 --- a/compose.yaml +++ b/compose.yaml @@ -11,4 +11,6 @@ services: - "${BEAMMP_PORT}:${BEAMMP_PORT}/udp" env_file: - .env + environment: + - BEAMMP_PROVIDER_DISABLE_CONFIG=true From 8fafe13d07920b1793f38d1cb52982271752d275 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Wed, 18 Mar 2026 08:03:55 +0100 Subject: [PATCH 29/31] Remove default CMD from Dockerfile Drop the fixed CMD ("--config=/config/ServerConfig.toml") from the Dockerfile, leaving only the ENTRYPOINT. This allows callers to pass runtime arguments or override the command without being forced to use the baked-in config flag. --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e2dcef60..c0ef1983 100644 --- a/Dockerfile +++ b/Dockerfile @@ -96,5 +96,4 @@ WORKDIR /app USER beammp EXPOSE 30814 -ENTRYPOINT ["/app/BeamMP-Server"] -CMD ["--config=/config/ServerConfig.toml"] \ No newline at end of file +ENTRYPOINT ["/app/BeamMP-Server"] \ No newline at end of file From 27cf7bfaf7584ffdbc0eaf42a59789cd3bc20da4 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Wed, 18 Mar 2026 08:04:50 +0100 Subject: [PATCH 30/31] Revert "Remove Resources volume mount from compose.yaml" This reverts commit 9066648d9a2a9b499749ed3e351ba3a4715336c5. --- compose.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compose.yaml b/compose.yaml index 88a8cd26..80e53fd3 100644 --- a/compose.yaml +++ b/compose.yaml @@ -9,6 +9,9 @@ services: ports: - "${BEAMMP_PORT}:${BEAMMP_PORT}/tcp" - "${BEAMMP_PORT}:${BEAMMP_PORT}/udp" + volumes: + # Mount resources directory (mods, plugins, etc.) + - ./Resources:/app/Resources env_file: - .env environment: From dca9fbd6e50092cb676da5b4fc58e975d18258fe Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Wed, 18 Mar 2026 08:05:12 +0100 Subject: [PATCH 31/31] Remove volume comment in compose.yaml Remove a redundant comment above the Resources volume mount in compose.yaml. This is a non-functional cleanup to reduce clutter in the compose file; the actual volume mapping (./Resources:/app/Resources) is unchanged. --- compose.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 80e53fd3..e9903a7a 100644 --- a/compose.yaml +++ b/compose.yaml @@ -10,7 +10,6 @@ services: - "${BEAMMP_PORT}:${BEAMMP_PORT}/tcp" - "${BEAMMP_PORT}:${BEAMMP_PORT}/udp" volumes: - # Mount resources directory (mods, plugins, etc.) - ./Resources:/app/Resources env_file: - .env