2024-12-28 16:30:48 +01:00
|
|
|
# =========== 1) Build stage ===========
|
2025-08-14 23:25:01 +02:00
|
|
|
FROM golang:1.24-alpine AS builder
|
2024-12-28 16:30:48 +01:00
|
|
|
|
|
|
|
|
# Create and set working directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy go.mod and go.sum first, then download dependencies
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
|
|
# Copy the rest of the backend code
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# Build the Go binary
|
|
|
|
|
RUN go build -o server main.go
|
|
|
|
|
|
|
|
|
|
# =========== 2) Runtime stage ===========
|
|
|
|
|
FROM alpine:3.18
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy the compiled binary from builder stage
|
|
|
|
|
COPY --from=builder /app/server /app
|
|
|
|
|
|
2025-08-12 22:09:15 +02:00
|
|
|
# Expose port 8180 (backend port)
|
|
|
|
|
EXPOSE 8180
|
2024-12-28 16:30:48 +01:00
|
|
|
|
|
|
|
|
# Run the Go server
|
|
|
|
|
CMD ["./server"]
|