- Add multi-stage Dockerfile with Alpine Linux for minimal image size - Include docker-compose.yml for simplified deployment with volume persistence - Add .dockerignore to exclude unnecessary files from build context - Update main.go to support DATABASE_PATH environment variable - Update README to promote Docker as the recommended deployment method - Use non-root user in container for improved security - Final image size ~38MB with all dependencies Docker deployment now available via: docker-compose up -d or docker build -t alpenqueue . docker run -d -p 8080:8080 -v alpenqueue-data:/app/data alpenqueue 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
51 lines
1.1 KiB
Docker
51 lines
1.1 KiB
Docker
# Multi-stage build for smaller final image
|
|
FROM golang:1.25-alpine AS builder
|
|
|
|
# Install build dependencies for CGO (required for SQLite)
|
|
RUN apk add --no-cache gcc musl-dev sqlite-dev
|
|
|
|
# Set working directory
|
|
WORKDIR /build
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application with CGO enabled for SQLite
|
|
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o alpenqueue ./cmd/alpenqueue
|
|
|
|
# Final stage - minimal image
|
|
FROM alpine:latest
|
|
|
|
# Install runtime dependencies
|
|
RUN apk --no-cache add ca-certificates sqlite-libs
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S alpenqueue && \
|
|
adduser -u 1001 -S alpenqueue -G alpenqueue
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy binary from builder
|
|
COPY --from=builder /build/alpenqueue .
|
|
|
|
# Create directory for SQLite database
|
|
RUN mkdir -p /app/data && chown -R alpenqueue:alpenqueue /app
|
|
|
|
# Switch to non-root user
|
|
USER alpenqueue
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Volume for persistent data
|
|
VOLUME ["/app/data"]
|
|
|
|
# Run the application
|
|
CMD ["./alpenqueue"] |