Build SSO Docker Image #14
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: Build SSO Docker Image | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version of the application' | |
required: true | |
default: '0.0.1' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up GraalVM | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: 17 | |
- name: Build Jar | |
run: | | |
cd course-secure-rest-api-oauth2-tools/sso/ | |
./gradlew clean build -x test | |
cp build/libs/sso-${{github.event.inputs.version}}-SNAPSHOT.jar ../../ | |
- name: Create a Dockerfile | |
uses: 1arp/[email protected] | |
with: | |
file: Dockerfile | |
content: | | |
FROM eclipse-temurin:17 as builder | |
WORKDIR application | |
ARG JAR_FILE=*.jar | |
COPY ${JAR_FILE} application.jar | |
RUN java -Djarmode=layertools -jar application.jar extract | |
FROM eclipse-temurin:17 | |
WORKDIR application | |
COPY --from=builder application/dependencies/ ./ | |
COPY --from=builder application/spring-boot-loader/ ./ | |
COPY --from=builder application/snapshot-dependencies/ ./ | |
COPY --from=builder application/application/ ./ | |
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"] | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/vmware-tanzu-learning/course-secure-rest-api-oauth2-code/sso:latest | |