FROM golang:1.21-alpine AS builder WORKDIR /app # Install build dependencies RUN apk add --no-cache gcc musl-dev # Copy server code COPY server/ . # Download dependencies RUN go mod download # Build the server RUN CGO_ENABLED=1 GOOS=linux go build -o server -ldflags="-s -w" . # Final stage FROM alpine:3.19 RUN apk add --no-cache ca-certificates tzdata WORKDIR /app # Copy binary from builder COPY --from=builder /app/server . # Create data directory RUN mkdir -p /app/data # Expose port EXPOSE 8080 # Run the server CMD ["./server"]