From eea179643a9fb2727144a27f3ac3e23fc5877400 Mon Sep 17 00:00:00 2001 From: motatoes Date: Wed, 17 Apr 2024 19:11:21 +0100 Subject: [PATCH 1/5] add tasks docker --- .github/workflows/tasks_release.yml | 46 +++++++++++++++++++++++++++++ Dockerfile_tasks | 40 +++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 .github/workflows/tasks_release.yml create mode 100644 Dockerfile_tasks diff --git a/.github/workflows/tasks_release.yml b/.github/workflows/tasks_release.yml new file mode 100644 index 000000000..1d798761d --- /dev/null +++ b/.github/workflows/tasks_release.yml @@ -0,0 +1,46 @@ +name: Backend Publish docker image + +on: + release: + types: ['released'] + push: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}_tasks + +jobs: + build-and-push-image: + if: (startswith(github.event.release.tag_name, 'v')) + + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@5f4866a30a54f16a52d2ecb4a3898e9e424939cf + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5.5.1 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5.3.0 + with: + context: . + file: "Dockerfile_tasks" + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile_tasks b/Dockerfile_tasks new file mode 100644 index 000000000..f4662ea23 --- /dev/null +++ b/Dockerfile_tasks @@ -0,0 +1,40 @@ +FROM golang:1.22 as builder +ARG COMMIT_SHA +RUN echo "commit sha: ${COMMIT_SHA}" + +# Set the working directory +WORKDIR $GOPATH/src/github.com/diggerhq/digger + +# Copy all required source, blacklist files that are not required through `.dockerignore` +COPY . . + +# Get the vendor library +RUN go version + +# RUN vgo install + +# https://github.com/ethereum/go-ethereum/issues/2738 +# Build static binary "-getmode=vendor" does not work with go-ethereum + +RUN go build -ldflags="-X 'main.Version=${COMMIT_SHA}'" -o tasks_exe ./backend/tasks + +# Multi-stage build will just copy the binary to an alpine image. +FROM ubuntu:22.04 as runner +ENV ATLAS_VERSION v0.16.0 +ARG COMMIT_SHA +WORKDIR /app + +RUN apt-get update && apt-get install -y ca-certificates curl && apt-get install -y git && apt-get clean all +RUN update-ca-certificates + +RUN echo "commit sha: ${COMMIT_SHA}" + +# install atlas +RUN curl -sSf https://atlasgo.sh | sh + + +# Copy the binary to the corresponding folder +COPY --from=builder /go/src/github.com/diggerhq/digger/tasks_exe /app/tasks + +# Run the binary +ENTRYPOINT ["/app/tasks"] From 6b59b1fd4e8c2feeb50b0bd9036265e69316e85d Mon Sep 17 00:00:00 2001 From: motatoes Date: Wed, 17 Apr 2024 19:15:35 +0100 Subject: [PATCH 2/5] rename --- .github/workflows/tasks_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tasks_release.yml b/.github/workflows/tasks_release.yml index 1d798761d..c8ccb3170 100644 --- a/.github/workflows/tasks_release.yml +++ b/.github/workflows/tasks_release.yml @@ -1,4 +1,4 @@ -name: Backend Publish docker image +name: Tasks Publish docker image on: release: From 2cccbc2c4373c1db705ea7891dde3781d16c10d3 Mon Sep 17 00:00:00 2001 From: motatoes Date: Wed, 17 Apr 2024 19:16:34 +0100 Subject: [PATCH 3/5] unskip --- .github/workflows/tasks_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tasks_release.yml b/.github/workflows/tasks_release.yml index c8ccb3170..cc92ac50e 100644 --- a/.github/workflows/tasks_release.yml +++ b/.github/workflows/tasks_release.yml @@ -11,7 +11,7 @@ env: jobs: build-and-push-image: - if: (startswith(github.event.release.tag_name, 'v')) +# if: (startswith(github.event.release.tag_name, 'v')) runs-on: ubuntu-latest From caf1d23708a10d214822b8f99bab07dc088b8c38 Mon Sep 17 00:00:00 2001 From: motatoes Date: Wed, 17 Apr 2024 20:11:21 +0100 Subject: [PATCH 4/5] .github --- .github/workflows/tasks_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tasks_release.yml b/.github/workflows/tasks_release.yml index cc92ac50e..c8ccb3170 100644 --- a/.github/workflows/tasks_release.yml +++ b/.github/workflows/tasks_release.yml @@ -11,7 +11,7 @@ env: jobs: build-and-push-image: -# if: (startswith(github.event.release.tag_name, 'v')) + if: (startswith(github.event.release.tag_name, 'v')) runs-on: ubuntu-latest From 2d22f3a21678efa864db2ccfbbc33244035de521 Mon Sep 17 00:00:00 2001 From: motatoes Date: Wed, 17 Apr 2024 20:11:35 +0100 Subject: [PATCH 5/5] add conditional --- .github/workflows/tasks_release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tasks_release.yml b/.github/workflows/tasks_release.yml index c8ccb3170..cbcdfd489 100644 --- a/.github/workflows/tasks_release.yml +++ b/.github/workflows/tasks_release.yml @@ -3,7 +3,6 @@ name: Tasks Publish docker image on: release: types: ['released'] - push: env: REGISTRY: ghcr.io