Skip to content

Commit

Permalink
feat: build and publish docker image for arm and amd platforms (#1004)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukasz Gornicki <[email protected]>
  • Loading branch information
Ferror and derberg authored Oct 11, 2023
1 parent 4d347f8 commit f360fa6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
53 changes: 38 additions & 15 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release Docker Image
on:
on:
release:
types:
types:
- published

jobs:
Expand All @@ -10,24 +10,47 @@ jobs:
name: Docker build and push
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: master
- name: Get version without v character
id: version
run: |
VERSION=${{github.event.release.tag_name}}
VERSION_WITHOUT_V=${VERSION:1}
echo "::set-output name=value::$(echo $VERSION_WITHOUT_V)"
- name: Release to Docker
run: |
echo ${{secrets.DOCKER_PASSWORD}} | docker login -u ${{secrets.DOCKER_USERNAME}} --password-stdin
sleep 1m #docker image installs generator from npm, this sleep protects this step from any delays on npm side
npm run docker:build
docker tag asyncapi/generator:latest asyncapi/generator:${{ steps.version.outputs.value }}
docker push asyncapi/generator:${{ steps.version.outputs.value }}
docker push asyncapi/generator:latest
echo "value=${VERSION_WITHOUT_V}" >> $GITHUB_OUTPUT
- name: Set Up QEMU
uses: docker/setup-qemu-action@v2

- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# This workflow triggers on GitHub Release, but it may start before the npm package is published.
- name: Sleep for 1s seconds
run: sleep 1s

- name: Build Image
uses: docker/build-push-action@v4
with:
push: true
load: false
build-args: |
ASYNCAPI_GENERATOR_VERSION=${{ steps.version.outputs.value }}
tags: |
asyncapi/generator:${{ steps.version.outputs.value }}
asyncapi/generator:latest
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha

- name: Update Docker Hub Readme
uses: meeDamian/[email protected]
with:
user: ${{ secrets.DOCKER_USERNAME }}
pass: ${{ secrets.DOCKER_PASSWORD }}
slug: asyncapi/generator
description: Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG ASYNCAPI_GENERATOR_VERSION=1.10.9

FROM node:14-alpine

WORKDIR /app
Expand All @@ -14,6 +16,6 @@ RUN apk --update add git chromium && \
rm /var/cache/apk/*

# Installing latest released npm package
RUN npm install -g @asyncapi/generator
RUN npm install -g @asyncapi/generator@$ASYNCAPI_GENERATOR_VERSION

ENTRYPOINT [ "ag" ]

0 comments on commit f360fa6

Please sign in to comment.