51
Dockerfile
Normal file
51
Dockerfile
Normal file
@@ -0,0 +1,51 @@
|
||||
# Build stage
|
||||
FROM golang:1.25-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache git ca-certificates tzdata
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the binary
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o zwift-monitor .
|
||||
|
||||
# Final stage
|
||||
FROM alpine:latest
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy binary from builder
|
||||
COPY --from=builder /app/zwift-monitor .
|
||||
|
||||
# Create data directory
|
||||
RUN mkdir -p /data/activities
|
||||
|
||||
# Run as non-root user
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
RUN chown -R appuser:appgroup /app /data
|
||||
USER appuser
|
||||
|
||||
# Set default environment variables
|
||||
ENV ZWIFT_OUTPUT_DIR=/data/activities \
|
||||
ZWIFT_STATE_FILE=/data/zwift-state.json \
|
||||
ZWIFT_TOKEN_CACHE=/data/.zwift-token.json \
|
||||
ZWIFT_POLL_INTERVAL=5m \
|
||||
ZWIFT_LOG_LEVEL=info \
|
||||
ZWIFT_RATE_LIMIT=5 \
|
||||
ZWIFT_MAX_RETRIES=3
|
||||
|
||||
# Expose volume for data
|
||||
VOLUME ["/data"]
|
||||
|
||||
# Run the service
|
||||
CMD ["/app/zwift-monitor"]
|
||||
Reference in New Issue
Block a user