Skip to content

Commit f8517d4

Browse files
authored
Add ARM64 support and PUID/PGID environment variables in Docker run command (#5)
* Update docker-publish.yml * Update Dockerfile * Update README.md * switch to node:alpine
1 parent c75db58 commit f8517d4

File tree

3 files changed

+56
-28
lines changed

3 files changed

+56
-28
lines changed

.github/workflows/docker-publish.yml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build and Push Docker image to GHCR
22

33
on:
44
push:
5-
branches: [ main ] # Adjust to your default branch
5+
branches: [ main ]
66
workflow_dispatch:
77

88
jobs:
@@ -11,22 +11,29 @@ jobs:
1111

1212
permissions:
1313
contents: read
14-
packages: write # Required to push to GHCR
14+
packages: write
1515

1616
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v4
19-
20-
- name: Log in to GHCR
21-
uses: docker/login-action@v3
22-
with:
23-
registry: ghcr.io
24-
username: ${{ github.actor }}
25-
password: ${{ secrets.GITHUB_TOKEN }}
26-
27-
- name: Build and push Docker image
28-
uses: docker/build-push-action@v5
29-
with:
30-
context: .
31-
push: true
32-
tags: ghcr.io/${{ github.repository }}:pre-alpha
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Log in to GHCR
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Build and push Docker image (amd64 + arm64)
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
push: true
38+
platforms: linux/amd64,linux/arm64
39+
tags: ghcr.io/${{ github.repository }}:pre-alpha

Dockerfile

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,49 @@
1-
# Stage 1: Build frontend
2-
FROM node:alpine AS frontend-build
1+
# syntax=docker/dockerfile:1.4
2+
3+
# -------- Stage 1: Build frontend --------
4+
FROM --platform=$BUILDPLATFORM node:alpine AS frontend-build
5+
36
WORKDIR /frontend
47
COPY ./frontend ./
8+
59
RUN npm install
610
RUN npm run build
711
RUN npm prune --omit=dev
812

9-
# Stage 2: Build backend
10-
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS backend-build
13+
# -------- Stage 2: Build backend --------
14+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS backend-build
15+
1116
WORKDIR /backend
1217
COPY ./backend ./
18+
19+
# Accept build-time architecture as ARG (e.g., x64 or arm64)
20+
ARG TARGETARCH
1321
RUN dotnet restore
14-
RUN dotnet publish -c Release -r linux-musl-x64 -o ./publish
22+
RUN dotnet publish -c Release -r linux-musl-${TARGETARCH} -o ./publish
1523

16-
# Stage 3: Combined runtime
24+
# -------- Stage 3: Combined runtime image --------
1725
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine
26+
1827
WORKDIR /app
19-
RUN mkdir /config
20-
RUN apk add --no-cache nodejs npm libc6-compat shadow su-exec bash
28+
29+
# Prepare environment
30+
RUN mkdir /config \
31+
&& apk add --no-cache nodejs npm libc6-compat shadow su-exec bash
32+
33+
# Copy frontend
2134
COPY --from=frontend-build /frontend/node_modules ./frontend/node_modules
2235
COPY --from=frontend-build /frontend/package.json ./frontend/package.json
2336
COPY --from=frontend-build /frontend/server.js ./frontend/server.js
2437
COPY --from=frontend-build /frontend/build ./frontend/build
38+
39+
# Copy backend
2540
COPY --from=backend-build /backend/publish ./backend
26-
EXPOSE 3000
27-
ENV NODE_ENV=production
41+
42+
# Entry and runtime setup
2843
COPY entrypoint.sh /entrypoint.sh
2944
RUN chmod +x /entrypoint.sh
45+
46+
EXPOSE 3000
47+
ENV NODE_ENV=production
48+
3049
CMD ["/entrypoint.sh"]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ And if you would like to persist saved settings, attach a volume at `/config`
3737
mkdir -p $(pwd)/nzbdav && \
3838
docker run --rm -it \
3939
-v $(pwd)/nzbdav:/config \
40+
-e PUID=1000 \
41+
-e PGID=1000 \
4042
-p 3000:3000 \
4143
ghcr.io/nzbdav-dev/nzbdav:pre-alpha
4244
```

0 commit comments

Comments
 (0)