apg-go/Dockerfile
Winni Neessen 48a0b6763b
Modify Docker build process and workflow
The Docker build command in the GitHub workflow file (docker.yml) now requires sudo privileges. Additionally, the Dockerfile has been expanded to not only tidy up and verify the Go modules project but also to alter the build path for the "apg-go" executable.
2024-03-13 23:45:58 +01:00

23 lines
776 B
Docker

## Build first
FROM golang:latest AS builder
RUN mkdir /builddir
ADD . /builddir/
WORKDIR /builddir
RUN go mod tidy
RUN go mod download
RUN go mod verify
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags '-w -s -extldflags "-static"' -o apg-go \
src.neessen.cloud/wneessen/apg-go/cmd/apg
## Create scratch image
FROM scratch
LABEL maintainer="wn@neessen.dev"
COPY ["docker-files/passwd", "/etc/passwd"]
COPY ["docker-files/group", "/etc/group"]
COPY --from=builder ["/etc/ssl/certs/ca-certificates.crt", "/etc/ssl/cert.pem"]
COPY --chown=apg-go ["LICENSE", "/apg-go/LICENSE"]
COPY --chown=apg-go ["README.md", "/apg-go/README.md"]
COPY --from=builder --chown=apg-go ["/builddir/apg-go", "/apg-go/apg-go"]
WORKDIR /apg-go
USER apg-go
ENTRYPOINT ["/apg-go/apg-go"]