34 lines
702 B
Docker
34 lines
702 B
Docker
# Stage 1: Build the Go binary
|
|
FROM golang:1.21-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy go.mod and go.sum to download dependencies
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# Copy the rest of the source code
|
|
COPY . .
|
|
|
|
# Build the config service
|
|
WORKDIR /app/pkg/config
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /app/server .
|
|
|
|
# Stage 2: Create the final minimal image
|
|
FROM alpine:latest
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy the binary from the builder stage
|
|
COPY --from=builder /app/server .
|
|
|
|
# Copy the settings and shared config files
|
|
COPY ./pkg/config/settings.toml .
|
|
COPY ./pkg/config/shared_config.toml .
|
|
|
|
# Expose the port the service listens on
|
|
EXPOSE 8081
|
|
|
|
# Command to run the service
|
|
CMD ["/app/server"]
|