From c8baa15bb16b3394508fedc284767f8c730d4a93 Mon Sep 17 00:00:00 2001 From: Corey Sotiropoulos Date: Fri, 23 Jan 2026 01:37:05 +0000 Subject: [PATCH] [ci,docker] Improve documentation for repo vars and build args --- .github/workflows/docker_build.yml | 3 ++- .github/workflows/docker_test.yml | 1 + .github/workflows/pr_checks.yml | 2 ++ .github/workflows/publish_meshes.yml | 1 + .github/workflows/test.yml | 2 ++ docker/README.md | 24 +++++++++++++++++------- docker/alpine.Dockerfile | 8 +++++++- docker/ubuntu.Dockerfile | 8 +++++++- 8 files changed, 39 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 6dba166646c..e05155b41a5 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -45,7 +45,7 @@ on: type: boolean default: false publish: - description: 'Publish image to registry.' + description: 'Publish image to registry. Requires PUBLISH_DOCKER repo var to be set to a non-empty value and packages enabled.' required: false type: boolean default: false @@ -58,6 +58,7 @@ jobs: BUILDX_NO_DEFAULT_ATTESTATIONS: 1 # https://github.com/orgs/community/discussions/45969 build_id: ${{ format('build-{0}-{1}-{2}-tracy{3}-pch{4}', inputs.os, inputs.compiler, inputs.build_type, inputs.tracy && 'ON' || 'OFF', inputs.build_type == 'Debug' && 'OFF' || 'ON') }} ccache_id: ${{ format('ccache-{0}-{1}-{2}-tracy{3}-pch{4}', inputs.os, inputs.compiler, inputs.build_type, inputs.tracy && 'ON' || 'OFF', inputs.build_type == 'Debug' && 'OFF' || 'ON') }} + # Placeholder values. Actual values set in the first step. REPO_OWNER: 'landsandboat' REPO: 'landsandboat/server' steps: diff --git a/.github/workflows/docker_test.yml b/.github/workflows/docker_test.yml index 8600f0f9e51..b355b34e501 100644 --- a/.github/workflows/docker_test.yml +++ b/.github/workflows/docker_test.yml @@ -33,6 +33,7 @@ jobs: XI_NETWORK_SQL_DATABASE: xidb XI_NETWORK_SQL_LOGIN: xiadmin XI_NETWORK_SQL_PASSWORD: 'password' + # Placeholder values. Actual values set in the first step. REPO_OWNER: 'landsandboat' REPO: 'landsandboat/server' services: diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml index 815ecb61a1a..581835f411f 100644 --- a/.github/workflows/pr_checks.yml +++ b/.github/workflows/pr_checks.yml @@ -1,3 +1,5 @@ +# Set DEVTOOLS_IMAGE repo var to use a different devtools image. Default: ghcr.io/landsandboat/devtools:ubuntu + name: PR Checks on: diff --git a/.github/workflows/publish_meshes.yml b/.github/workflows/publish_meshes.yml index 745e9618a93..da26c841158 100644 --- a/.github/workflows/publish_meshes.yml +++ b/.github/workflows/publish_meshes.yml @@ -15,6 +15,7 @@ jobs: name: Build and Publish ximeshes Docker Image runs-on: ubuntu-latest env: + # Placeholder value. Actual value set in the first step. REPO_OWNER: 'landsandboat' steps: - name: Lowercase repository owner diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 98728c80a15..413ebb72371 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,3 +1,5 @@ +# Set DEVTOOLS_IMAGE repo var to use a different devtools image. Default: ghcr.io/landsandboat/devtools:ubuntu + name: Tests on: diff --git a/docker/README.md b/docker/README.md index eddc2e7e303..8c9c6736f29 100644 --- a/docker/README.md +++ b/docker/README.md @@ -213,27 +213,37 @@ volumes: docker build -f docker/ubuntu.Dockerfile . ``` -The Dockerfiles also support a few build args: +The Dockerfiles support a few [build args](https://docs.docker.com/build/building/variables/#arg-usage-example), use these if you want to use a different compiler/version/user/etc: ``` -BASE_TAG +BASE_TAG=24.04 UNAME=xiadmin UGROUP=xiadmin UID=1000 GID=1000 COMPILER=gcc -GCC_VERSION -LLVM_VERSION +GCC_VERSION=14 +LLVM_VERSION=20 CMAKE_BUILD_TYPE=Release TRACY_ENABLE=OFF ENABLE_CLANG_TIDY=OFF PCH_ENABLE=ON WARNINGS_AS_ERRORS=TRUE -REPO_URL -BRANCH +REPO_URL="https://github.com/USERNAME/server" +COMMIT_SHA="$(git rev-parse HEAD)" ``` -`REPO_URL` and `BRANCH` are required for dbtool unless you mount the host .git directory at runtime. +`REPO_URL` and `COMMIT_SHA` are required for dbtool unless you mount the host .git directory at runtime. + +Be mindful of the [license requirements](../LICENSE) if you publish your image, as not all source files are included in the final image. Providing the `REPO_URL` and `COMMIT_SHA` will add labels that link to your published source when viewed with `docker inspect`. + +```sh +docker build -f docker/ubuntu.Dockerfile \ +--tag USERNAME/server:latest \ +--build-arg REPO_URL="https://github.com/USERNAME/server" \ +--build-arg COMMIT_SHA="$(git rev-parse HEAD)" \ +. +``` ## Devtools diff --git a/docker/alpine.Dockerfile b/docker/alpine.Dockerfile index 2a4103d4dcf..dfb30e76df2 100644 --- a/docker/alpine.Dockerfile +++ b/docker/alpine.Dockerfile @@ -43,8 +43,10 @@ chown $UNAME:$UGROUP /server git config --system --add safe.directory /server EOF +# Pre-enable Python virtual environment. ENV VIRTUAL_ENV=/xiadmin/.venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" + ENV TRACY_NO_INVARIANT_CHECK=1 SHELL ["/bin/bash", "-c"] @@ -75,6 +77,7 @@ apk --update-cache add \ EOF # Install secondary dependencies as user. +# python3 = global, python = (pre-enabled) venv USER $UNAME RUN --mount=type=bind,source=tools/requirements.txt,target=/tmp/requirements.txt \ --mount=type=cache,target=/xiadmin/.cache/pip,id=cache-pip-alpine <