mirror of
https://github.com/Dvorinka/Bookra.git
synced 2026-06-04 04:22:59 +00:00
36 lines
630 B
Docker
36 lines
630 B
Docker
# Build stage
|
|
FROM golang:1.26.2-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache git
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o /app/auth-service ./cmd/api
|
|
|
|
# Final stage
|
|
FROM alpine:3.22
|
|
|
|
WORKDIR /app
|
|
|
|
# Install ca-certificates for HTTPS
|
|
RUN apk add --no-cache ca-certificates
|
|
|
|
# Copy binary from builder
|
|
COPY --from=builder /app/auth-service /app/
|
|
|
|
# Copy migrations
|
|
COPY --from=builder /app/migrations /app/migrations
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["/app/auth-service"]
|