diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..61d6a76 --- /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