docker-etchosts/Dockerfile
Patrick Kuijvenhoven 40daf21cf7 feat(docker): Improve Dockerfile
- include build process in Dockerfile
- use multistage build process
2024-06-25 13:53:15 +02:00

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"]