mirror of
https://github.com/costela/docker-etchosts.git
synced 2025-05-10 17:35:41 +02:00
feat(docker): Improve Dockerfile
- include build process in Dockerfile - use multistage build process
This commit is contained in:
parent
bb55ee63a9
commit
40daf21cf7
1 changed files with 25 additions and 2 deletions
27
Dockerfile
27
Dockerfile
|
@ -1,3 +1,26 @@
|
|||
FROM scratch
|
||||
# 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"]
|
||||
COPY docker-etchosts /
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue