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.
This commit is contained in:
Winni Neessen 2024-03-13 23:45:58 +01:00
parent 7da9c71983
commit 48a0b6763b
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D
2 changed files with 6 additions and 3 deletions

View file

@ -19,7 +19,7 @@ jobs:
run: | run: |
apt-get update; apt-get -y install docker; which docker apt-get update; apt-get -y install docker; which docker
- name: Build the Docker image - name: Build the Docker image
run: docker build --no-cache --force-rm -t apg-go:main . run: sudo docker build --no-cache --force-rm -t apg-go:main .
test: test:
runs-on: docker runs-on: docker
steps: steps:

View file

@ -3,8 +3,11 @@ FROM golang:latest AS builder
RUN mkdir /builddir RUN mkdir /builddir
ADD . /builddir/ ADD . /builddir/
WORKDIR /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 \ RUN CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags '-w -s -extldflags "-static"' -o apg-go \
github.com/wneessen/apg-go/cmd/apg src.neessen.cloud/wneessen/apg-go/cmd/apg
## Create scratch image ## Create scratch image
FROM scratch FROM scratch
@ -17,4 +20,4 @@ COPY --chown=apg-go ["README.md", "/apg-go/README.md"]
COPY --from=builder --chown=apg-go ["/builddir/apg-go", "/apg-go/apg-go"] COPY --from=builder --chown=apg-go ["/builddir/apg-go", "/apg-go/apg-go"]
WORKDIR /apg-go WORKDIR /apg-go
USER apg-go USER apg-go
ENTRYPOINT ["/apg-go/apg-go"] ENTRYPOINT ["/apg-go/apg-go"]