diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ef70162 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,22 @@ +# Keep the build context to source. The important one is node_modules: the Dockerfile runs `COPY . .` after +# `npm ci`, so a host node_modules (Windows/macOS/x86 binaries) would overwrite the container's own and break the +# build — most visibly when cross-building for arm64. +**/node_modules +**/dist +**/build +**/*.tsbuildinfo + +# Never send secrets or data into a build. +.env +.env.* +!.env.example +data + +.git +.gitignore +.claude +*.log +.DS_Store + +# Compose files aren't needed inside the image. +docker-compose*.yml diff --git a/.env.example b/.env.example index 3488b99..b42f546 100644 --- a/.env.example +++ b/.env.example @@ -13,6 +13,10 @@ CREDENTIALS_ENCRYPTION_KEY=change-me-to-a-random-64-char-hex-string # Port docker-compose publishes on the host (container always listens on 3000). HOST_PORT=3000 +# Optional, for the arm64 compose files (docker-compose.arm64*.yml): registry image and tag. +#IMAGE_REPO=gitea.labsconnect.se/bobban/homelabmanager-homelab-manager +#ARM64_TAG=arm64 + # --- Authentik OIDC application/provider --- # Create an OAuth2/OIDC "Provider" in Authentik with: # Redirect URI: /auth/callback diff --git a/README.md b/README.md index 74e856d..18544df 100644 --- a/README.md +++ b/README.md @@ -255,3 +255,27 @@ docker compose up -d The app listens on `HOST_PORT` (default `3000`); SQLite data persists in `./data` on the host. + +### arm64 (Raspberry Pi, Apple silicon, ARM servers) + +Two compose files, one to build the image and one to run the published one: + +```bash +# On any machine with Docker: build the arm64 image and push it to the registry +docker compose -f docker-compose.arm64.build.yml build +docker compose -f docker-compose.arm64.build.yml push + +# On the arm64 machine: pull that image and run it (no build there) +docker compose -f docker-compose.arm64.yml pull +docker compose -f docker-compose.arm64.yml up -d +``` + +`docker-compose.arm64.build.yml` can also build and run right on an arm64 machine +(`up -d --build`). Building on x86 goes through QEMU emulation — slower, and it needs +a one-time `docker run --privileged --rm tonistiigi/binfmt --install arm64`. + +Both files use the image `gitea.labsconnect.se/bobban/homelabmanager-homelab-manager:arm64`. +Set `IMAGE_REPO` and/or `ARM64_TAG` in `.env` to use another registry or to pin a release +tag (e.g. `ARM64_TAG=1.4.0-arm64`). The arm64 tag is kept separate from the default image, +so the existing `docker-compose.yml` is unaffected. A `.dockerignore` keeps host +`node_modules`, `.env` and `data/` out of the build. diff --git a/docker-compose.arm64.build.yml b/docker-compose.arm64.build.yml new file mode 100644 index 0000000..2e11258 --- /dev/null +++ b/docker-compose.arm64.build.yml @@ -0,0 +1,33 @@ +# Builds the arm64 image from source (Raspberry Pi, Apple silicon, Ampere/Graviton, ...). +# +# Build and publish it, so docker-compose.arm64.yml can pull it on the arm64 machine: +# docker compose -f docker-compose.arm64.build.yml build +# docker compose -f docker-compose.arm64.build.yml push +# +# Or build and run it right here on an arm64 machine: +# docker compose -f docker-compose.arm64.build.yml up -d --build +# +# Building on an x86 machine works too, through QEMU emulation (slower). One-time setup: +# docker run --privileged --rm tonistiigi/binfmt --install arm64 +# Needs Docker Compose v2 with buildx (bundled with current Docker Desktop and Docker Engine). + +services: + homelab-manager: + build: + context: . + platforms: + - linux/arm64 + platform: linux/arm64 + # Same image name and tag docker-compose.arm64.yml pulls. Override with IMAGE_REPO / ARM64_TAG in .env or the shell. + image: ${IMAGE_REPO:-gitea.labsconnect.se/bobban/homelabmanager-homelab-manager}:${ARM64_TAG:-arm64} + container_name: homelab-manager + restart: unless-stopped + ports: + - "${HOST_PORT:-3000}:3000" + env_file: + - .env + environment: + PORT: 3000 + NODE_ENV: production + volumes: + - ./data:/app/data diff --git a/docker-compose.arm64.yml b/docker-compose.arm64.yml new file mode 100644 index 0000000..4db3834 --- /dev/null +++ b/docker-compose.arm64.yml @@ -0,0 +1,24 @@ +# Runs the published arm64 image from the registry — no build on this machine. +# (Publish it first with docker-compose.arm64.build.yml, or from CI.) +# +# docker compose -f docker-compose.arm64.yml pull +# docker compose -f docker-compose.arm64.yml up -d +# +# Update later with the same two commands. + +services: + homelab-manager: + # Override with IMAGE_REPO / ARM64_TAG in .env or the shell — e.g. ARM64_TAG=1.4.0-arm64 to pin a release. + image: ${IMAGE_REPO:-gitea.labsconnect.se/bobban/homelabmanager-homelab-manager}:${ARM64_TAG:-arm64} + platform: linux/arm64 + container_name: homelab-manager + restart: unless-stopped + ports: + - "${HOST_PORT:-3000}:3000" + env_file: + - .env + environment: + PORT: 3000 + NODE_ENV: production + volumes: + - ./data:/app/data