From e27580465aab75a7ff79eb9b6f3904c10c7255a5 Mon Sep 17 00:00:00 2001 From: CrazyBolillo Date: Sat, 13 Jul 2024 09:06:10 -0600 Subject: [PATCH] ci: add docker image A docker image will be uploaded to github's registry on new releases, it is also built as part of the QA job to ensure no regressions. --- .dockerignore | 10 ++++++++++ .github/workflows/qa.yaml | 8 ++++++++ .github/workflows/release.yaml | 21 +++++++++++++++++++++ Dockerfile | 14 ++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..bf29d1e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +docs/ +dist/ +.github/ + +.dockerignore +.gitignore + +Makefile +README.md +LICENSE diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index 43d05e7..1bd2d9c 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -26,3 +26,11 @@ jobs: run: sqlc vet - name: Diff run: sqlc diff + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/build-push-action@v5 + with: + context: . + push: false diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e024070..79667b4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,3 +21,24 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/crazybolillo/eryth + - uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..12450a1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.22 + +WORKDIR /app + +COPY . . + +ENV CGO_ENABLED=0 +RUN go build -o /bin/eryth ./cmd + +FROM scratch + +COPY --from=0 /bin/eryth /bin/eryth + +ENTRYPOINT ["eryth"]