From 8a0e8dfdf5e5a8b3472ec41f45a32be9c862f64d Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Thu, 8 Apr 2021 07:07:36 -0700 Subject: [PATCH] Add workflow to publish Docker image to dockerhub --- .github/workflows/docker-image-publish.yml | 44 ++++++++++++++++++++++ Dockerfile | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-image-publish.yml diff --git a/.github/workflows/docker-image-publish.yml b/.github/workflows/docker-image-publish.yml new file mode 100644 index 0000000..444e950 --- /dev/null +++ b/.github/workflows/docker-image-publish.yml @@ -0,0 +1,44 @@ +name: Publish Docker image +on: + push: + branches: + - "master" + tags: + - "v*" + pull_request: + branches: + - "master" +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Docker meta + id: meta + uses: crazy-max/ghaction-docker-meta@v2 + with: + images: hibiken/asynqmon + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index 07ee7ba..019e89c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ RUN go mod download COPY . . # Copy frontend static files from /static to the root folder of the backend container. -COPY --from=frontend ["/static/build", "/ui/build"] +COPY --from=frontend ["/static/build", "ui/build"] # Set necessary environmet variables needed for the image and build the server. ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64