forked from Archives/Athou_commafeed
use github actions to build a native arm64 docker image
This commit is contained in:
136
.github/workflows/ci.yml
vendored
136
.github/workflows/ci.yml
vendored
@@ -7,8 +7,57 @@ env:
|
|||||||
DOCKER_BUILD_SUMMARY: false
|
DOCKER_BUILD_SUMMARY: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-linux:
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ "ubuntu-latest", "ubuntu-24.04-arm", "windows-latest" ]
|
||||||
|
database: [ "h2", "postgresql", "mysql", "mariadb" ]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
# Checkout
|
||||||
|
- name: Configure git to checkout as-is
|
||||||
|
run: git config --global core.autocrlf false
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
- name: Set up GraalVM
|
||||||
|
uses: graalvm/setup-graalvm@v1
|
||||||
|
with:
|
||||||
|
java-version: ${{ env.JAVA_VERSION }}
|
||||||
|
distribution: "graalvm"
|
||||||
|
cache: "maven"
|
||||||
|
|
||||||
|
- name: Install Playwright dependencies
|
||||||
|
run: sudo apt-get install -y libgbm1
|
||||||
|
if: matrix.os != 'windows-latest'
|
||||||
|
|
||||||
|
# Build & Test
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn --batch-mode --no-transfer-progress install -Pnative -P${{ matrix.database }} -DskipTests=${{ matrix.os == 'windows-latest' && matrix.database != 'h2' }}
|
||||||
|
|
||||||
|
# Upload artifacts
|
||||||
|
- name: Upload cross-platform app
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: commafeed-${{ matrix.database }}-jvm
|
||||||
|
path: commafeed-server/target/commafeed-*.zip
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
|
- name: Upload native executable
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: commafeed-${{ matrix.database }}-${{ runner.os }}-${{ runner.arch }}
|
||||||
|
path: commafeed-server/target/commafeed-*-runner*
|
||||||
|
|
||||||
|
docker:
|
||||||
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
database: [ "h2", "postgresql", "mysql", "mariadb" ]
|
database: [ "h2", "postgresql", "mysql", "mariadb" ]
|
||||||
@@ -27,29 +76,29 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Set up GraalVM
|
- name: Install required packages
|
||||||
uses: graalvm/setup-graalvm@v1
|
run: sudo apt-get install -y rename unzip
|
||||||
with:
|
|
||||||
java-version: ${{ env.JAVA_VERSION }}
|
|
||||||
distribution: "graalvm"
|
|
||||||
cache: "maven"
|
|
||||||
|
|
||||||
# Build & Test
|
# Prepare artifacts
|
||||||
- name: Build with Maven
|
- name: Download artifacts
|
||||||
run: mvn --batch-mode --no-transfer-progress install -Pnative -P${{ matrix.database }}
|
uses: actions/download-artifact@v4
|
||||||
|
|
||||||
# Upload artifacts
|
|
||||||
- name: Upload cross-platform app
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: commafeed-${{ matrix.database }}-jvm
|
pattern: commafeed-${{ matrix.database }}-*
|
||||||
path: commafeed-server/target/commafeed-*.zip
|
path: ./artifacts
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
- name: Upload native executable
|
- name: Set the exec flag on the native executables
|
||||||
uses: actions/upload-artifact@v4
|
run: chmod +x artifacts/*-runner
|
||||||
with:
|
|
||||||
name: commafeed-${{ matrix.database }}-${{ runner.os }}-${{ runner.arch }}
|
- name: Rename native executables to match buildx TARGETARCH
|
||||||
path: commafeed-server/target/commafeed-*-runner
|
run: |
|
||||||
|
rename 's/x86_64/amd64/g' artifacts/*
|
||||||
|
rename 's/aarch_64/arm64/g' artifacts/*
|
||||||
|
|
||||||
|
- name: Unzip jvm package
|
||||||
|
run: |
|
||||||
|
unzip artifacts/*-jvm.zip -d artifacts/extracted-jvm-package
|
||||||
|
rename 's/commafeed-.*/quarkus-app/g' artifacts/extracted-jvm-package/*
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
- name: Login to Container Registry
|
- name: Login to Container Registry
|
||||||
@@ -67,7 +116,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: commafeed-server/src/main/docker/Dockerfile.native
|
file: commafeed-server/src/main/docker/Dockerfile.native
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64,linux/arm64/v8
|
||||||
tags: |
|
tags: |
|
||||||
athou/commafeed:latest-${{ matrix.database }}
|
athou/commafeed:latest-${{ matrix.database }}
|
||||||
athou/commafeed:${{ github.ref_name }}-${{ matrix.database }}
|
athou/commafeed:${{ github.ref_name }}-${{ matrix.database }}
|
||||||
@@ -92,7 +141,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: commafeed-server/src/main/docker/Dockerfile.native
|
file: commafeed-server/src/main/docker/Dockerfile.native
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64,linux/arm64/v8
|
||||||
tags: athou/commafeed:master-${{ matrix.database }}
|
tags: athou/commafeed:master-${{ matrix.database }}
|
||||||
|
|
||||||
- name: Docker build and push master - jvm
|
- name: Docker build and push master - jvm
|
||||||
@@ -105,46 +154,10 @@ jobs:
|
|||||||
platforms: linux/amd64,linux/arm64/v8
|
platforms: linux/amd64,linux/arm64/v8
|
||||||
tags: athou/commafeed:master-${{ matrix.database }}-jvm
|
tags: athou/commafeed:master-${{ matrix.database }}-jvm
|
||||||
|
|
||||||
build-windows:
|
|
||||||
runs-on: windows-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
database: [ "h2", "postgresql", "mysql", "mariadb" ]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# Checkout
|
|
||||||
- name: Configure git to checkout as-is
|
|
||||||
run: git config --global core.autocrlf false
|
|
||||||
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
# Setup
|
|
||||||
- name: Set up GraalVM
|
|
||||||
uses: graalvm/setup-graalvm@v1
|
|
||||||
with:
|
|
||||||
java-version: ${{ env.JAVA_VERSION }}
|
|
||||||
distribution: "graalvm"
|
|
||||||
cache: "maven"
|
|
||||||
|
|
||||||
# Build & Test
|
|
||||||
- name: Build with Maven
|
|
||||||
run: mvn --batch-mode --no-transfer-progress install -Pnative -P${{ matrix.database }} -DskipTests=${{ matrix.database != 'h2' }}
|
|
||||||
|
|
||||||
# Upload artifacts
|
|
||||||
- name: Upload native executable
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: commafeed-${{ matrix.database }}-${{ runner.os }}-${{ runner.arch }}
|
|
||||||
path: commafeed-server/target/commafeed-*-runner.exe
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- build-linux
|
- build
|
||||||
- build-windows
|
|
||||||
if: github.ref_type == 'tag'
|
if: github.ref_type == 'tag'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -160,6 +173,9 @@ jobs:
|
|||||||
path: ./artifacts
|
path: ./artifacts
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Set the exec flag on the native executables
|
||||||
|
run: chmod +x artifacts/*-runner
|
||||||
|
|
||||||
- name: Extract Changelog Entry
|
- name: Extract Changelog Entry
|
||||||
uses: mindsers/changelog-reader-action@v2
|
uses: mindsers/changelog-reader-action@v2
|
||||||
id: changelog_reader
|
id: changelog_reader
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ EXPOSE 8082
|
|||||||
RUN mkdir -p /commafeed/data
|
RUN mkdir -p /commafeed/data
|
||||||
VOLUME /commafeed/data
|
VOLUME /commafeed/data
|
||||||
|
|
||||||
COPY commafeed-server/target/quarkus-app/ /commafeed
|
COPY artifacts/extracted-jvm-package/quarkus-app/ /commafeed
|
||||||
WORKDIR /commafeed
|
WORKDIR /commafeed
|
||||||
|
|
||||||
CMD ["java", \
|
CMD ["java", \
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
FROM debian:12.9
|
FROM debian:12.9
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
EXPOSE 8082
|
EXPOSE 8082
|
||||||
|
|
||||||
RUN mkdir -p /commafeed/data
|
RUN mkdir -p /commafeed/data
|
||||||
VOLUME /commafeed/data
|
VOLUME /commafeed/data
|
||||||
|
|
||||||
COPY commafeed-server/target/commafeed-*-runner /commafeed/application
|
COPY artifacts/commafeed-*-${TARGETARCH}-runner /commafeed/application
|
||||||
WORKDIR /commafeed
|
WORKDIR /commafeed
|
||||||
|
|
||||||
CMD ["./application"]
|
CMD ["./application"]
|
||||||
|
|||||||
@@ -92,5 +92,4 @@ Tags are of the form `<version>-<database>[-jvm]` where:
|
|||||||
- `latest` (always points to the latest version)
|
- `latest` (always points to the latest version)
|
||||||
- `master` (always points to the latest git commit)
|
- `master` (always points to the latest git commit)
|
||||||
- `<database>` is the database to use (`h2`, `postgresql`, `mysql` or `mariadb`)
|
- `<database>` is the database to use (`h2`, `postgresql`, `mysql` or `mariadb`)
|
||||||
- `-jvm` is optional and indicates that CommaFeed is running on a JVM, and not compiled natively. This image supports
|
- `-jvm` is optional and indicates that CommaFeed is running on a JVM, and not compiled natively.
|
||||||
the arm64 platform which is not yet supported by the native image.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user