Update compose + CI for CasaOS deploy; build both images in CI

docker-compose.yml:
- Remove env_file — all vars inline with \${VAR:-default} substitution
- NTFY_TOPIC soft-defaults to empty (no hard :? error)
- Pull pre-built images from ghcr.io (no local build step)
- Add resource limits: app 512MB/1CPU, notifier 128MB/0.25CPU
- Add x-casaos metadata for CasaOS app store / dashboard
- Remove dev service (run separately as needed)

.github/workflows/docker.yml:
- Build and push both app (ghcr.io/nmemmert/letter) and notifier
  (ghcr.io/nmemmert/letter-notifier) images in one job
- Separate GHA cache scopes per image for efficient layer reuse
- Separate metadata steps for independent tag sets

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 4.6 committed 2026-08-17 13:26:54 -04:00
1 parent 0eb625c188
commit fc3bae40da
2 files changed
+71 -66

No files matched your search

+32 -10
View File
@@ -7,11 +7,12 @@ on:
env: env:
REGISTRY: ghcr.io REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }} APP_IMAGE: ghcr.io/nmemmert/letter
NOTIFIER_IMAGE: ghcr.io/nmemmert/letter-notifier
jobs: jobs:
docker: docker:
name: Build & push image name: Build & push images
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
@@ -30,23 +31,44 @@ jobs:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags & labels) - name: Extract metadata — app
id: meta id: meta-app
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} images: ${{ env.APP_IMAGE }}
tags: | tags: |
type=ref,event=branch type=ref,event=branch
type=semver,pattern={{version}} type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=sha-,format=short type=sha,prefix=sha-,format=short
- name: Build and push - name: Extract metadata — notifier
id: meta-notifier
uses: docker/metadata-action@v5
with:
images: ${{ env.NOTIFIER_IMAGE }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=sha-,format=short
- name: Build and push — app
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: . context: .
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta-app.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta-app.outputs.labels }}
cache-from: type=gha cache-from: type=gha,scope=app
cache-to: type=gha,mode=max cache-to: type=gha,mode=max,scope=app
- name: Build and push — notifier
uses: docker/build-push-action@v6
with:
context: ./notifier
push: true
tags: ${{ steps.meta-notifier.outputs.tags }}
labels: ${{ steps.meta-notifier.outputs.labels }}
cache-from: type=gha,scope=notifier
cache-to: type=gha,mode=max,scope=notifier
+39 -56
View File
@@ -1,66 +1,49 @@
services: services:
# ── Web app (nginx, port 8080) ──────────────────────────────────────────────
app: app:
build: . image: "ghcr.io/nmemmert/letter:main"
image: ghcr.io/nmemmert/letter:main deploy:
resources:
reservations:
memory: 128MB
cpus: "0.00"
limits:
memory: 512MB
cpus: "1.00"
restart: no
network_mode: bridge
ports: ports:
- "${APP_PORT:-8080}:80" - "${APP_PORT:-8080}:80"
restart: unless-stopped volumes: []
# ── Monthly ntfy reminder ───────────────────────────────────────────────────
notifier: notifier:
build: ./notifier image: "ghcr.io/nmemmert/letter-notifier:main"
restart: unless-stopped deploy:
env_file: resources:
- path: .env reservations:
required: false # container still starts without a .env file memory: 64MB
cpus: "0.00"
limits:
memory: 128MB
cpus: "0.25"
restart: no
network_mode: bridge
volumes: []
environment: environment:
# ── ntfy connection ─────────────────────────────────────────────────── - NTFY_TOPIC=${NTFY_TOPIC:-}
# Required: your ntfy topic — keep it unguessable, e.g. "nate-letter-k7x2" - NTFY_URL=${NTFY_URL:-https://ntfy.sh}
# Subscribe at https://ntfy.sh/<NTFY_TOPIC> or in the ntfy mobile app - NTFY_TOKEN=${NTFY_TOKEN:-}
NTFY_TOPIC: ${NTFY_TOPIC:?NTFY_TOPIC is required — set it in .env} - NTFY_PRIORITY=${NTFY_PRIORITY:-default}
- CRON_SCHEDULE=${CRON_SCHEDULE:-0 9 1 * *}
# ntfy server (default: ntfy.sh; set to your self-hosted URL if applicable) - TZ=${TZ:-America/Chicago}
NTFY_URL: ${NTFY_URL:-https://ntfy.sh} - APP_URL=${APP_URL:-http://172.16.16.106:8080}
- NTFY_TEST_ON_START=${NTFY_TEST_ON_START:-false}
# Bearer token for access-controlled / private topics (leave blank for public)
NTFY_TOKEN: ${NTFY_TOKEN:-}
# Notification priority: min | low | default | high | urgent
NTFY_PRIORITY: ${NTFY_PRIORITY:-default}
# ── Schedule ──────────────────────────────────────────────────────────
# Cron expression — default fires at 9 AM on the 1st of every month
# Format: minute hour day-of-month month day-of-week
CRON_SCHEDULE: ${CRON_SCHEDULE:-0 9 1 * *}
# IANA timezone for the cron schedule
TZ: ${TZ:-America/Chicago}
# ── App ───────────────────────────────────────────────────────────────
# URL the notification deep-links back to (shown as "Open" in ntfy)
APP_URL: ${APP_URL:-http://localhost:8080}
# Set to "true" to fire a test notification immediately on container start
NTFY_TEST_ON_START: ${NTFY_TEST_ON_START:-false}
depends_on: depends_on:
- app - app
# ── Local dev (Vite HMR, port 5173) — run with: docker compose --profile dev up dev x-casaos:
dev: title:
image: node:20-alpine custom: "Annual Letter"
working_dir: /app main: app
volumes: scheme: http
- .:/app hostname: "172.16.16.106"
- node_modules:/app/node_modules index: /
ports:
- "${DEV_PORT:-5173}:5173"
environment:
NODE_ENV: development
command: sh -c "npm install && npm run dev -- --host 0.0.0.0"
profiles: [dev]
volumes:
node_modules: