Skip to content

Commit 4210ae2

Browse files
authored
ADD Docker build images, test, release (#27)
* ADD Docker build images, test, release * macos x64 * comment linux/s390x * get version from official release * get version from official release OpenICF * get version from official release OpenICF * get version from official release by API * get version from official release by API * fix context release.yml
1 parent c6f0f0f commit 4210ae2

File tree

5 files changed

+260
-1
lines changed

5 files changed

+260
-1
lines changed

.github/workflows/build.yml

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
java: [ '8', '11', '17', '21' ]
14-
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
14+
os: [ 'ubuntu-latest', 'macos-12', 'windows-latest' ]
1515
fail-fast: false
1616
steps:
1717
- uses: actions/checkout@v4
@@ -86,3 +86,98 @@ jobs:
8686
OpenICF-ssh-connector/target/*.jar
8787
OpenICF-xml-connector/target/*.jar
8888
!**/*-sources.jar
89+
build-docker:
90+
runs-on: 'ubuntu-latest'
91+
services:
92+
registry:
93+
image: registry:2
94+
ports:
95+
- 5000:5000
96+
steps:
97+
- uses: actions/checkout@v4
98+
with:
99+
fetch-depth: 0
100+
- name: Get latest release version
101+
shell: bash
102+
run: |
103+
export git_version_last="$(curl -i -o - --silent https://api.github.com/repos/OpenIdentityPlatform/OpenICF/releases/latest | grep -m1 "\"name\"" | cut -d\" -f4)" ; echo "last release: $git_version_last"
104+
echo "release_version=$git_version_last" >> $GITHUB_ENV
105+
- name: Docker meta
106+
id: meta
107+
uses: docker/metadata-action@v5
108+
with:
109+
images: |
110+
localhost:5000/${{ github.repository }}
111+
tags: |
112+
type=raw,value=${{ env.release_version }}
113+
- name: Set up QEMU
114+
uses: docker/setup-qemu-action@v3
115+
- name: Set up Docker Buildx
116+
uses: docker/setup-buildx-action@v3
117+
with:
118+
driver-opts: network=host
119+
- name: Build image (default)
120+
uses: docker/build-push-action@v5
121+
continue-on-error: true
122+
with:
123+
context: .
124+
file: ./Dockerfile
125+
build-args: |
126+
VERSION=${{ env.release_version }}
127+
platforms: linux/amd64, linux/arm64/8, linux/arm/v7, linux/ppc64le #, linux/s390x
128+
push: true
129+
tags: ${{ steps.meta.outputs.tags }}
130+
labels: ${{ steps.meta.outputs.labels }}
131+
- name: Docker test
132+
shell: bash
133+
run: |
134+
docker run --rm -it -d --memory="1g" --name=test localhost:5000/${GITHUB_REPOSITORY,,}:${{ env.release_version }}
135+
timeout 3m bash -c 'until docker inspect --format="{{json .State.Health.Status}}" test | grep -q \"healthy\"; do sleep 10; done'
136+
build-docker-alpine:
137+
runs-on: 'ubuntu-latest'
138+
services:
139+
registry:
140+
image: registry:2
141+
ports:
142+
- 5000:5000
143+
steps:
144+
- uses: actions/checkout@v4
145+
with:
146+
fetch-depth: 0
147+
- name: Get latest release version
148+
shell: bash
149+
run: |
150+
export git_version_last="$(curl -i -o - --silent https://api.github.com/repos/OpenIdentityPlatform/OpenICF/releases/latest | grep -m1 "\"name\"" | cut -d\" -f4)" ; echo "last release: $git_version_last"
151+
echo "release_version=$git_version_last" >> $GITHUB_ENV
152+
- name: Docker meta
153+
id: meta
154+
uses: docker/metadata-action@v5
155+
with:
156+
images: |
157+
localhost:5000/${{ github.repository }}
158+
tags: |
159+
type=raw,value=alpine
160+
type=raw,value=${{ env.release_version }}-alpine
161+
- name: Set up QEMU
162+
uses: docker/setup-qemu-action@v3
163+
- name: Set up Docker Buildx
164+
uses: docker/setup-buildx-action@v3
165+
with:
166+
driver-opts: network=host
167+
- name: Build image
168+
continue-on-error: true
169+
uses: docker/build-push-action@v5
170+
with:
171+
context: .
172+
file: ./Dockerfile-alpine
173+
build-args: |
174+
VERSION=${{ env.release_version }}
175+
platforms: linux/amd64,linux/arm64/8, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6, linux/ppc64le
176+
push: true
177+
tags: ${{ steps.meta.outputs.tags }}
178+
labels: ${{ steps.meta.outputs.labels }}
179+
- name: Docker test
180+
shell: bash
181+
run: |
182+
docker run --rm -it -d --memory="1g" --name=test localhost:5000/${GITHUB_REPOSITORY,,}:${{ env.release_version }}-alpine
183+
timeout 3m bash -c 'until docker inspect --format="{{json .State.Health.Status}}" test | grep -q \"healthy\"; do sleep 10; done'

.github/workflows/release.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,99 @@ jobs:
7676
OpenICF-ldap-connector/target/*.jar
7777
OpenICF-ssh-connector/target/*.jar
7878
OpenICF-xml-connector/target/*.jar
79+
release-docker:
80+
name: Docker release
81+
runs-on: 'ubuntu-latest'
82+
needs:
83+
- release-maven
84+
steps:
85+
- uses: actions/checkout@v4
86+
with:
87+
ref: ${{ github.event.inputs.releaseVersion }}
88+
fetch-depth: 1
89+
submodules: recursive
90+
- name: Docker meta
91+
id: meta
92+
uses: docker/metadata-action@v5
93+
with:
94+
images: |
95+
${{ github.repository }}
96+
ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}
97+
tags: |
98+
type=raw,value=latest
99+
type=raw,value=${{ github.event.inputs.releaseVersion }}
100+
- name: Set up QEMU
101+
uses: docker/setup-qemu-action@v3
102+
- name: Set up Docker Buildx
103+
uses: docker/setup-buildx-action@v3
104+
- name: Login to DockerHub
105+
uses: docker/login-action@v3
106+
with:
107+
username: ${{ secrets.DOCKER_USERNAME }}
108+
password: ${{ secrets.DOCKER_PASSWORD }}
109+
- name: Login to GHCR
110+
uses: docker/login-action@v3
111+
with:
112+
registry: ghcr.io
113+
username: ${{ github.repository_owner }}
114+
password: ${{ secrets.GITHUB_TOKEN }}
115+
- name: Build and push image
116+
uses: docker/build-push-action@v5
117+
continue-on-error: true
118+
with:
119+
context: .
120+
file: ./Dockerfile
121+
build-args: |
122+
VERSION=${{ github.event.inputs.releaseVersion }}
123+
platforms: linux/amd64, linux/arm64/8, linux/arm/v7, linux/ppc64le #, linux/s390x
124+
push: true
125+
tags: ${{ steps.meta.outputs.tags }}
126+
labels: ${{ steps.meta.outputs.labels }}
127+
release-docker-alpine:
128+
name: Docker release
129+
runs-on: 'ubuntu-latest'
130+
needs:
131+
- release-maven
132+
steps:
133+
- uses: actions/checkout@v4
134+
with:
135+
ref: ${{ github.event.inputs.releaseVersion }}
136+
fetch-depth: 1
137+
submodules: recursive
138+
- name: Docker meta
139+
id: meta
140+
uses: docker/metadata-action@v5
141+
with:
142+
images: |
143+
${{ github.repository }}
144+
ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}
145+
tags: |
146+
type=raw,value=alpine
147+
type=raw,value=${{ github.event.inputs.releaseVersion }}-alpine
148+
- name: Set up QEMU
149+
uses: docker/setup-qemu-action@v3
150+
- name: Set up Docker Buildx
151+
uses: docker/setup-buildx-action@v3
152+
- name: Login to DockerHub
153+
uses: docker/login-action@v3
154+
with:
155+
username: ${{ secrets.DOCKER_USERNAME }}
156+
password: ${{ secrets.DOCKER_PASSWORD }}
157+
- name: Login to GHCR
158+
uses: docker/login-action@v3
159+
with:
160+
registry: ghcr.io
161+
username: ${{ github.repository_owner }}
162+
password: ${{ secrets.GITHUB_TOKEN }}
163+
- name: Build and push image
164+
continue-on-error: true
165+
uses: docker/build-push-action@v5
166+
with:
167+
context: .
168+
file: ./Dockerfile-alpine
169+
build-args: |
170+
VERSION=${{ github.event.inputs.releaseVersion }}
171+
platforms: linux/amd64,linux/arm64/8, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6, linux/ppc64le
172+
push: true
173+
tags: ${{ steps.meta.outputs.tags }}
174+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM eclipse-temurin:8-jre-jammy
2+
3+
MAINTAINER Open Identity Platform Community <[email protected]>
4+
5+
ENV USER="openicf"
6+
ENV OPENICF_OPTS="-server -XX:+UseContainerSupport"
7+
8+
ARG VERSION
9+
10+
WORKDIR /opt
11+
12+
#COPY OpenICF-java-framework/openicf-zip/target/*.zip ./
13+
14+
RUN apt-get update
15+
RUN apt-get install -y --no-install-recommends curl unzip
16+
RUN if [ ! -z "$VERSION" ] ; then rm -rf ./*.zip ; curl -L https://github.com/OpenIdentityPlatform/OpenICF/releases/download/$VERSION/openicf-$VERSION.zip --output openicf-$VERSION.zip ; fi
17+
RUN unzip openicf-*.zip && rm -rf *.zip
18+
RUN apt-get remove -y --purge unzip
19+
RUN rm -rf /var/lib/apt/lists/*
20+
RUN groupadd $USER
21+
RUN useradd -m -r -u 1001 -g $USER $USER
22+
RUN install -d -o $USER /opt/openicf
23+
RUN chown -R $USER:$USER /opt/openicf
24+
RUN chmod -R g=u /opt/openicf
25+
RUN chmod +x /opt/openicf/bin/*.sh
26+
27+
EXPOSE 8759
28+
29+
USER $USER
30+
31+
HEALTHCHECK --interval=30s --timeout=30s --start-period=1s --retries=3 CMD curl -i -o - --silent http://127.0.0.1:8759/openicf | grep -q "OpenICF Connector Server"
32+
33+
ENTRYPOINT ["/opt/openicf/bin/ConnectorServer.sh","/run"]

Dockerfile-alpine

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM openjdk:8-jre-alpine
2+
3+
MAINTAINER Open Identity Platform Community <[email protected]>
4+
5+
ENV USER="openicf"
6+
ENV OPENICF_OPTS="-server -XX:+UseContainerSupport"
7+
8+
ARG VERSION
9+
10+
WORKDIR /opt
11+
12+
#COPY OpenICF-java-framework/openicf-zip/target/*.zip ./
13+
14+
RUN apk add --update --no-cache --virtual builddeps curl unzip
15+
RUN apk upgrade --update --no-cache
16+
RUN apk add bash
17+
RUN if [ ! -z "$VERSION" ] ; then rm -rf ./*.zip ; curl -L https://github.com/OpenIdentityPlatform/OpenICF/releases/download/$VERSION/openicf-$VERSION.zip --output openicf-$VERSION.zip ; fi
18+
RUN unzip openicf-*.zip && rm -rf *.zip
19+
RUN apk del unzip
20+
RUN addgroup -S $USER
21+
RUN adduser -S -u 1001 -G $USER $USER
22+
RUN install -d -o $USER /opt/openicf
23+
RUN chown -R $USER:$USER /opt/openicf
24+
RUN chmod -R g=u /opt/openicf
25+
RUN chmod +x /opt/openicf/bin/*.sh
26+
27+
EXPOSE 8759
28+
29+
USER $USER
30+
31+
HEALTHCHECK --interval=30s --timeout=30s --start-period=1s --retries=3 CMD curl -i -o - --silent http://127.0.0.1:8759/openicf | grep -q "OpenICF Connector Server"
32+
33+
ENTRYPOINT ["/opt/openicf/bin/ConnectorServer.sh","/run"]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[![Last commit](https://img.shields.io/github/last-commit/OpenIdentityPlatform/OpenICF.svg)](https://github.com/OpenIdentityPlatform/OpenICF/commits/master)
77
[![License](https://img.shields.io/badge/license-CDDL-blue.svg)](https://github.com/OpenIdentityPlatform/OpenICF/blob/master/LICENSE.md)
88
[![Downloads](https://img.shields.io/github/downloads/OpenIdentityPlatform/OpenICF/total.svg)](https://github.com/OpenIdentityPlatform/OpenICF/releases)
9+
[![Docker](https://img.shields.io/docker/pulls/openidentityplatform/openicf.svg)](https://hub.docker.com/r/openidentityplatform/openicf)
910
[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/OpenIdentityPlatform/OpenIDM)
1011
[![Top language](https://img.shields.io/github/languages/top/OpenIdentityPlatform/OpenICF.svg)](https://github.com/OpenIdentityPlatform/OpenICF)
1112
[![Code size in bytes](https://img.shields.io/github/languages/code-size/OpenIdentityPlatform/OpenICF.svg)](https://github.com/OpenIdentityPlatform/OpenICF)
@@ -26,6 +27,7 @@ This project is licensed under the [Common Development and Distribution License
2627

2728
## Downloads
2829
* [OpenICF ZIP](https://github.com/OpenIdentityPlatform/OpenICF/releases)
30+
* [OpenICF Docker](https://hub.docker.com/r/openidentityplatform/openicf/)
2931

3032
### OpenICF Java connectors:
3133
* [csvfile-connector](https://github.com/OpenIdentityPlatform/OpenICF/releases)

0 commit comments

Comments
 (0)