-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (23 loc) · 1021 Bytes
/
Copy pathDockerfile
File metadata and controls
33 lines (23 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
FROM alpine:3.21 AS build
RUN apk add --no-cache curl xz
RUN curl -fsSL https://ziglang.org/download/0.15.2/zig-x86_64-linux-0.15.2.tar.xz | tar -xJ -C /opt && \
ln -s /opt/zig-x86_64-linux-0.15.2/zig /usr/local/bin/zig
WORKDIR /src
COPY . .
RUN zig build -Doptimize=ReleaseFast
# ---
FROM alpine:3.21
RUN apk add --no-cache nginx && \
rm -rf /var/cache/apk/* /tmp/*
RUN addgroup -S publr && adduser -S publr -G publr -h /app -s /sbin/nologin && \
mkdir -p /app/data /run/nginx /var/lib/nginx /var/log/nginx && \
chown -R publr:publr /app /run/nginx /var/lib/nginx /var/log/nginx
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /src/zig-out/bin/publr /app/publr
COPY --from=build /src/data/publr.db /app/publr.db.seed
RUN chmod +x /app/publr && chown publr:publr /app/publr /app/publr.db.seed
USER publr
WORKDIR /app
VOLUME /app/data
EXPOSE 8080
ENTRYPOINT ["sh", "-c", "[ -f /app/data/publr.db ] || cp /app/publr.db.seed /app/data/publr.db; nginx && exec /app/publr serve --port 3000"]