36 lines
646 B
Docker
36 lines
646 B
Docker
# Build stage
|
|
FROM golang:1.24-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache git
|
|
|
|
# Copy go mod and sum files from backend
|
|
COPY backend/go.mod backend/go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy backend source code
|
|
COPY backend/ .
|
|
|
|
# Build the Go app
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o api cmd/api/main.go
|
|
|
|
# Production stage
|
|
FROM alpine:latest
|
|
|
|
WORKDIR /app
|
|
|
|
# Install ca-certificates for HTTPS requests
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
# Copy the binary from builder
|
|
COPY --from=builder /app/api .
|
|
|
|
# Dokku sets PORT dynamically
|
|
EXPOSE 5000
|
|
|
|
# Run the binary
|
|
CMD ["./api"]
|