123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- # Build stage
- FROM golang:1.22.5-alpine AS builder
- # Install build dependencies
- RUN apk add --no-cache gcc musl-dev
- # Set working directory
- WORKDIR /app
- # Copy go mod and sum files
- COPY go.mod go.sum ./
- # Download dependencies
- RUN go mod download
- # Copy source code
- COPY . .
- # Build the application
- RUN CGO_ENABLED=1 GOOS=linux go build -a -o byom-trends .
- # Final stage
- FROM alpine:3.19
- # Install runtime dependencies
- RUN apk add --no-cache sqlite-libs ca-certificates tzdata
- # Create app directory
- WORKDIR /app
- # Copy binary from builder
- COPY --from=builder /app/byom-trends .
- COPY --from=builder /app/config.yaml .
- # Create data directory
- RUN mkdir -p /app/data
- # Set environment variables
- ENV GIN_MODE=release
- # Expose port
- EXPOSE 8080
- # Run the application
- CMD ["/app/byom-trends", "serve"]
|