Skip to content

Commit

Permalink
Use commands to build docker images from package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
tobi1449 committed Jan 21, 2025
1 parent c912030 commit f87564f
Showing 1 changed file with 44 additions and 15 deletions.
59 changes: 44 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
types: [released]
workflow_dispatch:


jobs:
build-and-publish-image:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -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/#-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

0 comments on commit f87564f

Please # to comment.