From 63f2af9661bb0d698cec187e0f352a0911b203e7 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Fri, 3 Nov 2023 22:35:22 +0600 Subject: [PATCH 1/3] :contruction: Trying to make a docker build action --- .gitea/workflows/build-image.yaml | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .gitea/workflows/build-image.yaml diff --git a/.gitea/workflows/build-image.yaml b/.gitea/workflows/build-image.yaml new file mode 100644 index 0000000..aa9dd1c --- /dev/null +++ b/.gitea/workflows/build-image.yaml @@ -0,0 +1,36 @@ +--- +name: Create and publish a Docker image +on: + publish: + branches: + - master + - develop + - release + push: + tags: + - v* + +env: + REGISTRY: source.toby3d.me + IMAGE_NAME: ${{ gitea.repository }} + +jobs: + build-image: + runs-on: ubuntu-latest + env: + DOCKER_USERNAME: toby3d + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker BuildX + uses: docker/setup-buildx-action@v3 + - name: Login to registry + uses: docker/login-action@v3 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + tags: user/app:latest From eb9a5017a73d94360a37a65bd3f290c099a197f3 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Sun, 5 Nov 2023 02:59:55 +0600 Subject: [PATCH 2/3] :whale: Build and push docker container --- .gitea/workflows/build-image.yaml | 42 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/.gitea/workflows/build-image.yaml b/.gitea/workflows/build-image.yaml index aa9dd1c..43fb68e 100644 --- a/.gitea/workflows/build-image.yaml +++ b/.gitea/workflows/build-image.yaml @@ -1,36 +1,44 @@ --- -name: Create and publish a Docker image on: - publish: + push: branches: - master - develop - - release - push: - tags: - - v* env: - REGISTRY: source.toby3d.me - IMAGE_NAME: ${{ gitea.repository }} + DOCKER_REGISTRY: source.toby3d.me jobs: - build-image: + docker: runs-on: ubuntu-latest - env: - DOCKER_USERNAME: toby3d + container: + image: catthehacker/ubuntu:act-latest + permissions: + contents: read + packages: write steps: + - name: Checkout + uses: https://gitea.com/actions/checkout@v3 + - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: https://gitea.com/docker/setup-qemu-action@v2 + - name: Set up Docker BuildX - uses: docker/setup-buildx-action@v3 + uses: https://gitea.com/docker/setup-buildx-action@v2 + - name: Login to registry - uses: docker/login-action@v3 + uses: https://gitea.com/docker/login-action@v2 with: - username: ${{ env.DOCKER_USERNAME }} + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ gitea.repository_owner }} password: ${{ secrets.DOCKER_TOKEN }} + - name: Build and push - uses: docker/build-push-action@v5 + uses: https://gitea.com/docker/build-push-action@v4 + env: + ACTIONS_RUNTIME_TOKEN: "" # See https://gitea.com/gitea/act_runner/issues/119 with: + context: . + file: ./build/Dockerfile push: true - tags: user/app:latest + tags: ${{ env.DOCKER_REGISTRY }}/${{ gitea.repository }}:${{ gitea.ref_name }} From 6367abc9d8c5261fcc2bcb9fb551527d7e4c8345 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Mon, 6 Nov 2023 04:30:52 +0600 Subject: [PATCH 3/3] :whale: Added VCS flag in container building step --- build/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Dockerfile b/build/Dockerfile index 1ce9737..601b16f 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -7,7 +7,7 @@ FROM golang:alpine AS builder WORKDIR /app ENV CGO_ENABLED=0 -ENV GOFLAGS=-mod=vendor +ENV GOFLAGS="-mod=vendor -buildvcs=true" COPY go.mod go.sum *.go ./ COPY internal ./internal/