Initial commit

Signed-off-by: Thomas Klaehn <thomas.klaehn@perinet.io>
This commit is contained in:
Thomas Klaehn
2026-02-10 11:47:49 +01:00
commit c54fa58c35
17 changed files with 1834 additions and 0 deletions

51
Dockerfile Normal file
View 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"]