Skip to content

Commit

Permalink
feat: add java image (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jigarkhwar authored Sep 7, 2024
1 parent 4cbfb76 commit 2440ddd
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 4 deletions.
38 changes: 37 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,47 @@ jobs:
/kaniko/executor --dockerfile="Dockerfile" \
--context="${{ github.repositoryUrl }}#${{ github.ref }}#${{ github.sha }}" \
--destination="$DOCKER_IMAGE_NAME:master" \
--destination="$DOCKER_IMAGE_NAME:${GITHUB_REF##*/}" \
--destination="$DOCKER_IMAGE_NAME:latest" \
${{ env.KANIKO_CACHE_ARGS }} \
--push-retry 5
env:
GIT_USERNAME: ${{ github.actor }}
GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DOCKER_IMAGE_NAME: "galaxioteam/base"
java-build:
strategy:
matrix:
java-version: [ 17, 21 ]
runs-on: ubuntu-22.04
container:
image: gcr.io/kaniko-project/executor:v1.20.0-debug
needs: base-build
permissions:
contents: read # read the repository
steps:
- name: Test Java Build with kaniko
run: |
cat <<EOF > /kaniko/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "$(echo -n "${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }}" | base64 )"
}
}
}
EOF
export IFS=''
/kaniko/executor --dockerfile="java.Dockerfile" \
--context="${{ github.repositoryUrl }}#${{ github.ref }}#${{ github.sha }}" \
--build-arg "BASE_VERSION=${GITHUB_REF##*/}" \
--build-arg "JAVA_VERSION=${{ matrix.java-version }}" \
--cleanup \
--destination="$DOCKER_IMAGE_NAME:${{ matrix.java-version }}-${GITHUB_REF##*/}" \
${{ env.KANIKO_CACHE_ARGS }} \
--push-retry 5
env:
GIT_USERNAME: ${{ github.actor }}
GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DOCKER_IMAGE_NAME: "galaxioteam/base-jdk"
61 changes: 58 additions & 3 deletions .github/workflows/pull-request-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,71 @@ on:
pull_request:
branches: [ '**' ]

env:
KANIKO_CACHE_ARGS: "--cache=true --cache-repo galaxioteam/base-cache --cache-copy-layers=true --cache-ttl=24h"

jobs:
test-build:
base-build:
runs-on: ubuntu-22.04
container:
image: gcr.io/kaniko-project/executor:v1.20.0-debug
permissions:
contents: read # read the repository
steps:
- name: Test Build with kaniko
- name: Build and Push Image to docker registry with kaniko
run: |
cat <<EOF > /kaniko/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "$(echo -n "${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }}" | base64 )"
}
}
}
EOF
/kaniko/executor --dockerfile="Dockerfile" \
--context="${{ github.repositoryUrl }}#${{ github.head_ref }}" \
--no-push
--destination="$DOCKER_IMAGE_NAME:${GITHUB_SHA}" \
${{ env.KANIKO_CACHE_ARGS }} \
--push-retry 5
env:
GIT_USERNAME: ${{ github.actor }}
GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DOCKER_IMAGE_NAME: "galaxioteam/base"
java-build:
strategy:
matrix:
java-version: [ 17, 21 ]
runs-on: ubuntu-22.04
container:
image: gcr.io/kaniko-project/executor:v1.20.0-debug
needs: base-build
permissions:
contents: read # read the repository
steps:
- name: Test Java Build with kaniko
run: |
cat <<EOF > /kaniko/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "$(echo -n "${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }}" | base64 )"
}
}
}
EOF
export IFS=''
/kaniko/executor --dockerfile="java.Dockerfile" \
--context="${{ github.repositoryUrl }}#${{ github.head_ref }}" \
--build-arg "BASE_VERSION=${GITHUB_SHA}" \
--build-arg "JAVA_VERSION=${{ matrix.java-version }}" \
--cleanup \
--destination="$DOCKER_IMAGE_NAME:${{ matrix.java-version }}-${GITHUB_SHA}" \
${{ env.KANIKO_CACHE_ARGS }} \
--push-retry 5
env:
GIT_USERNAME: ${{ github.actor }}
GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DOCKER_IMAGE_NAME: "galaxioteam/base-jdk"
19 changes: 19 additions & 0 deletions java.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG JAVA_VERSION=21
ARG BASE_VERSION=master

FROM eclipse-temurin:${JAVA_VERSION}-jdk-jammy as fat

LABEL maintainer="Galaxio Team"
LABEL authors="i.akhaltsev"

FROM galaxioteam/base:${BASE_VERSION}

COPY --from=fat /opt/java/openjdk/ /opt/java/openjdk/

# Env variables
ENV PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV JAVA_HOME=/opt/java/openjdk

RUN java --version

ARG JAVA_OPTS_COMMON="-Dconfig.override_with_env_vars=true -Dfile.encoding=UTF-8"

0 comments on commit 2440ddd

Please sign in to comment.