Skip to content

Commit 41fb9c5

Browse files
committed
ci: build own Docker image from newsdiff app source
- Clones rmdes/newsdiff, builds with the generic Dockerfile - Pushes to ghcr.io/rmdes/newsdiff-deploy:main - Weekly rebuild to pick up app updates - docker-compose.yml references own image instead of newsdiff repo - Keeps compose + nginx validation as pre-build step
1 parent b189146 commit 41fb9c5

3 files changed

Lines changed: 76 additions & 39 deletions

File tree

.github/workflows/docker.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Build and push Docker image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
workflow_dispatch:
8+
schedule:
9+
# Rebuild weekly to pick up latest newsdiff app image layers
10+
- cron: '0 6 * * 1'
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ghcr.io/rmdes/newsdiff-deploy
15+
16+
jobs:
17+
validate:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Validate docker-compose.yml
23+
env:
24+
ORIGIN: https://example.com
25+
POSTGRES_PASSWORD: ci-test-password
26+
run: docker compose config --quiet
27+
28+
- name: Check nginx config syntax
29+
run: |
30+
docker run --rm \
31+
-v "$PWD/nginx.conf:/etc/nginx/nginx.conf:ro" \
32+
--add-host app:127.0.0.1 \
33+
--add-host bot:127.0.0.1 \
34+
nginx:alpine nginx -t
35+
36+
build:
37+
runs-on: ubuntu-latest
38+
needs: validate
39+
permissions:
40+
contents: read
41+
packages: write
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
# Clone the app source to build from
46+
- name: Clone newsdiff app
47+
run: git clone --depth 1 https://github.com/rmdes/newsdiff.git app
48+
49+
- uses: docker/setup-buildx-action@v3
50+
51+
- uses: docker/login-action@v3
52+
with:
53+
registry: ghcr.io
54+
username: ${{ github.actor }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- uses: docker/metadata-action@v5
58+
id: meta
59+
with:
60+
images: ${{ env.IMAGE_NAME }}
61+
tags: |
62+
type=ref,event=branch
63+
type=semver,pattern={{version}}
64+
type=sha
65+
66+
- uses: docker/build-push-action@v6
67+
with:
68+
context: ./app
69+
push: true
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}
72+
cache-from: type=gha
73+
cache-to: type=gha,mode=max

.github/workflows/validate.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
# Database migrations (runs once on startup, then exits)
33
migrate:
4-
image: ghcr.io/rmdes/newsdiff:main
4+
image: ghcr.io/rmdes/newsdiff-deploy:main
55
command: ["node", "--import", "tsx/esm", "src/lib/server/db/migrate.ts"]
66
environment:
77
DATABASE_URL: postgres://${POSTGRES_USER:-newsdiff}:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-newsdiff}
@@ -12,7 +12,7 @@ services:
1212

1313
# SvelteKit web app + feed poller + syndicator workers
1414
app:
15-
image: ghcr.io/rmdes/newsdiff:main
15+
image: ghcr.io/rmdes/newsdiff-deploy:main
1616
command: ["node", "build/index.js"]
1717
environment:
1818
DATABASE_URL: postgres://${POSTGRES_USER:-newsdiff}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-newsdiff}
@@ -44,7 +44,7 @@ services:
4444

4545
# ActivityPub bot (handles incoming federation requests)
4646
bot:
47-
image: ghcr.io/rmdes/newsdiff:main
47+
image: ghcr.io/rmdes/newsdiff-deploy:main
4848
command: ["node", "--import", "tsx/esm", "src/bot/index.ts"]
4949
environment:
5050
REDIS_HOST: redis

0 commit comments

Comments
 (0)