From dc9034e8c09706a6f5cc08c931e6715c35956947 Mon Sep 17 00:00:00 2001 From: John Axe Date: Sat, 7 Sep 2024 07:21:22 -0300 Subject: [PATCH] feat: add java image --- .github/workflows/build.yml | 2 +- .github/workflows/pull-request-build.yml | 49 ++++++++++++++++++++---- java.Dockerfile | 3 +- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 19df926..16d5b5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,7 @@ 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 diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml index 62af1ac..cd62fde 100644 --- a/.github/workflows/pull-request-build.yml +++ b/.github/workflows/pull-request-build.yml @@ -4,21 +4,40 @@ on: pull_request: branches: [ '**' ] +env: + KANIKO_CACHE_ARGS: "--cache=true --cache-repo galaxioteam/base-cache --cache-copy-layers=true --cache-ttl=24h" + jobs: - test-base-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 + needs: test-build steps: - - name: Test Base Build with kaniko + - name: Build and Push Image to docker registry with kaniko run: | + cat < /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 }}" \ - --cleanup \ - --no-push - test-java-build: + --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 ] @@ -30,10 +49,26 @@ jobs: steps: - name: Test Java Build with kaniko run: | + cat < /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 \ - --no-push - + --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" diff --git a/java.Dockerfile b/java.Dockerfile index cb746c5..a5390d7 100644 --- a/java.Dockerfile +++ b/java.Dockerfile @@ -1,11 +1,12 @@ 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:master +FROM galaxioteam/base:${BASE_VERSION} COPY --from=fat /opt/java/openjdk/ /opt/java/openjdk/