-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (68 loc) · 3.48 KB
/
Copy pathmvn_docker_image.yaml
File metadata and controls
84 lines (68 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Build with maven and Push to Docker Registry
on:
push:
tags:
- v*
workflow_dispatch:
inputs:
ref_name:
required: true
type: string
description: Tag to deploy
jobs:
create-docker-image:
name: Create Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref_name || github.ref_name }}
- name: Git Status
run: git status
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
- name: Create maven central settings.xml
uses: whelk-io/maven-settings-xml-action@9dc09b23833fa9aa7f27b63db287951856f3433d
- name: Set TAG_NAME from ref_name
run: echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Replace all characters in `\/:"<>|?*` by `-` in TAG_NAME
run: echo "TAG_NAME=$(echo "$TAG_NAME" | sed 's/[\/:"<>|?*]/-/g')" >> $GITHUB_ENV
- name: Set maven root directory
run: echo "MVN_ROOT_DIR=start-hack-backend" >> $GITHUB_ENV
- name: Set VERSION from TAG_NAME
run: echo "VERSION=${TAG_NAME}" >> $GITHUB_ENV
- name: Strip leading `v` from VERSION
run: echo "VERSION=${VERSION##v}" >> $GITHUB_ENV
- name: Set versions
run: mvn -f ${{ env.MVN_ROOT_DIR }}/pom.xml versions:set -DnewVersion=$VERSION
- name: Commit versions
run: mvn -f ${{ env.MVN_ROOT_DIR }}/pom.xml versions:commit
- name: Build with Maven
run: mvn --batch-mode --update-snapshots install -DskipTests -f ${{ env.MVN_ROOT_DIR }}/pom.xml
- name: Set default docker image
run: |
echo "DOCKER_IMAGE=sthomasch/eclipse-temurin-gdal:21" >> $GITHUB_ENV
- name: Docker image for build
run: |
echo "Docker image jar build: $DOCKER_IMAGE"
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.docker_hub_username }}
password: ${{ secrets.docker_hub_password }}
- name: Build and push docker image
run: |
mvn --batch-mode package jib:build \
-f start-hack-backend/start-hack-ws/pom.xml \
-Dconfig.deploy.env=dev -Dconfig.directory=/config \
-Dimage=${{ secrets.docker_hub_username }}/start-hack-backend:${{ env.VERSION }} \
-Djib.from.image=${{ env.DOCKER_IMAGE }} \
-Djib.to.tags=latest,${{ env.VERSION }} \
-Djib.to.auth.username=${{ secrets.docker_hub_username }} \
-Djib.to.auth.password=${{ secrets.docker_hub_password }} \
-Djib.container.volumes='/config/' \
-Djib.container.environment=VERSION_TAG_NAME="${{ env.TAG_NAME }}",SPRING_CONFIG_LOCATION="/config/",SPRING_DOCKER_COMPOSE_ENABLED=false \
-Djib.container.entrypoint='sh,-c,java -XX:MinRAMPercentage=60.0 -XX:MaxRAMPercentage=80.0 $ADDITIONAL_JAVA_OPTS -cp @/app/jib-classpath-file @/app/jib-main-class-file $@'