Skip to content

Commit

Permalink
build: add docker image based on java binary
Browse files Browse the repository at this point in the history
add graalvm build arg -march=compatibility

related-to: #482
  • Loading branch information
fhussonnois committed Aug 30, 2024
1 parent 95b105f commit f2987f2
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 30 deletions.
105 changes: 85 additions & 20 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
GRAAL_VERSION: '21.0.1'
GRAAL_DISTRIBUTION: 'graalvm-community'
jobs:
build:
build-cli:
if: github.repository == 'streamthoughts/jikkou'
name: 'Build Docker Image'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -51,10 +51,16 @@ jobs:
- name: 'Build Native Executable (Jikkou CLI)'
run: |
chmod +x ./mvnw && \
./mvnw -ntp -B clean package -Pnative -Dgraalvm.build.arg="--static --libc=musl" -DskipTests && \
./mvnw -ntp -B clean package -Pnative -Dgraalvm.build.arg="--static --libc=musl --verbose -march=compatibility" -DskipTests && \
cp ./cli/target/jikkou-cli-${{ env.VERSION }}-runner ./docker/jikkou-cli-${{ env.VERSION }}-runner
- name: 'Build & Push to Docker Hub (Jikkou CLI)'
- name: 'Build Java Binary Executable (Jikkou CLI)'
run: |
chmod +x ./mvnw && \
./mvnw -ntp -B --file pom.xml -Pdist package -DskipTests && \
cp -r ./dist/jikkou-${{ env.VERSION }}-java-binary ./docker
- name: 'Build & Push to Docker Hub (Jikkou CLI Native)'
if: github.ref_name == 'main'
uses: docker/build-push-action@v6
with:
Expand All @@ -70,7 +76,23 @@ jobs:
BRANCH=${{ env.GIT_BRANCH }}
CREATED=${{ env.CREATED }}
- name: 'Build & Push to Docker Hub (Jikkou CLI)'
- name: 'Build & Push to Docker Hub (Jikkou CLI Java)'
if: github.ref_name == 'main'
uses: docker/build-push-action@v6
with:
context: docker
platforms: linux/amd64,linux/arm64
file: docker/Dockerfile_java
no-cache: true
push: true
tags: streamthoughts/jikkou:main-java
build-args: |
VERSION=${{ env.VERSION }}
COMMIT=${{ env.GIT_COMMIT }}
BRANCH=${{ env.GIT_BRANCH }}
CREATED=${{ env.CREATED }}
- name: 'Build & Push to Docker Hub (Jikkou CLI Native)'
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v6
with:
Expand All @@ -86,21 +108,64 @@ jobs:
BRANCH=${{ env.GIT_BRANCH }}
CREATED=${{ env.CREATED }}
- name: 'Build & Push to Docker Hub (Jikkou API Server)'
- name: 'Build & Push to Docker Hub (Jikkou CLI Java)'
if: github.ref_name == 'main'
run: |
./mvnw -ntp -B install -DskipTests && \
./mvnw -ntp -B package -DskipTests -f ./server/jikkou-api-server/pom.xml \
-Dpackaging=docker \
-Djib.to.image=streamthoughts/jikkou-api-server:main
docker image push --all-tags streamthoughts/jikkou-api-server
uses: docker/build-push-action@v6
with:
context: docker
platforms: linux/amd64,linux/arm64
file: docker/Dockerfile_java
no-cache: true
push: true
tags: streamthoughts/jikkou:${{ env.VERSION }}-java,streamthoughts/jikkou:latest-java
build-args: |
VERSION=${{ env.VERSION }}
COMMIT=${{ env.GIT_COMMIT }}
BRANCH=${{ env.GIT_BRANCH }}
CREATED=${{ env.CREATED }}
- name: 'Build & Push to Docker Hub (Jikkou API Server)'
if: startsWith(github.ref, 'refs/tags/v')
run: |
./mvnw -ntp -B install -DskipTests && \
./mvnw -ntp -B package -DskipTests -f ./server/jikkou-api-server/pom.xml \
-Dpackaging=docker \
-Djib.to.image=streamthoughts/jikkou-api-server:${{ env.VERSION }} \
-Djib.to.tags=latest
docker image push --all-tags streamthoughts/jikkou-api-server
build-server:
if: github.repository == 'streamthoughts/jikkou'
name: 'Build Docker Image'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3

- name: 'Set up Java'
- uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRO }}
java-version: ${{ env.JAVA_VERSION }}

- name: 'Login to DockerHub'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: 'Set Docker Image Build-Args'
run: |
VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GIT_COMMIT=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
echo "CREATED=$(date --rfc-3339=seconds)" >> $GITHUB_ENV
GIT_BRANCH=${GITHUB_REF#refs/*/}
if [[ $GIT_BRANCH == v* ]]; then
TAGS="$VERSION,latest"
else
TAGS="main"
fi
echo "TAGS=$TAGS" >> $GITHUB_ENV
- name: 'Build & Push to Docker Hub (Jikkou API Server)'
run: |
./mvnw -ntp -B install -DskipTests && \
./mvnw -ntp -B package -DskipTests -f ./server/jikkou-api-server/pom.xml \
-Dpackaging=docker \
-Djib.to.image=streamthoughts/jikkou-api-server \
-Djib.to.tags=${{ env.TAGS }}
docker image push --all-tags streamthoughts/jikkou-api-server
43 changes: 43 additions & 0 deletions docker/Dockerfile_java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) The original authors
#
# Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
#
FROM eclipse-temurin:21.0.4_7-jdk-ubi9-minimal

LABEL org.opencontainers.image.title=jikkou \
org.opencontainers.image.licenses=Apache-2.0 \
org.opencontainers.image.url=https://streamthoughts.github.io/jikkou/ \
org.opencontainers.image.documentation=https://streamthoughts.github.io/jikkou/ \
org.opencontainers.image.source=https://github.com/streamthoughts/jikkou

ARG VERSION
ARG CREATED
ARG COMMIT

ENV USER_ID=10000 \
GROUP_ID=10001 \
USER_NAME="appuser" \
GROUP_NAME="appuser" \
JIKKOUCONFIG="/etc/jikkou/config"

RUN mkdir -p /etc/jikkou/

WORKDIR /app

RUN groupadd -g $GROUP_ID $GROUP_NAME && \
useradd -r -s /bin/false -u $USER_ID -g $USER_NAME $GROUP_NAME && \
chown $USER_NAME:$GROUP_NAME /app

USER $USER_NAME

COPY --chmod=0755 ./jikkou-${VERSION}-java-binary/* .

LABEL org.opencontainers.image.created=$CREATED \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.revision=$COMMIT

ENTRYPOINT ["./bin/jikkou"]


13 changes: 3 additions & 10 deletions docker/Dockerfile.ubuntu → docker/Dockerfile_ubuntu
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
# Copyright 2023 The original authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) The original authors
#
# http://www.apache.org/licenses/LICENSE-2.0
# Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:20.04

LABEL org.opencontainers.image.title=jikkou \
Expand Down

0 comments on commit f2987f2

Please sign in to comment.