go-mongo/Dockerfile
2025-05-31 18:38:18 +03:00

38 lines
657 B
Docker

# ---------- Build Stage ----------
FROM golang:1.24-alpine AS builder
# Set working directory
WORKDIR /app
# Install dependencies
RUN apk add --no-cache git
# Cache and install Go modules
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code
COPY . .
# Build the Go binary
RUN go build -o server .
# ---------- Final Stage ----------
FROM alpine:latest
# Install timezone data (optional)
RUN apk add --no-cache tzdata ca-certificates
# Set working directory
WORKDIR /root/
# Copy binary from builder
COPY --from=builder /app/server .
# Copy binary from builder
COPY --from=builder /app/model.conf .
# Run the binary
CMD ["./server"]