Skip to content

Commit faf71a0

Browse files
authored
Merge pull request cinnyapp#64 from hazre/ci/add-docker-image-builds
ci: add docker image workflow
2 parents 08fa7cd + 3e02071 commit faf71a0

2 files changed

Lines changed: 111 additions & 1 deletion

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build and publish Docker image
2+
3+
on:
4+
push:
5+
branches: [dev]
6+
tags:
7+
- '+([0-9]).+([0-9]).+([0-9])'
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
attestations: write
20+
artifact-metadata: write
21+
id-token: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
26+
with:
27+
persist-credentials: false
28+
29+
- name: Log in to GitHub Container Registry
30+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Extract metadata
37+
id: meta
38+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
flavor: |
42+
latest=false
43+
tags: |
44+
# dev branch: short commit SHA + latest
45+
type=sha,prefix=,format=short,enable=${{ github.ref == 'refs/heads/dev' }}
46+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }}
47+
48+
# git tags: semver breakdown
49+
type=semver,pattern={{version}}
50+
type=semver,pattern={{major}}.{{minor}}
51+
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
52+
53+
- name: Set up QEMU
54+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
55+
56+
- name: Set up Docker Buildx
57+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
58+
59+
- name: Build and push Docker image
60+
id: push
61+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
62+
with:
63+
context: .
64+
push: true
65+
platforms: linux/amd64,linux/arm64,linux/arm/v7
66+
tags: ${{ steps.meta.outputs.tags }}
67+
labels: ${{ steps.meta.outputs.labels }}
68+
cache-from: type=gha
69+
cache-to: type=gha,mode=max
70+
71+
- name: Generate artifact attestation
72+
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
73+
with:
74+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
75+
subject-digest: ${{ steps.push.outputs.digest }}
76+
push-to-registry: true

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,41 @@ The web app is available at [app.sable.moe](https://app.sable.moe/) and gets upd
1212
You can also download our desktop app for windows and linux from [releases](https://github.com/7w1/sable/releases/latest).
1313

1414
## Self-hosting
15-
To host Sable on your own, download this repo and built with nginx.
15+
You can either run the prebuilt container image or build Sable yourself.
16+
17+
### Docker
18+
19+
Prebuilt images are published to `ghcr.io/7w1/sable`.
20+
21+
- `latest` tracks the current `dev` branch image.
22+
- `X.Y.Z` tags are versioned releases.
23+
- `X.Y` tags float within a release line.
24+
- Pushes to `dev` also publish a short commit SHA tag.
25+
26+
Run the latest image with:
27+
28+
```sh
29+
docker run --rm -p 8080:80 ghcr.io/7w1/sable:latest
30+
```
31+
32+
Then open `http://localhost:8080`.
33+
34+
If you want to override the bundled [`config.json`](config.json), mount your own
35+
file at `/app/config.json`:
36+
37+
```yaml
38+
services:
39+
sable:
40+
image: ghcr.io/7w1/sable:latest
41+
ports:
42+
- '8080:80'
43+
volumes:
44+
- ./config.json:/app/config.json:ro
45+
```
46+
47+
### Build it yourself
48+
49+
To build and serve Sable yourself with nginx, clone this repo and build it:
1650
1751
```sh
1852
npm ci # Installs all dependencies

0 commit comments

Comments
 (0)