diff --git a/.gitea/workflows/docker-build-push.yaml b/.gitea/workflows/docker-build-push.yaml new file mode 100644 index 0000000..9a65610 --- /dev/null +++ b/.gitea/workflows/docker-build-push.yaml @@ -0,0 +1,80 @@ +# Build and push Docker images to Gitea registry on push to main. +# Requires: Repository Actions enabled; secrets REGISTRY_USER and REGISTRY_TOKEN (PAT with package write); +# a runner with Docker (e.g. act_runner with Docker, or host Docker socket). +# Registry is assumed to be the same Gitea host; set REGISTRY in repo variables if different. + +name: Docker build and push + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: https://github.com/actions/checkout@v4 + + - name: Set version + id: version + run: | + VERSION=$(git describe --tags --always 2>/dev/null | sed 's/^v//' || echo "latest") + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Building with tag: $VERSION" + + - name: Log in to Gitea container registry + env: + REGISTRY: ${{ vars.REGISTRY || '10.0.10.205:3000' }} + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} + run: | + echo "$REGISTRY_TOKEN" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin + + - name: Build and push api + env: + REGISTRY: ${{ vars.REGISTRY || '10.0.10.205:3000' }} + OWNER: ${{ vars.REGISTRY_OWNER || 'bert.hausmans' }} + VERSION: ${{ steps.version.outputs.version }} + run: | + docker build --platform linux/amd64 \ + -t "$REGISTRY/$OWNER/event-uploader-api:$VERSION" ./api + docker push "$REGISTRY/$OWNER/event-uploader-api:$VERSION" + if [ "$VERSION" != "latest" ]; then + docker tag "$REGISTRY/$OWNER/event-uploader-api:$VERSION" "$REGISTRY/$OWNER/event-uploader-api:latest" + docker push "$REGISTRY/$OWNER/event-uploader-api:latest" + fi + + - name: Build and push admin + env: + REGISTRY: ${{ vars.REGISTRY || '10.0.10.205:3000' }} + OWNER: ${{ vars.REGISTRY_OWNER || 'bert.hausmans' }} + VERSION: ${{ steps.version.outputs.version }} + run: | + docker build --platform linux/amd64 \ + -t "$REGISTRY/$OWNER/event-uploader-admin:$VERSION" ./admin + docker push "$REGISTRY/$OWNER/event-uploader-admin:$VERSION" + if [ "$VERSION" != "latest" ]; then + docker tag "$REGISTRY/$OWNER/event-uploader-admin:$VERSION" "$REGISTRY/$OWNER/event-uploader-admin:latest" + docker push "$REGISTRY/$OWNER/event-uploader-admin:latest" + fi + + - name: Build and push upload + env: + REGISTRY: ${{ vars.REGISTRY || '10.0.10.205:3000' }} + OWNER: ${{ vars.REGISTRY_OWNER || 'bert.hausmans' }} + VERSION: ${{ steps.version.outputs.version }} + run: | + docker build --platform linux/amd64 \ + -t "$REGISTRY/$OWNER/event-uploader-upload:$VERSION" ./upload + docker push "$REGISTRY/$OWNER/event-uploader-upload:$VERSION" + if [ "$VERSION" != "latest" ]; then + docker tag "$REGISTRY/$OWNER/event-uploader-upload:$VERSION" "$REGISTRY/$OWNER/event-uploader-upload:latest" + docker push "$REGISTRY/$OWNER/event-uploader-upload:latest" + fi + + - name: Summary + run: | + echo "Images pushed with tag: ${{ steps.version.outputs.version }}" + echo "On Dockge: set TAG=${{ steps.version.outputs.version }} (or TAG=latest) and Pull + Redeploy." diff --git a/deploy/README.md b/deploy/README.md index 52759e6..3c9e367 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -6,12 +6,16 @@ Production stack: images from Gitea registry only. Use from Dockge on the home s Build and upload images to Gitea’s container registry (`10.0.10.205:3000`) from your dev machine so Dockge can pull them. +**Option A: Gitea Actions (on push to main)** — Enable Repository Actions, register a runner with Docker, add secrets `REGISTRY_USER` and `REGISTRY_TOKEN` (PAT with package write). The workflow `.gitea/workflows/docker-build-push.yaml` builds api, admin, upload for `linux/amd64` on every push to `main`. MariaDB: run `./scripts/push-mariadb-to-registry.sh` once from your dev machine. + +**Option B: Manual** — From your dev machine: + 1. **One-time:** Allow HTTP registry and log in: - Docker Desktop (Mac): Settings → Docker Engine → add `"insecure-registries": ["10.0.10.205:3000"]`, Apply. - Run: `docker login 10.0.10.205:3000` (username: `bert.hausmans`, password: Gitea password or a personal access token with package read/write). 2. **Each release:** From the project root: - - `./scripts/docker-build-push.sh 1.0.0` (or any version; omit to use `latest` or git describe). - - Or manually: set `VERSION=1.0.0`, `REGISTRY=10.0.10.205:3000`, `OWNER=bert.hausmans`, then `docker build -t $REGISTRY/$OWNER/event-uploader-api:$VERSION ./api` (and same for `admin`, `upload`), then `docker push` for each. + - `./scripts/docker-build-push.sh 1.0.0` (or any version; omit to use `latest` or git describe). Images are built for `linux/amd64` by default so they run on typical Dockge servers; if your server is ARM, run `PLATFORM=linux/arm64 ./scripts/docker-build-push.sh ...`. + - Or manually: set `VERSION=1.0.0`, `REGISTRY=...`, `OWNER=...`, then `docker build --platform linux/amd64 -t ...` and push for api, admin, upload. After pushing, deploy on the server: set `TAG=1.0.0` in the stack `.env`, then in Dockge use **Pull** and **Redeploy**. @@ -56,3 +60,18 @@ This means the registry has no image for the tag Dockge is using. ### "no matching manifest for linux/amd64" (database) The stack uses **MariaDB 11** from your Gitea registry (`10.0.10.205:3000/bert.hausmans/mariadb:11`). If that image is missing or the server can’t pull from Docker Hub, run once from your dev machine (after `docker login 10.0.10.205:3000`): `./scripts/push-mariadb-to-registry.sh`. It pulls the amd64 image from Docker Hub and pushes it to Gitea so the server only pulls from Gitea. + +### Proxy timeout (dial tcp 192.168.65.1:3128: i/o timeout) + +Docker is sending registry requests through an HTTP proxy; the proxy is not responding for traffic to your Gitea registry. **Bypass the proxy for the registry** on the machine where the error occurs (Dockge server or your dev machine): + +- **Environment:** Set `NO_PROXY` (or `no_proxy`) to include the registry host so it is not proxied, e.g. + `NO_PROXY=localhost,127.0.0.1,10.0.10.205` + or append: `NO_PROXY=$NO_PROXY,10.0.10.205` + Then restart the process (Dockge, Docker daemon, or your shell) that runs `docker pull`/`docker push`. + +- **Docker daemon (Linux server):** If the daemon uses a proxy, add the registry to `no_proxy` in the same place (e.g. `/etc/systemd/system/docker.service.d/http-proxy.conf`): + `Environment="no_proxy=localhost,127.0.0.1,10.0.10.205"` + Then `sudo systemctl daemon-reload` and `sudo systemctl restart docker`. + +- **Docker Desktop (Mac):** In Settings → Resources → Proxies, either disable the proxy or add `10.0.10.205` to “Bypass for these hosts”. diff --git a/scripts/docker-build-push.sh b/scripts/docker-build-push.sh index 99d8434..417dfa4 100755 --- a/scripts/docker-build-push.sh +++ b/scripts/docker-build-push.sh @@ -3,6 +3,7 @@ # One-time: docker login 10.0.10.205:3000 (username: bert.hausmans, password: token or password). # Usage: ./scripts/docker-build-push.sh [VERSION] # VERSION defaults to "latest" (or git describe --tags --always if available). +# Set PLATFORM=linux/arm64 if your Dockge server is ARM (e.g. Raspberry Pi). # Run from project root. set -e @@ -18,12 +19,14 @@ else VERSION=$(git describe --tags --always 2>/dev/null || echo "latest") fi -echo "Building and pushing images with tag: $VERSION" +# Build for linux/amd64 so images run on typical Dockge servers (avoid "no matching manifest" on ARM-built images) +PLATFORM="${PLATFORM:-linux/amd64}" +echo "Building and pushing images with tag: $VERSION (platform: $PLATFORM)" echo "Registry: $REGISTRY, Owner: $OWNER" echo "" for name in api admin upload; do - docker build -t "$REGISTRY/$OWNER/event-uploader-$name:$VERSION" "$ROOT/$name" + docker build --platform "$PLATFORM" -t "$REGISTRY/$OWNER/event-uploader-$name:$VERSION" "$ROOT/$name" docker push "$REGISTRY/$OWNER/event-uploader-$name:$VERSION" if [ "$VERSION" != "latest" ]; then docker tag "$REGISTRY/$OWNER/event-uploader-$name:$VERSION" "$REGISTRY/$OWNER/event-uploader-$name:latest"