Files

42 lines
728 B
Docker

# Build stage
FROM golang:1.24-alpine AS builder
# Install dependencies
RUN apk add --no-cache git
# Set working directory
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o auth-server ./auth/cmd/server
# Final stage
FROM alpine:latest
# Install ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates
# Create app directory
WORKDIR /root/
# Copy the binary from builder stage
COPY --from=builder /app/auth-server .
# Expose port
EXPOSE 8081
# Environment variables with defaults
ENV PORT=8081
# Run the binary
CMD ["./auth-server"]