Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Add ARM64 support and PUID/PGID environment variables in Docker run command (#5)

Aryaf8517d4d913c
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index 22ded387..e7538d9a 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -2,7 +2,7 @@ name: Build and Push Docker image to GHCR
on:
push:
- branches: [ main ] # Adjust to your default branch
+ branches: [ main ]
workflow_dispatch:
jobs:
@@ -11,22 +11,29 @@ jobs:
permissions:
contents: read
- packages: write # Required to push to GHCR
+ packages: write
steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Log in to GHCR
- uses: docker/login-action@v3
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- push: true
- tags: ghcr.io/${{ github.repository }}:pre-alpha
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Log in to GHCR
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Build and push Docker image (amd64 + arm64)
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ push: true
+ platforms: linux/amd64,linux/arm64
+ tags: ghcr.io/${{ github.repository }}:pre-alpha
diff --git a/Dockerfile b/Dockerfile
index e94f276f..ac258c99 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,30 +1,49 @@
-# Stage 1: Build frontend
-FROM node:alpine AS frontend-build
+# syntax=docker/dockerfile:1.4
+
+# -------- Stage 1: Build frontend --------
+FROM --platform=$BUILDPLATFORM node:alpine AS frontend-build
+
WORKDIR /frontend
COPY ./frontend ./
+
RUN npm install
RUN npm run build
RUN npm prune --omit=dev
-# Stage 2: Build backend
-FROM mcr.microsoft.com/dotnet/sdk:9.0 AS backend-build
+# -------- Stage 2: Build backend --------
+FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS backend-build
+
WORKDIR /backend
COPY ./backend ./
+
+# Accept build-time architecture as ARG (e.g., x64 or arm64)
+ARG TARGETARCH
RUN dotnet restore
-RUN dotnet publish -c Release -r linux-musl-x64 -o ./publish
+RUN dotnet publish -c Release -r linux-musl-${TARGETARCH} -o ./publish
-# Stage 3: Combined runtime
+# -------- Stage 3: Combined runtime image --------
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine
+
WORKDIR /app
-RUN mkdir /config
-RUN apk add --no-cache nodejs npm libc6-compat shadow su-exec bash
+
+# Prepare environment
+RUN mkdir /config \
+ && apk add --no-cache nodejs npm libc6-compat shadow su-exec bash
+
+# Copy frontend
COPY --from=frontend-build /frontend/node_modules ./frontend/node_modules
COPY --from=frontend-build /frontend/package.json ./frontend/package.json
COPY --from=frontend-build /frontend/server.js ./frontend/server.js
COPY --from=frontend-build /frontend/build ./frontend/build
+
+# Copy backend
COPY --from=backend-build /backend/publish ./backend
-EXPOSE 3000
-ENV NODE_ENV=production
+
+# Entry and runtime setup
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
+
+EXPOSE 3000
+ENV NODE_ENV=production
+
CMD ["/entrypoint.sh"]
diff --git a/README.md b/README.md
index d8f6bf38..fee332ff 100644
--- a/README.md
+++ b/README.md
@@ -37,6 +37,8 @@ And if you would like to persist saved settings, attach a volume at `/config`
mkdir -p $(pwd)/nzbdav && \
docker run --rm -it \
-v $(pwd)/nzbdav:/config \
+ -e PUID=1000 \
+ -e PGID=1000 \
-p 3000:3000 \
ghcr.io/nzbdav-dev/nzbdav:pre-alpha
```