p1-logger/Dockerfile
Pieter Hollander 8a370d7767
Some checks failed
Build Docker image / build (push) Failing after 44s
Rename app.
2023-12-05 17:43:23 +01:00

26 lines
708 B
Docker

# Use buildx for multi-architecture support
FROM --platform=${BUILDPLATFORM} golang:1.21 AS builder
WORKDIR /app
# Copy go.mod and go.sum files to download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code into the container
COPY . .
# Build the application for the specified target architecture
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o mqtt-postgresql .
# Create a minimal runtime image
FROM --platform=${TARGETPLATFORM} scratch
WORKDIR /app
# Copy the executable from the builder stage
COPY --from=builder /app/p1-logger /app/p1-logger
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Run the application
CMD ["./p1-logger"]