mirror of
https://github.com/truecharts/charts.git
synced 2026-07-22 13:09:49 -03:00
48 lines
1.3 KiB
Docker
48 lines
1.3 KiB
Docker
# Stage 1 - Build the Go application
|
|
FROM golang:1.23.2-alpine@sha256:9dd2625a1ff2859b8d8b01d8f7822c0f528942fe56cfe7a1e7c38d3b8d72d679 AS builder
|
|
|
|
# Install necessary build dependencies
|
|
RUN apk --no-cache add --update gcc musl-dev
|
|
|
|
# Create the necessary directories
|
|
RUN mkdir -p /build /output
|
|
|
|
# Set the working directory
|
|
WORKDIR /build
|
|
|
|
# Copy go mod and sum files
|
|
COPY apps/kube-sa-proxy/go.mod apps/kube-sa-proxy/go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy the rest of the Go application source code
|
|
COPY apps/kube-sa-proxy/cmd/main.go .
|
|
COPY apps/kube-sa-proxy/internal/config ./internal/config
|
|
COPY apps/kube-sa-proxy/internal/proxy ./internal/proxy
|
|
COPY apps/kube-sa-proxy/internal/utils ./internal/utils
|
|
|
|
# Build the Go application
|
|
RUN go build -ldflags "-w -s" -o /output/my-proxy-service .
|
|
|
|
# Stage 2 - Create the final image
|
|
FROM alpine@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d AS runner
|
|
|
|
# Install necessary runtime dependencies
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy the binary from the builder stage
|
|
COPY --from=builder /output/my-proxy-service .
|
|
|
|
# Set environment variables
|
|
ENV PORT=3000
|
|
|
|
# Expose the port
|
|
EXPOSE $PORT
|
|
|
|
# Set the default command to run the binary
|
|
CMD sh -c "./my-proxy-service"
|