From f87564fbf732bb19edd1fe1748c0e4ddf5d8a881 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 21 Jan 2025 22:08:46 +0100 Subject: [PATCH] Use commands to build docker images from package.json --- .github/workflows/publish.yml | 59 ++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6e532ea3..52ce1719 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,7 +8,6 @@ on: types: [released] workflow_dispatch: - jobs: build-and-publish-image: runs-on: ubuntu-latest @@ -49,21 +48,51 @@ jobs: - name: Check Typescript run: pnpm run check-ts - - name: Build Docker image - run: docker build . --file docker/Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" - - name: Log in to registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Push image - run: | - IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - [ "$VERSION" == "main" ] && VERSION=latest - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 # Specify the Node.js version required for env2arg.js + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ secrets.GITHUB_ACTOR }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push base Docker image + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 + file: ./docker/Base.Dockerfile + push: true + tags: ghcr.io/tobi1449/dockge:base + + - name: Build and publish health-check Docker image + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 + file: ./docker/BuildHealthCheck.Dockerfile + push: true + tags: ghcr.io/tobi1449/dockge:build-healthcheck + + - name: Build and publish main Docker Image + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 + file: ./docker/Dockerfile + push: true + # Substitute the values from env2arg.js into the Docker command + tags: | + ghcr.io/tobi1449/dockge:latest + ghcr.io/tobi1449/dockge:$VERSION + target: release