Files
PixivFE/Dockerfile
T
perennial ba6f2c78a1 Docker: Update config and simplify deployment
- Update Dockerfile to use golang 1.23.1 with Alpine
- Switch base image to scratch
- Replace docker-compose.yml with compose.yaml and update configuration
- Remove unnecessary files (entrypoint.sh, pixivfe_token.txt)
- Simplify token management
- Update documentation
2024-09-12 01:37:25 +10:00

40 lines
992 B
Docker

# Use the official Alpine-based golang image as a parent image
FROM golang:1.23.1-alpine3.20 AS builder
WORKDIR /app
# Copy the current directory contents into the container
COPY . .
# Build the application
RUN go mod download && \
CGO_ENABLED=0 go build -v -ldflags="-extldflags=-static" -tags netgo -a -o pixivfe
# Stage for creating the non-privileged user
FROM alpine:3.20 AS user-stage
RUN adduser -u 10001 -S pixivfe
# Stage for a smaller final image
FROM scratch
# Copy necessary files from the builder stage
COPY --from=builder /app/pixivfe /app/pixivfe
COPY --from=builder /app/assets /app/assets
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Copy passwd file for the non-privileged user from the user-stage
COPY --from=user-stage /etc/passwd /etc/passwd
# Set the working directory
WORKDIR /app
# Expose port 8282
EXPOSE 8282
# Switch to non-privileged user
USER pixivfe
# Set the entrypoint to the binary name
ENTRYPOINT ["/app/pixivfe"]