diff --git a/.dockerignore b/.dockerignore index ad321ff..23c61aa 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,7 @@ _site/ .git/ .claude/ node_modules/ +images/ .sass-cache/ .jekyll-metadata *.md diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index eafa89d..3cca3fd 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,15 +1,16 @@ -name: Build & Push Docker Image to GHCR +name: Build & Push Docker Image to Gitea Registry on: push: branches: [master] env: - REGISTRY: ghcr.io - IMAGE_NAME: kroonk/photography + REGISTRY: git.mischlabs.de + REGISTRY_IMAGE: git.mischlabs.de/mrdiderot/photography jobs: build-and-push: + if: ${{ github.server_url == 'https://git.mischlabs.de' }} runs-on: ubuntu-latest steps: - name: Checkout @@ -40,16 +41,20 @@ jobs: fi docker --version - - name: Log in to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ secrets.GHCR_USERNAME }} - password: ${{ secrets.GHCR_TOKEN }} + - name: Log in to Gitea Package Registry + shell: sh + run: | + if [ -z "${{ secrets.REGISTRY_USER }}" ] || [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then + echo "Missing registry credentials." + echo "Create repository secrets REGISTRY_USER and REGISTRY_TOKEN." + echo "REGISTRY_TOKEN must be a Gitea access token with package write permission." + exit 1 + fi + echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ env.REGISTRY }}" -u "${{ secrets.REGISTRY_USER }}" --password-stdin - name: Build and push Docker image shell: sh run: | - docker build -t ghcr.io/kroonk/photography:latest -t ghcr.io/kroonk/photography:${{ github.sha }} . - docker push ghcr.io/kroonk/photography:latest - docker push ghcr.io/kroonk/photography:${{ github.sha }} + docker build -t ${{ env.REGISTRY_IMAGE }}:latest -t ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} . + docker push ${{ env.REGISTRY_IMAGE }}:latest + docker push ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} diff --git a/Dockerfile b/Dockerfile index ebd756f..aa7aee9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,19 +12,26 @@ COPY . . RUN bundle exec jekyll build -# === Serve-Phase: node.js backend + ImageMagick === -FROM node:20-alpine +# === Node-Dependencies: native sqlite3 mit Build-Tools bauen === +FROM node:20-alpine AS node-deps -# ImageMagick + Format-Delegates (JPEG/PNG/WebP), Build-Tools fuer sqlite3 native bindings -RUN apk add --no-cache imagemagick \ - libjpeg-turbo libjpeg-turbo-dev \ - libpng libpng-dev \ - libwebp libwebp-dev \ - python3 make g++ build-base sqlite-dev +RUN apk add --no-cache python3 make g++ sqlite-dev WORKDIR /app COPY package*.json ./ -RUN npm install --omit=dev +RUN npm ci --omit=dev && npm cache clean --force + +# === Serve-Phase: node.js backend + Runtime-Tools === +FROM node:20-alpine + +# Getrennte RUNs halten einzelne Registry-Layer klein genug fuer Proxy-Limits. +RUN apk add --no-cache docker-cli +RUN apk add --no-cache imagemagick libjpeg-turbo libpng libwebp +RUN apk add --no-cache sqlite-libs + +WORKDIR /app +COPY package*.json ./ +COPY --from=node-deps /app/node_modules ./node_modules COPY backend ./backend COPY --from=builder /site/_site ./public diff --git a/README.md b/README.md index 60c676b..92ab26a 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,18 @@ To deploy on a NAS or Linux server, adjust the `docker-compose.yml` to match you ```yaml services: photography-website: - image: ghcr.io/kroonk/photography:latest + image: git.mischlabs.de/mrdiderot/photography:latest container_name: photography-website ports: - "8090:8090" + environment: + - JWT_SECRET=replace-with-a-long-random-secret + - INITIAL_ADMIN_USERNAME=MrDiderot + - INITIAL_ADMIN_PASSWORD=Start123 + - FULLS_DIR=/app/public/images/fulls + - THUMBS_DIR=/app/public/images/thumbs + - SYNC_IMAGE=git.mischlabs.de/mrdiderot/photography:latest + - SYNC_CONTAINER=photography-website volumes: - /path/to/nextcloud/data:/app/public/images/fulls:ro - thumbs:/app/public/images/thumbs @@ -32,6 +40,14 @@ services: Run `docker compose up -d` to launch the site. +Change the initial admin password after the first login. If you prefer not to store the initial password in `docker-compose.yml`, create a bcrypt hash and use `INITIAL_ADMIN_PASSWORD_HASH` instead: + +```bash +node -e "const bcrypt = require('bcryptjs'); console.log(bcrypt.hashSync('your-admin-password', 10));" +``` + +The admin dashboard includes a sync button that pulls `SYNC_IMAGE` and restarts `SYNC_CONTAINER`. This requires the Docker socket mount shown above. + ## Credits & License - Originally based on a Jekyll template. - UI Design by [AJ / HTML5 UP](https://html5up.net). diff --git a/admin.html b/admin.html index c0defed..0a2fb65 100644 --- a/admin.html +++ b/admin.html @@ -6,7 +6,10 @@ @@ -34,7 +41,8 @@ -
+
+

Nutzer erstellen

@@ -62,6 +70,13 @@
+

Website aktualisieren

+

Laedt das neueste Docker-Image und startet den Website-Container neu.

+ + +
+ +

Nutzerverwaltung

@@ -69,7 +84,7 @@
IDUsernameRolleErstelltAktionen
-
+

Ordner-Zuweisung

Waehle einen Nutzer und klicke auf Ordner um sie zuzuweisen oder zu entfernen.