mirror of
https://github.com/costela/docker-etchosts.git
synced 2025-05-10 17:35:41 +02:00
26 lines
529 B
Docker
26 lines
529 B
Docker
# syntax=docker/dockerfile:1
|
|
# Based on https://docs.docker.com/language/golang/build-images/#multi-stage-builds
|
|
|
|
# Build the application from source
|
|
FROM golang:1.22
|
|
|
|
WORKDIR /app
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY *.go ./
|
|
|
|
ARG CGO_ENABLED=0
|
|
ARG GOARCH=amd64
|
|
ARG GOOS=linux
|
|
RUN go build -ldflags '-s -w' -trimpath -o /docker-etchosts
|
|
|
|
# Deploy the application binary into a lean image
|
|
FROM scratch AS build-release-stage
|
|
|
|
WORKDIR /
|
|
|
|
COPY --from=0 /docker-etchosts /docker-etchosts
|
|
|
|
ENTRYPOINT ["/docker-etchosts"]
|