From 9390edb49e90d410d670e5af33027ff24dbfd1e2 Mon Sep 17 00:00:00 2001 From: Jumpy Squirrel Date: Sat, 7 Oct 2023 12:59:21 +0200 Subject: [PATCH 1/2] feat(#44): add Docker build and publish --- .github/workflows/docker.yml | 22 ++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 18 ++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..82d0296 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,22 @@ +name: Create and publish Docker image + +on: + push: + branches: + - 'main' + +jobs: + call_build-and-push-image: + permissions: + contents: read + packages: write + uses: eurofurence/reg-workflows/.github/workflows/docker-build-push.yml@main + with: + image-name: ${{ github.repository }} + image-tags: latest + full-repo-url: https://github.com/${{ github.repository }} + branch-or-tag-name: ${{ github.ref_name }} + commit-hash: ${{ github.sha }} + registry-user: ${{ github.actor }} + secrets: + registry-pass: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index b3ae626..0d8eeda 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ target config.yaml *.http **/*.jar +api-generator # Remove this line when implementing custom tools tools/cmd/** \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9979cc6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM golang:1 as build + +COPY . /app +WORKDIR /app + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" cmd/reg-room-service/main.go + +RUN chmod 755 main + +FROM scratch + +COPY --from=build /app/main /main +COPY --from=build /etc/ssl/certs /etc/ssl/certs + +# run as an unprivileged unnamed user that has no write permissions on the binary +USER 8877 + +ENTRYPOINT ["/main"] \ No newline at end of file From a8ed9d4acbf34f992dac2b12cd70e3b6e4d91c36 Mon Sep 17 00:00:00 2001 From: Jumpy Squirrel Date: Sat, 7 Oct 2023 13:39:58 +0200 Subject: [PATCH 2/2] fix(#44): Update .github/workflows/docker.yml Co-authored-by: Ludwig --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 82d0296..61d6a76 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,7 +6,7 @@ on: - 'main' jobs: - call_build-and-push-image: + call-build-and-push-image: permissions: contents: read packages: write