This commit is contained in:
2026-07-16 00:12:44 -07:00
commit f0dd3c52db
8 changed files with 362 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
# Build stage
FROM golang:1.26.5-alpine AS builder
WORKDIR /app
# Install git and ca-certificates (needed for go modules and HTTPS)
RUN apk add --no-cache git ca-certificates
# Copy dependency files first for better layer caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY *.go ./
# Build a static binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o backend .
# Runtime stage
FROM alpine:latest
WORKDIR /app
# Copy the binary from the builder stage
COPY --from=builder /app/backend .
# Expose the port Gin listens on
EXPOSE 8080
# Run the backend
CMD ["./backend"]