31 lines
566 B
Docker
31 lines
566 B
Docker
# Build stage
|
|
FROM golang:1.25-alpine AS builder
|
|
|
|
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 apiserver ./cmd/apiserver
|
|
|
|
# Final stage
|
|
FROM alpine:latest
|
|
|
|
WORKDIR /root/
|
|
|
|
# Copy binary from builder stage
|
|
COPY --from=builder /app/apiserver .
|
|
COPY --from=builder /app/configs ./configs
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Run the application
|
|
CMD ["./apiserver", "--config-path=./configs/server.toml"] |