Skip to content

Commit 846b31e

Browse files
committed
build: publish containers
Signed-off-by: Andrew Berezovskyi <andriib@kth.se>
1 parent 5aa1ff3 commit 846b31e

File tree

6 files changed

+241
-4
lines changed

6 files changed

+241
-4
lines changed

.github/workflows/docker.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: "Docker Build and Push (OSLC RefImpl)"
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- 'src/**'
8+
- '.github/workflows/docker.yml'
9+
release:
10+
types: [published]
11+
schedule:
12+
# Weekly rebuild every Friday at 3:00 AM UTC to get latest base image updates
13+
- cron: '0 3 * * 5'
14+
workflow_dispatch:
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_BASE_NAME: ${{ github.repository }}
19+
20+
jobs:
21+
build-and-push:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
strategy:
28+
matrix:
29+
server: [server-rm, server-cm, server-qm, server-am]
30+
include:
31+
- server: server-rm
32+
description: "OSLC Requirements Management Reference Implementation"
33+
- server: server-cm
34+
description: "OSLC Change Management Reference Implementation"
35+
- server: server-qm
36+
description: "OSLC Quality Management Reference Implementation"
37+
- server: server-am
38+
description: "OSLC Asset Management Reference Implementation"
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v4
43+
44+
- name: Check build trigger
45+
run: |
46+
if [ "${{ github.event_name }}" = "schedule" ]; then
47+
echo "🔄 This is a scheduled weekly rebuild to update base images"
48+
elif [ "${{ github.event_name }}" = "release" ]; then
49+
echo "🚀 This is a release build"
50+
else
51+
echo "📦 This is a regular build triggered by push"
52+
fi
53+
echo "Building ${{ matrix.server }} (${{ matrix.description }})"
54+
55+
- name: Log in to Container Registry
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ${{ env.REGISTRY }}
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Extract metadata
63+
id: meta
64+
uses: docker/metadata-action@v5
65+
with:
66+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE_NAME }}/${{ matrix.server }}
67+
tags: |
68+
# For pushes to master branch or scheduled builds, tag as "latest"
69+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.event_name == 'schedule' }}
70+
# For releases, create semantic version tags
71+
type=semver,pattern={{version}}
72+
type=semver,pattern={{major}}.{{minor}}
73+
type=semver,pattern={{major}}
74+
labels: |
75+
org.opencontainers.image.title=OSLC RefImpl ${{ matrix.server }}
76+
org.opencontainers.image.description=${{ matrix.description }}
77+
78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
81+
- name: Build and push Docker image
82+
uses: docker/build-push-action@v5
83+
with:
84+
context: ./src
85+
file: ./src/${{ matrix.server }}/Dockerfile
86+
push: true
87+
tags: ${{ steps.meta.outputs.tags }}
88+
labels: ${{ steps.meta.outputs.labels }}
89+
platforms: linux/amd64,linux/arm64
90+
cache-from: type=gha,scope=${{ matrix.server }}
91+
cache-to: type=gha,mode=max,scope=${{ matrix.server }}
92+
# For scheduled builds, don't use cache to ensure fresh base images
93+
no-cache: ${{ github.event_name == 'schedule' }}
94+
pull: true
95+
96+
- name: Output image details
97+
run: |
98+
echo "Image for ${{ matrix.server }} has been pushed to:"
99+
echo "${{ steps.meta.outputs.tags }}" | while read -r tag; do
100+
echo " - $tag"
101+
done
102+
103+
build-combined-compose:
104+
runs-on: ubuntu-latest
105+
needs: build-and-push
106+
if: github.event_name != 'pull_request'
107+
permissions:
108+
contents: read
109+
packages: write
110+
111+
steps:
112+
- name: Checkout repository
113+
uses: actions/checkout@v4
114+
115+
- name: Log in to Container Registry
116+
uses: docker/login-action@v3
117+
with:
118+
registry: ${{ env.REGISTRY }}
119+
username: ${{ github.actor }}
120+
password: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# OSLC 2020 Reference Implementation
33

44
[![CI build](https://github.com/oslc-op/refimpl/actions/workflows/maven.yml/badge.svg)](https://github.com/oslc-op/refimpl/actions/workflows/maven.yml)
5+
[![Docker](https://github.com/oslc-op/refimpl/actions/workflows/docker.yml/badge.svg)](https://github.com/oslc-op/refimpl/actions/workflows/docker.yml)
56
[![Discourse users](https://img.shields.io/discourse/users?color=28bd84&server=https%3A%2F%2Fforum.open-services.net%2F)](https://forum.open-services.net/)
67
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/oslc-op/refimpl)
78

@@ -88,6 +89,26 @@ To see logs:
8889

8990
docker logs oslc-refimpl-am -f
9091

92+
### Using Pre-built Docker Images
93+
94+
Pre-built Docker images are available from GitHub Container Registry for both x86_64 (amd64) and ARM64 architectures:
95+
96+
```bash
97+
# Run individual servers with latest images
98+
docker run -p 8800:8080 ghcr.io/oslc-op/refimpl/server-rm:latest
99+
docker run -p 8801:8080 ghcr.io/oslc-op/refimpl/server-cm:latest
100+
docker run -p 8802:8080 ghcr.io/oslc-op/refimpl/server-qm:latest
101+
docker run -p 8803:8080 ghcr.io/oslc-op/refimpl/server-am:latest
102+
103+
# Or run specific versions
104+
docker run -p 8800:8080 ghcr.io/oslc-op/refimpl/server-rm:0.3.0
105+
docker run -p 8801:8080 ghcr.io/oslc-op/refimpl/server-cm:0.3.0
106+
docker run -p 8802:8080 ghcr.io/oslc-op/refimpl/server-qm:0.3.0
107+
docker run -p 8803:8080 ghcr.io/oslc-op/refimpl/server-am:0.3.0
108+
```
109+
110+
> **Note:** Images are automatically rebuilt weekly to ensure the latest security updates from base images.
111+
91112

92113
### Running on Tomcat in Docker
93114

src/server-am/Dockerfile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
FROM docker.io/library/maven:3-eclipse-temurin-21-alpine AS build
22

3-
COPY . /src
43
WORKDIR /src
4+
5+
# Copy all pom.xml files and create module directories for Maven structure
6+
COPY pom.xml .
7+
COPY lib-common/pom.xml lib-common/pom.xml
8+
COPY server-rm/pom.xml server-rm/pom.xml
9+
COPY server-cm/pom.xml server-cm/pom.xml
10+
COPY server-qm/pom.xml server-qm/pom.xml
11+
COPY server-am/pom.xml server-am/pom.xml
12+
COPY client-toolchain/pom.xml client-toolchain/pom.xml
13+
14+
# Copy source code for dependencies
15+
COPY lib-common/ lib-common/
16+
COPY server-am/ server-am/
17+
18+
# Build only the specific module and its dependencies
519
RUN mvn -B --no-transfer-progress -DskipTests clean package -pl server-am -am
620

721
FROM docker.io/library/jetty:12-jre21-eclipse-temurin
22+
23+
# Add metadata
24+
LABEL org.opencontainers.image.title="OSLC RefImpl AM Server"
25+
LABEL org.opencontainers.image.description="OSLC Asset Management Reference Implementation"
26+
LABEL org.opencontainers.image.source="https://github.com/oslc-op/refimpl"
27+
LABEL org.opencontainers.image.vendor="OSLC Open Project"
28+
LABEL org.opencontainers.image.licenses="EPL-2.0"
29+
830
# WARNING DO NOT CHANGE WORKDIR or set it back to what it was before
931
# $JETTY_BASE must be correct before starting Jetty
1032

1133
COPY --from=build /src/server-am/target/*.war /var/lib/jetty/webapps/ROOT.war
1234

1335
RUN java -jar "$JETTY_HOME/start.jar" --add-modules=ee9-deploy,ee9-jsp,ee9-jstl
36+
37+
EXPOSE 8080

src/server-cm/Dockerfile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
FROM docker.io/library/maven:3-eclipse-temurin-21-alpine AS build
22

3-
COPY . /src
43
WORKDIR /src
4+
5+
# Copy all pom.xml files and create module directories for Maven structure
6+
COPY pom.xml .
7+
COPY lib-common/pom.xml lib-common/pom.xml
8+
COPY server-rm/pom.xml server-rm/pom.xml
9+
COPY server-cm/pom.xml server-cm/pom.xml
10+
COPY server-qm/pom.xml server-qm/pom.xml
11+
COPY server-am/pom.xml server-am/pom.xml
12+
COPY client-toolchain/pom.xml client-toolchain/pom.xml
13+
14+
# Copy source code for dependencies
15+
COPY lib-common/ lib-common/
16+
COPY server-cm/ server-cm/
17+
18+
# Build only the specific module and its dependencies
519
RUN mvn -B --no-transfer-progress -DskipTests clean package -pl server-cm -am
620

721
FROM docker.io/library/jetty:12-jre21-eclipse-temurin
22+
23+
# Add metadata
24+
LABEL org.opencontainers.image.title="OSLC RefImpl CM Server"
25+
LABEL org.opencontainers.image.description="OSLC Change Management Reference Implementation"
26+
LABEL org.opencontainers.image.source="https://github.com/oslc-op/refimpl"
27+
LABEL org.opencontainers.image.vendor="OSLC Open Project"
28+
LABEL org.opencontainers.image.licenses="EPL-2.0"
29+
830
# WARNING DO NOT CHANGE WORKDIR or set it back to what it was before
931
# $JETTY_BASE must be correct before starting Jetty
1032

1133
COPY --from=build /src/server-cm/target/*.war /var/lib/jetty/webapps/ROOT.war
1234

1335
RUN java -jar "$JETTY_HOME/start.jar" --add-modules=ee9-deploy,ee9-jsp,ee9-jstl
36+
37+
EXPOSE 8080

src/server-qm/Dockerfile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
FROM docker.io/library/maven:3-eclipse-temurin-21-alpine AS build
22

3-
COPY . /src
43
WORKDIR /src
4+
5+
# Copy all pom.xml files and create module directories for Maven structure
6+
COPY pom.xml .
7+
COPY lib-common/pom.xml lib-common/pom.xml
8+
COPY server-rm/pom.xml server-rm/pom.xml
9+
COPY server-cm/pom.xml server-cm/pom.xml
10+
COPY server-qm/pom.xml server-qm/pom.xml
11+
COPY server-am/pom.xml server-am/pom.xml
12+
COPY client-toolchain/pom.xml client-toolchain/pom.xml
13+
14+
# Copy source code for dependencies
15+
COPY lib-common/ lib-common/
16+
COPY server-qm/ server-qm/
17+
18+
# Build only the specific module and its dependencies
519
RUN mvn -B --no-transfer-progress -DskipTests clean package -pl server-qm -am
620

721
FROM docker.io/library/jetty:12-jre21-eclipse-temurin
22+
23+
# Add metadata
24+
LABEL org.opencontainers.image.title="OSLC RefImpl QM Server"
25+
LABEL org.opencontainers.image.description="OSLC Quality Management Reference Implementation"
26+
LABEL org.opencontainers.image.source="https://github.com/oslc-op/refimpl"
27+
LABEL org.opencontainers.image.vendor="OSLC Open Project"
28+
LABEL org.opencontainers.image.licenses="EPL-2.0"
29+
830
# WARNING DO NOT CHANGE WORKDIR or set it back to what it was before
931
# $JETTY_BASE must be correct before starting Jetty
1032

1133
COPY --from=build /src/server-qm/target/*.war /var/lib/jetty/webapps/ROOT.war
1234

1335
RUN java -jar "$JETTY_HOME/start.jar" --add-modules=ee9-deploy,ee9-jsp,ee9-jstl
36+
37+
EXPOSE 8080

src/server-rm/Dockerfile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
FROM docker.io/library/maven:3-eclipse-temurin-21-alpine AS build
22

3-
COPY . /src
43
WORKDIR /src
4+
5+
# Copy all pom.xml files and create module directories for Maven structure
6+
COPY pom.xml .
7+
COPY lib-common/pom.xml lib-common/pom.xml
8+
COPY server-rm/pom.xml server-rm/pom.xml
9+
COPY server-cm/pom.xml server-cm/pom.xml
10+
COPY server-qm/pom.xml server-qm/pom.xml
11+
COPY server-am/pom.xml server-am/pom.xml
12+
COPY client-toolchain/pom.xml client-toolchain/pom.xml
13+
14+
# Copy source code for dependencies
15+
COPY lib-common/ lib-common/
16+
COPY server-rm/ server-rm/
17+
18+
# Build only the specific module and its dependencies
519
RUN mvn -B --no-transfer-progress -DskipTests clean package -pl server-rm -am
620

721
FROM docker.io/library/jetty:12-jre21-eclipse-temurin
22+
23+
# Add metadata
24+
LABEL org.opencontainers.image.title="OSLC RefImpl RM Server"
25+
LABEL org.opencontainers.image.description="OSLC Requirements Management Reference Implementation"
26+
LABEL org.opencontainers.image.source="https://github.com/oslc-op/refimpl"
27+
LABEL org.opencontainers.image.vendor="OSLC Open Project"
28+
LABEL org.opencontainers.image.licenses="EPL-2.0"
29+
830
# WARNING DO NOT CHANGE WORKDIR or set it back to what it was before
931
# $JETTY_BASE must be correct before starting Jetty
1032

1133
COPY --from=build /src/server-rm/target/*.war /var/lib/jetty/webapps/ROOT.war
1234

1335
RUN java -jar "$JETTY_HOME/start.jar" --add-modules=ee9-deploy,ee9-jsp,ee9-jstl
36+
37+
EXPOSE 8080

0 commit comments

Comments
 (0)