# Build stage FROM golang:1.21-bookworm AS builder # Install build dependencies RUN apt-get update && apt-get install -y \ gcc \ sqlite3 \ libsqlite3-dev \ && rm -rf /var/lib/apt/lists/* # 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 RUN CGO_ENABLED=1 go build -o mealprep -ldflags="-s -w" . # Runtime stage FROM debian:bookworm-slim # Install runtime dependencies RUN apt-get update && apt-get install -y \ ca-certificates \ sqlite3 \ libsqlite3-0 \ wget \ && rm -rf /var/lib/apt/lists/* # Create app directory and data directory WORKDIR /app RUN mkdir -p /app/data # Copy binary from builder COPY --from=builder /build/mealprep . # Copy static files COPY --from=builder /build/static ./static # Expose port EXPOSE 8080 # Set environment variables ENV DB_PATH=/app/data/mealprep.db # Run the application CMD ["./mealprep"]