Skip to content

Commit 4172884

Browse files
authored
Merge pull request #3331 from ControlSystemStudio/CSSTUDIO-2989
Updates to Docker related files for middleware services
2 parents f093186 + add4c2e commit 4172884

14 files changed

+370
-18
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: [ "master" ]
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
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Alarm Server Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
paths: services/alarm-server/**
7+
tags:
8+
- '**'
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}/service-alarm-server
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-server
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/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Services
2+
3+
Modules in this directory include CS Studio/Phoebus middleware services:
4+
5+
* Alarm Config Logger
6+
* Alarm Logger
7+
* Alarm Service
8+
* Archive Engine
9+
* Save-and-Restore
10+
11+
Additional middleware services are maintained in other repositories:
12+
* Phoebus Logbook Service (Olog): https://github.com/Olog/phoebus-olog
13+
* Channel Finder Service: https://github.com/ChannelFinder/ChannelFinderService
14+
* Archiver Appliance: https://github.com/archiver-appliance/epicsarchiverap
15+
16+
# Docker
17+
18+
The provided Docker compose file can be used to launch the full stack of 3rd party services upon which
19+
services in this repository depend:
20+
21+
* Elasticsearch
22+
* Used by Save-and-Restore, Alarm Logger, Channel Finder and Olog
23+
* MongoDB
24+
* Used by Olog
25+
* Kafka + Zookeeper
26+
* Used by Alarm Server and Alarm Logger
27+
28+
The Docker compose file depends on the environment variable ```HOST_IP_ADDRESS```, which must be set
29+
to the IP address of the host running the Docker container. Kafka clients must use this as the
30+
```bootstrap-server``` IP address.
31+
32+
Docker supports environment variables to be set in a file (default ```.env``` in current directory) like so:
33+
34+
```HOST_IP_ADDRESS=1.2.3.4```
35+
.
36+
.
37+
.
38+
39+
This may be preferable compared to setting environment variables on command line, e.g.
40+
41+
```>export HOST_IP_ADDRESS=1.2.3.4```.

services/alarm-logger/Dockerfile

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

services/alarm-logger/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,18 @@ A full list of checks is documented [here](https://maven.apache.org/maven-releas
135135
`mvn -Darguments="-Dskip-executable-jar" -Pdocs,releases release:perform`
136136
Checkout the release tag, build, sign and push the build binaries to sonatype. The `docs` profile is needed in order
137137
to create required javadocs jars.
138+
139+
# Docker
140+
141+
The latest version of the service is available as a Docker image (ghcr.io/controlsystemstudio/phoebus/service-alarm-logger:master).
142+
Pushes to the master branch into this directory will trigger a new build of the image.
143+
144+
Docker compose file is provided. It requires the following environment variable to be set:
145+
146+
```KAFKA_HOST_IP_ADDRESS=1.2.3.4```
147+
```ELASTIC_HOST_IP_ADDRESS=1.2.3.4```
148+
```ALARM_TOPICS```: comma-separated list of alarm topics subscribed to by the service
149+
150+
This may be preferable compared to setting environment variables on command line, e.g.
151+
152+
```>export KAFKA_HOST_IP_ADDRESS=1.2.3.4```.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
alarmlogger:
3+
image: ghcr.io/controlsystemstudio/phoebus/service-alarm-logger:master
4+
ports:
5+
- "8080:8080"
6+
command: >
7+
/bin/bash -c "
8+
java -jar /alarmlogger/service-alarm-logger-*.jar -bootstrap.servers ${KAFKA_HOST_IP_ADDRESS}:9092 -es_host ${ELASTIC_HOST_IP_ADDRESS} -topics ${ALARM_TOPICS} -noshell"
9+
10+

services/alarm-server/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-server-*.jar /alarmserver/service-alarm-server-*.jar
5+
COPY target/lib /alarmserver/lib
6+
7+
CMD ["java", "-jar", "/alarmserver/service-alarm-server-*.jar"]

services/alarm-server/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,32 @@ some useful startup arguments include
4747
-import config.xml - Import alarm configruation from file
4848
-logging logging.properties - Load log settings
4949
```
50+
51+
## Docker
52+
53+
Docker compose files are provided for convenience to cover two use cases:
54+
55+
1. ```docker-compose-alarm-server-only.yml``` will run the alarm server. Required environment variables:
56+
* ```KAFKA_HOST_IP_ADDRESS``` must be set to identify the Kafka server external IP address.
57+
* ```CONFIG``` identifies the configuration (topic) name.
58+
* ```ALARM_SERVICE_SETTINGS_FILE``` file in user's home directory specifying EPICS related settings, e.g.
59+
```org.phoebus.pv/default=pva```.
60+
2. ```docker-compose-alarm-server-only-import.yml``` will run the alarm server for the
61+
purpose of importing a configuration. Environment variables must be se as in case 1.
62+
Additionally, the environment variable ```CONFIG_FILE``` must identify an alarm
63+
configuration file in the current user's home directory.
64+
65+
Docker supports environment variables to be set in a file (default ```.env``` in current directory) like so:
66+
67+
```KAFKA_HOST_IP_ADDRESS=1.2.3.4```
68+
```CONFIG=Accelerator```
69+
.
70+
.
71+
.
72+
73+
This may be preferable compared to setting environment variables on command line, e.g.
74+
75+
```>export KAFKA_HOST_IP_ADDRESS=1.2.3.4```.
76+
77+
**NOTE:** Accessing IOCs over pva (default mode in the Docker compose files) works **only** if IOC is running on the
78+
same host as the Docker container. Moreover, this has been verified to work only on Linux.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
alarmserver:
3+
image: ghcr.io/controlsystemstudio/phoebus/service-alarm-server:master
4+
volumes:
5+
- /home:/home
6+
command: >
7+
/bin/bash -c "
8+
java -jar /alarmserver/service-alarm-server-*.jar -config ${CONFIG} -import ${CONFIG_FILE} -server ${KAFKA_HOST_IP_ADDRESS}:9092 -settings"
9+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
alarmserver:
3+
image: ghcr.io/controlsystemstudio/phoebus/service-alarm-server:master
4+
environment:
5+
EPICS_PVA_ADDR_LIST: ${HOST_IP_ADDRESS}
6+
volumes:
7+
- /home:/home
8+
command: >
9+
/bin/bash -c "
10+
java -jar /alarmserver/service-alarm-server-*.jar -settings ${ALARM_SERVICE_SETTINGS_FILE} -config ${CONFIG} -server ${KAFKA_HOST_IP_ADDRESS}:9092 -settings ${SETTINGS_FILE} -noshell"
11+

0 commit comments

Comments
 (0)