This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
🧐 Generate Docker image 🎁 #2679
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🧐 Generate Docker image 🎁 | |
on: | |
pull_request: | |
branches: | |
- 'main' | |
push: | |
tags: | |
- 'v*' | |
branches: | |
- 'main' | |
workflow_dispatch: | |
schedule: | |
- cron: '12 0 * * *' | |
jobs: | |
build: | |
name: 👩🏼🏭 Build Native Quarkus 👩🏼🏭 | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🪅 Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: 🗄️ Checkout Source Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: 🥸 Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
check-latest: true | |
- name: 🔥 Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: 🤳 Build Native Quarkus | |
run: mvn -B install -Pnative -Dquarkus.native.native-image-xmx=5g | |
- name: 📤 Login to DockerHub | |
uses: docker/login-action@v2 | |
env: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
if: ${{env.username != ''}} | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: 📥 Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: kaotoio/backend | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: 🗃️ Build to test | |
uses: docker/build-push-action@v4 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
context: "api" | |
file: './api/src/main/docker/Dockerfile.native' | |
platforms: linux/amd64 | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: 🏃♀️ Run built image | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
docker images | |
docker run -d --rm -p 8081:8081 --name kaoto-backend kaotoio/backend:pr-${{ github.event.pull_request.number }} | |
- name: Check the deployed service URL | |
uses: jtalk/url-health-check-action@v3 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
url: 'http://localhost:8081/q/health' | |
max-attempts: 5 | |
retry-delay: 1s | |
- name: 🍱 Build and push | |
uses: docker/build-push-action@v4 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
context: "api" | |
file: './api/src/main/docker/Dockerfile.native' | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-for-mac: | |
name: 👩🏼🏭 Build Native Quarkus for MacOS 👩🏼🏭 | |
runs-on: macos-latest | |
steps: | |
- name: 🗄️ Checkout Source Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: 🥸 Set up GraalVM | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '17.0.7' | |
distribution: 'graalvm-community' | |
components: 'native-image' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: 🔥 Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-macos-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2-macos | |
- name: 🤳 Build Native Quarkus | |
run: mvn install -DskipTests -Pnative | |
- name: 📩 Save MacOS native build | |
uses: actions/upload-artifact@v3 | |
with: | |
name: macos-native-build | |
path: api/target/*-runner | |
retention-days: 1 | |
docker-for-mac: | |
name: 👩🏼🏭 Build Docker Image for MacOS 👩🏼🏭 | |
runs-on: ubuntu-latest | |
needs: [build-for-mac, build] | |
steps: | |
- name: 🦤 Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: 🪅 Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: 🗄️ Checkout Source Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: 📨 Retrieve saved MacOS native build | |
uses: actions/download-artifact@v3 | |
with: | |
name: macos-native-build | |
path: api/target/kaoto-runner | |
- name: 📤 Login to DockerHub | |
uses: docker/login-action@v2 | |
env: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
if: ${{env.username != ''}} | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: 📥 Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: kaotoio/backend | |
flavor: | | |
latest=auto | |
prefix= | |
suffix=-arm64,onlatest=true | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: 🍱 Build and push | |
uses: docker/build-push-action@v4 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
context: "api" | |
file: './api/src/main/docker/Dockerfile.native' | |
platforms: linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
standalone: | |
uses: ./.github/workflows/standalone-build-and-push.yml | |
needs: | |
- build | |
- build-for-mac | |
- docker-for-mac | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
tag: "${{ github.ref_name }}-${{ github.sha }}" | |
alias: "latest" | |
frontend-version: main | |
backend-version: main | |
secrets: | |
docker-username: ${{ secrets.DOCKER_USERNAME }} | |
docker-password: ${{ secrets.DOCKER_PASSWORD }} | |
quay-username: ${{ secrets.QUAY_USERNAME }} | |
quay-password: ${{ secrets.QUAY_PASSWORD }} |