From 3e0207110804d75a639d9a0d87e8f96a129979a1 Mon Sep 17 00:00:00 2001 From: hazre Date: Mon, 2 Mar 2026 23:46:12 +0100 Subject: [PATCH] ci: add docker image workflow --- .github/workflows/docker-publish.yml | 76 ++++++++++++++++++++++++++++ README.md | 36 ++++++++++++- 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 000000000..ff7656b9b --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,76 @@ +name: Build and publish Docker image + +on: + push: + branches: [dev] + tags: + - '+([0-9]).+([0-9]).+([0-9])' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + artifact-metadata: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Log in to GitHub Container Registry + uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + latest=false + tags: | + # dev branch: short commit SHA + latest + type=sha,prefix=,format=short,enable=${{ github.ref == 'refs/heads/dev' }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }} + + # git tags: semver breakdown + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64,linux/arm/v7 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/README.md b/README.md index a893884fd..f8998a50a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,41 @@ The web app is available at [app.sable.moe](https://app.sable.moe/) and gets upd You can also download our desktop app for windows and linux from [releases](https://github.com/7w1/sable/releases/latest). ## Self-hosting -To host Sable on your own, download this repo and built with nginx. +You can either run the prebuilt container image or build Sable yourself. + +### Docker + +Prebuilt images are published to `ghcr.io/7w1/sable`. + +- `latest` tracks the current `dev` branch image. +- `X.Y.Z` tags are versioned releases. +- `X.Y` tags float within a release line. +- Pushes to `dev` also publish a short commit SHA tag. + +Run the latest image with: + +```sh +docker run --rm -p 8080:80 ghcr.io/7w1/sable:latest +``` + +Then open `http://localhost:8080`. + +If you want to override the bundled [`config.json`](config.json), mount your own +file at `/app/config.json`: + +```yaml +services: + sable: + image: ghcr.io/7w1/sable:latest + ports: + - '8080:80' + volumes: + - ./config.json:/app/config.json:ro +``` + +### Build it yourself + +To build and serve Sable yourself with nginx, clone this repo and build it: ```sh npm ci # Installs all dependencies