Skip to content

Commit 5eb7a7a

Browse files
committed
Github action to build alarm logger Docker image
1 parent 460af03 commit 5eb7a7a

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Alarm Logger Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "CSSTUDIO-2989" ]
6+
paths: services/alarm-logger/**
7+
tags:
8+
- '**'
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}/service-alarm-logger
13+
14+
jobs:
15+
build-server:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup Maven and Java Action
20+
21+
with:
22+
java-version: '17'
23+
maven-version: '3.9.6'
24+
- name: Build
25+
run: mvn --batch-mode install -DskipTests
26+
build-and-push-image:
27+
permissions:
28+
contents: read
29+
packages: write
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Set up JDK 17
34+
uses: actions/setup-java@v4
35+
with:
36+
java-version: '17'
37+
distribution: 'temurin'
38+
cache: maven
39+
- name: Build with Maven
40+
run: mvn --batch-mode --update-snapshots package
41+
- name: Login to the registry
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
- name: Extract meta-data for Docker
48+
id: meta
49+
uses: docker/metadata-action@v5
50+
with:
51+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52+
- name: Set up Docker Build
53+
uses: docker/setup-buildx-action@v3
54+
- name: Build and publish the Docker image
55+
uses: docker/build-push-action@v5
56+
with:
57+
context: services/alarm-logger
58+
push: true
59+
platforms: linux/amd64
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}
62+
cache-from: type=gha
63+
cache-to: type=gha,mode=max

services/alarm-logger/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM eclipse-temurin:17-jre
2+
3+
# deployment unit
4+
COPY target/service-alarm-logger-*.jar /alarmlogger/service-alarm-logger-*.jar
5+
COPY target/lib /alarmlogger/lib
6+
7+
CMD ["java", "-jar", "/alarmlogger/service-alarm-logger-*.jar"]

0 commit comments

Comments
 (0)