From 42372da7a13560e989bd2237ce65e49f7f1d5779 Mon Sep 17 00:00:00 2001 From: nourbalaha Date: Fri, 6 Dec 2024 12:33:46 +0900 Subject: [PATCH] wip: dockerfile and build_worker --- .github/workflows/build_worker.yml | 10 +++++++--- worker/Dockerfile | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_worker.yml b/.github/workflows/build_worker.yml index 414711de6..543d59ad3 100644 --- a/.github/workflows/build_worker.yml +++ b/.github/workflows/build_worker.yml @@ -16,11 +16,14 @@ on: required: true DOCKERHUB_TOKEN: required: true + push: + branches: + - change-worker-docker-context jobs: docker: runs-on: ubuntu-latest - if: inputs.name || inputs.new_tag + if: github.ref == 'refs/heads/change-worker-docker-context' || inputs.name || inputs.new_tag env: IMAGE_NAME: reearth/reearth-cms-worker steps: @@ -62,6 +65,7 @@ jobs: - name: Build and push docker image uses: docker/build-push-action@v6 with: + context: .. file: ./worker/Dockerfile platforms: ${{ steps.options.outputs.platforms }} push: true @@ -72,7 +76,7 @@ jobs: docker_decompressor: runs-on: ubuntu-latest - if: inputs.name || inputs.new_tag + if: github.ref == 'refs/heads/change-worker-docker-context' || inputs.name || inputs.new_tag env: IMAGE_NAME: reearth/reearth-cms-decompressor steps: @@ -114,7 +118,7 @@ jobs: - name: Build and push docker image uses: docker/build-push-action@v6 with: - context: ./worker + context: .. file: ./worker/decompressor.Dockerfile platforms: ${{ steps.options.outputs.platforms }} push: true diff --git a/worker/Dockerfile b/worker/Dockerfile index f39ceefff..73c6aff8d 100644 --- a/worker/Dockerfile +++ b/worker/Dockerfile @@ -1,14 +1,19 @@ FROM golang:1.23.3-alpine AS build + ARG TAG=release -ARG REV ARG VERSION RUN apk add --update --no-cache git ca-certificates build-base -COPY go.work go.work.sum server/go.mod server/go.sum server/main.go worker/go.mod worker/go.sum worker/main.go /app/ +COPY go.work go.work.sum /app/ +COPY server/go.mod server/go.sum server/main.go /app/server/ +COPY worker/go.mod worker/go.sum worker/main.go /app/worker/ + WORKDIR /app + RUN go mod download +COPY server/pkg/ /app/server/pkg/ COPY worker/cmd/ /app/worker/cmd/ COPY worker/internal/ /app/worker/internal/ COPY worker/pkg/ /app/worker/pkg/ @@ -18,7 +23,7 @@ RUN CGO_ENABLED=0 go build -tags "${TAG}" "-ldflags=-X main.version=${VERSION} - FROM scratch COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=build /app/worker/reearth-cms-worker /app/reearth-cms-worker +COPY --from=build /app/reearth-cms-worker /app/reearth-cms-worker WORKDIR /app