Merge pull request #1493 from CyberL1/feat/docker-image-build-workflows

This commit is contained in:
Cyber
2026-02-10 10:27:17 +01:00
committed by GitHub
9 changed files with 258 additions and 125 deletions
@@ -0,0 +1,36 @@
name: Build admin api docker image
on:
push:
branches:
- master
paths:
- "extra/admin-api/Spacebar.AdminApi/**"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build the docker image
run: nix build .#containers.x86_64-linux.docker.admin-api
- run: docker load < result
- name: downcase REPO
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>$GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push the image
run: |
IMAGE_ID=$(docker images spacebar-server-ts-admin-api --format '{{.ID}}')
docker tag $IMAGE_ID ghcr.io/$REPO-admin-api
docker push ghcr.io/$REPO-admin-api
+38
View File
@@ -0,0 +1,38 @@
name: Build api docker image
on:
push:
branches:
- master
paths:
- "src/api/**"
- "src/schemas/**"
- "src/util/**"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build the docker image
run: nix build .#containers.x86_64-linux.docker.api
- run: docker load < result
- name: downcase REPO
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>$GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push the image
run: |
IMAGE_ID=$(docker images spacebar-server-ts-api --format '{{.ID}}')
docker tag $IMAGE_ID ghcr.io/$REPO-api
docker push ghcr.io/$REPO-api
+36
View File
@@ -0,0 +1,36 @@
name: Build bundle docker image
on:
push:
branches:
- master
paths:
- "src/**"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build the docker image
run: nix build .#containers.x86_64-linux.docker.default
- run: docker load < result
- name: downcase REPO
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>$GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push the image
run: |
IMAGE_ID=$(docker images spacebar-server-ts --format '{{.ID}}')
docker tag $IMAGE_ID ghcr.io/$REPO
docker push ghcr.io/$REPO
+36
View File
@@ -0,0 +1,36 @@
name: Build cdn cs docker image
on:
push:
branches:
- master
paths:
- "extra/admin-api/Spacebar.Cdn/**"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build the docker image
run: nix build .#containers.x86_64-linux.docker.cdn-cs
- run: docker load < result
- name: downcase REPO
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>$GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push the image
run: |
IMAGE_ID=$(docker images spacebar-server-ts-cdn-cs --format '{{.ID}}')
docker tag $IMAGE_ID ghcr.io/$REPO-cdn-cs
docker push ghcr.io/$REPO-cdn-cs
+38
View File
@@ -0,0 +1,38 @@
name: Build cdn docker image
on:
push:
branches:
- master
paths:
- "src/cdn/**"
- "src/schemas/**"
- "src/util/**"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build the docker image
run: nix build .#containers.x86_64-linux.docker.cdn
- run: docker load < result
- name: downcase REPO
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>$GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push the image
run: |
IMAGE_ID=$(docker images spacebar-server-ts-cdn --format '{{.ID}}')
docker tag $IMAGE_ID ghcr.io/$REPO-cdn
docker push ghcr.io/$REPO-cdn
@@ -0,0 +1,36 @@
name: Build gateway offload docker image
on:
push:
branches:
- master
paths:
- "extra/admin-api/Spacebar.GatewayOffload/**"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build the docker image
run: nix build .#containers.x86_64-linux.docker.gateway-offload
- run: docker load < result
- name: downcase REPO
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>$GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push the image
run: |
IMAGE_ID=$(docker images spacebar-server-ts-gateway-offload --format '{{.ID}}')
docker tag $IMAGE_ID ghcr.io/$REPO-gateway-offload
docker push ghcr.io/$REPO-gateway-offload
@@ -0,0 +1,38 @@
name: Build gateway docker image
on:
push:
branches:
- master
paths:
- "src/gateway/**"
- "src/schemas/**"
- "src/util/**"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build the docker image
run: nix build .#containers.x86_64-linux.docker.gateway
- run: docker load < result
- name: downcase REPO
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>$GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push the image
run: |
IMAGE_ID=$(docker images spacebar-server-ts-gateway --format '{{.ID}}')
docker tag $IMAGE_ID ghcr.io/$REPO-gateway
docker push ghcr.io/$REPO-gateway
-50
View File
@@ -1,50 +0,0 @@
name: Publish Image
on:
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Log in to the Container registry
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 }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v3
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
-75
View File
@@ -1,75 +0,0 @@
ARG DEBIAN_CODE=trixie
ARG NODE_VERSION=24
ARG PYTHON_VERSION=3.13
ARG USER_NAME=spacebar
ARG USER_GROUP=$USER_NAME
ARG USER_UID=1000
ARG USER_GID=1000
ARG BASEDIR=/spacebar
FROM python:${PYTHON_VERSION}-slim-${DEBIAN_CODE} AS base_python
FROM node:${NODE_VERSION}-${DEBIAN_CODE}-slim AS base
COPY --from=base_python /usr/local/bin/python* /usr/local/bin/
COPY --from=base_python /usr/local/bin/pip* /usr/local/bin/
COPY --from=base_python /usr/local/lib/python* /usr/local/lib/
COPY --from=base_python /usr/local/lib/libpython* /usr/local/lib/
FROM base AS builder
ARG BRANCH
WORKDIR /build
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential pkg-config && \
rm -rf /var/lib/apt/lists/*
WORKDIR /build/server
COPY . .
RUN npm i \
&& npm run setup
FROM base AS final
ARG USER_NAME
ARG USER_GROUP
ARG USER_UID
ARG USER_GID
ARG BASEDIR
RUN mkdir -p "${BASEDIR}/server" \
&& chown -R "${USER_UID}:${USER_GID}" "${BASEDIR}"
RUN deluser node 2>/dev/null || true \
&& delgroup node 2>/dev/null || true \
&& rm -fr /home/node 2>/dev/null || true \
&& addgroup --gid "$USER_GID" "$USER_GROUP" \
&& adduser \
--disabled-password \
--gecos "" \
--uid "$USER_UID" \
--gid "$USER_GID" \
--no-create-home \
"$USER_NAME"
USER ${USER_NAME}
#@todo: only bring what we need
COPY --chown=${USER_NAME}:${USER_GROUP} --from=builder /build/server "${BASEDIR}/server"
ENV PORT="3001"
ENV CONFIG_PATH="${BASEDIR}/config.json"
ENV DATABASE="${BASEDIR}/database.db"
WORKDIR "${BASEDIR}/server"
ENTRYPOINT [ "npm", "run" ]
CMD [ "start" ]