Skip to content

Commit f4e0874

Browse files
jann0kmir-jalal
andauthored
Build & publish cdoc2-shares-server docker image to ghcr.io (#1)
* fix GH workflow deploy (deploy Maven and Docker images on release) * fix cdoc2-shares-server-liquibase Docker building * remove test dependency for cdoc2-client when building without tests (-Dmaven.test.skip=true) --------- Co-authored-by: Mir Jalal Hashimli <[email protected]>
1 parent 3e7f647 commit f4e0874

18 files changed

+117
-161
lines changed

.env

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
SHARES_SERVER_VERSION=latest
1+
#SHARES_SERVER_VERSION=latest
22
# SHARES_SERVER_VERSION=latest
3-
SHARES_SERVER_DB_VERSION=0.1.0
3+
#SHARES_SERVER_DB_VERSION=0.1.0
44
# don't set DOCKER_REGISTRY when working only locally
55
# DOCKER_REGISTRY=
6-
DOCKER_REGISTRY=gitlab.ext.cyber.ee:5050/cdoc2/
6+
#DOCKER_REGISTRY=gitlab.ext.cyber.ee:5050/cdoc2/
7+
DOCKER_REGISTRY=ghcr.io
78
# database properties
89
POSTGRES_URL=cdoc2-shares-postgres:5432
910
POSTGRES_DB=super-awesome-shares-server

.github/workflows/docker-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
name: Create and publish a Docker cdoc2-server-liquibase image
2+
name: Create and publish a Docker cdoc2-shares-server-liquibase image
33

44
# Configures this workflow to run every time release is created
55
on:
@@ -9,7 +9,7 @@ on:
99
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
1010
env:
1111
REGISTRY: ghcr.io
12-
IMAGE_NAME: cdoc2-server-liquibase
12+
IMAGE_NAME: cdoc2-shares-server-liquibase
1313
#IMAGE_NAME: ${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/shares-server:${TAG}-${GITHUB_SHA}
1414

1515
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.

.github/workflows/maven-release.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
22
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
33

4-
name: Publish to cdoc2-shares-server GitHub Packages Apache Maven (Maven repository)
4+
name: Publish to cdoc2-shares-server GitHub Packages (Maven and Container)
55

66
on:
77
release:
@@ -28,9 +28,9 @@ jobs:
2828
# Here: deploy for each submodule is necessary
2929
# to deploy submodules even when main module didn't change
3030
- name: Publish to GitHub Packages Apache Maven
31+
if: true
3132
run: |
32-
mvn deploy -s $GITHUB_WORKSPACE/settings.xml
33-
mvn -f shared-crypto deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
33+
mvn deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
3434
mvn -f server-openapi deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
3535
mvn -f server-db deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
3636
mvn -f shares-server deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
@@ -55,9 +55,8 @@ jobs:
5555
-Ddocker.publishRegistry.url=${REGISTRY} \
5656
-Ddocker.publishRegistry.username=${USERNAME} \
5757
-Ddocker.publishRegistry.password=${GITHUB_TOKEN} \
58-
-Dspring-boot.build-image
59-
.imageName=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/shares-server:${TAG}-${GITHUB_SHA} \
60-
-Dspring-boot.build-image.tags=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/shares-server:latest
58+
-Dspring-boot.build-image.imageName=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/cdoc2-shares-server:${TAG}-${GITHUB_SHA} \
59+
-Dspring-boot.build-image.tags=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/cdoc2-shares-server:latest
6160
env:
6261
REGISTRY: ghcr.io
6362
USERNAME: ${{ github.actor }}
@@ -68,5 +67,3 @@ jobs:
6867
TAG: ${{ github.event.release.tag_name }}
6968
# use open-eid Maven repo for dependencies download, see pom.xml
7069
MAVEN_REPO: open-eid/cdoc2-shares-server
71-
72-

.github/workflows/maven.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ jobs:
6666
cache: maven
6767

6868
- name: Build with Maven
69+
# temporary dislable tests as SID version of cdoc2-client is not available from GH
6970
run: |
7071
echo "Debug env vars: is_fork=$IS_FORK base_repo=$BASE_REPO MAVEN_REPO=$MAVEN_REPO"
7172
mvn help:active-profiles
7273
echo "Using Maven repo=$(mvn help:evaluate -Dexpression=github_ci.maven_repo -q -DforceStdout)"
73-
mvn -B verify
74+
mvn -B verify -Dmaven.test.skip=true
7475
env:
7576
GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
7677
IS_FORK: ${{needs.fork_setup.outputs.is_fork}}

README-DOCKER.md

Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,16 @@
11
# Build and run CDOC2 components
22

3+
TODO: This document is not up to date. See cdoc2-java-ref-impl/test/README.md for working docker-compose example
4+
35
## Build binaries
46

57
Follow the instructions in [Main README](README.md#building) to build all Java binaries
68

7-
## Docker usage
8-
9-
There are two docker compose files:
10-
11-
* docker-compose.yml - to run database scripts from source code
12-
* docker-compose-with-pre-made-images.yml - use pre-made liquibase image for database configuration
13-
14-
To install the latest Docker Compose version see https://docs.docker.com/compose/install/
15-
16-
`.env` file contains environment variables needed to create docker images and run docker compose.
17-
18-
To create new shares-server image run `build-image.sh` in `shares-server` directory:
19-
```bash
20-
cd shares-server
21-
./build-image.sh
22-
```
23-
24-
Change to project root and to check if everything is boots up correctly run docker compose in terminal window:
9+
Build Docker images locally:
2510
```bash
26-
docker compose -f docker-compose.yml up --build
11+
./build-images.sh
2712
```
2813

29-
When all good then exit the process and run again detached mode:
30-
```bash
31-
docker kill $(docker ps -q); docker rm $(docker ps -a -q)
32-
docker compose -f docker-compose.yml up -d
33-
```
34-
35-
Application properties are loaded from `config/application.properties.docker` file.
36-
37-
All certificates and related are loaded from `keys` directory.
38-
39-
For more details on creating server certificates and trust stores, see [Generating Server keystore](keys/README.md).
40-
41-
42-
### Build Docker liquibase image
43-
44-
Check the `.env` file for properties.
45-
46-
To create our pre-configured liquibase image run `create-liquibase-chanteset-image.sh` in
47-
`server-db` directory:
48-
```bash
49-
cd server-db
50-
./create-liquibase-chanteset-image.sh
51-
```
52-
53-
To use our pre-configured liquibase image run in project root:
54-
```bash
55-
docker compose -f docker-compose-with-pre-made-images.yml up --build
56-
```
5714

5815
## Testing
5916

@@ -68,28 +25,5 @@ curl -k https://localhost:18443/actuator/health
6825

6926
### Encrypt a file using CDOC2 Key Shares Server
7027

71-
In the `cdoc2-java-ref-impl/cdoc2-cli` repo execute:
72-
73-
```
74-
java -jar target/cdoc2-cli-*.jar create \
75-
--server=config/localhost/localhost.properties \
76-
-f /path/to/enrypted-file.cdoc \
77-
-r EST_ID_CODE \
78-
/path/to/input-file
79-
```
80-
81-
Replace `EST_ID_CODE` with the Estonian identification code of the recipient.
82-
83-
### Decrypt a file using CDOC2 Key Shares Server
84-
85-
In the `cdoc2-java-ref-impl/cdoc2-cli` repo execute:
86-
87-
```
88-
java -jar target/cdoc2-cli*.jar decrypt \
89-
--server=config/localhost/localhost.properties \
90-
-f /path/to/enrypted-file.cdoc \
91-
-o /path/to/derypted-file.cdoc
92-
```
93-
94-
For more details on how to use `cdoc2-cli` see [CDOC2 CLI](../cdoc2-cli/README.md).
28+
See `cdoc2-java-ref-impl/cdoc2-cli/README.md` for more details on how to encrypt/decrypt using Smart-ID.
9529

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ See [getting-started.md](getting-started.md) and [admin-guide.md](admin-guide.md
7373

7474
### Running pre-built Docker/OCI images
7575

76-
TODO:
76+
See [cdoc2-java-ref-impl](https://github.com/open-eid/cdoc2-java-ref-impl)/test/config/shares-server/docker-compose.yml
7777

7878
## Releasing and versioning
7979

build-images.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# build Docker images locally
4+
PROJECT_DIR=$(pwd)
5+
6+
cd $PROJECT_DIR/shares-server
7+
bash build-image.sh
8+
9+
cd $PROJECT_DIR/server-db
10+
bash build-image.sh
11+
12+
cd $PROJECT_DIR

docker-compose-with-pre-made-images.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Not up to date, see https://github.com/open-eid/cdoc2-java-ref-impl/test/README.md for working docker example
12
services:
23
cdoc2-shares-postgres:
34
container_name: cdoc2-shares-postgres

docker-compose.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Not up to date, see https://github.com/open-eid/cdoc2-java-ref-impl/test/README.md for working docker example
12
services:
23
cdoc2-shares-postgres:
34
container_name: cdoc2-shares-postgres
@@ -49,6 +50,8 @@ services:
4950
target: /config/servertruststore.jks
5051
- source: keystore
5152
target: /config/cdoc2server.p12
53+
- source: sid-trusted-issuers-truststore
54+
target: /config/sid_trusted_issuers.jks
5255
environment:
5356
- SPRING_CONFIG_ADDITIONAL_LOCATION=optional:file:/config/application.properties
5457
- POSTGRES_URL=${POSTGRES_URL}
@@ -79,6 +82,8 @@ services:
7982
target: /config/servertruststore.jks
8083
- source: keystore
8184
target: /config/cdoc2server.p12
85+
- source: sid-trusted-issuers-truststore
86+
target: /config/sid_trusted_issuers.jks
8287
environment:
8388
- SPRING_CONFIG_ADDITIONAL_LOCATION=optional:file:/config/application.properties
8489
- POSTGRES_URL=${POSTGRES_URL}
@@ -98,4 +103,6 @@ configs:
98103
truststore:
99104
file: ./keys/servertruststore.jks
100105
keystore:
101-
file: ./keys/cdoc2server.p12
106+
file: ./keys/cdoc2server.p12
107+
sid-trusted-issuers-truststore:
108+
file: ./shares-server/test/resources/sid-trusted-issuers/test_sid_trusted_issuers.jks

postgres.README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## Create postgres instance inside docker
22

33
```
4-
docker run --name cdoc2-psql -p 5432:5432 -e POSTGRES_DB=cdoc2-shares -e POSTGRES_PASSWORD=secret -d postgres
4+
docker run --name cdoc2-shares-psql -p 5432:5432 -e POSTGRES_DB=cdoc2-shares -e POSTGRES_PASSWORD=secret -d postgres
55
6-
docker start cdoc2-psql
7-
docker stop cdoc2-psql
6+
docker start cdoc2-shares-psql
7+
docker stop cdoc2-shares-psql
88
```
99
#docker rm cdoc2-psql
1010

@@ -16,18 +16,18 @@ image (version must match server version) that contains liquibase changeset file
1616
server version and create a `cdoc2-shares` database. If database is running inside Docker,
1717
then `--link` is required, so that liquibase container can connect to it.
1818
```
19-
docker run --rm --link cdoc2-psql \
19+
docker run --rm --link cdoc2-shares-psql \
2020
--env DB_URL=jdbc:postgresql://cdoc2-psql/cdoc2-shares \
2121
--env DB_PASSWORD=secret \
2222
--env DB_USER=postgres \
23-
ghcr.io/open-eid/cdoc2-server-liquibase:v1.4.1-rc.1-74cbc827e3cf08c2f4a51711a2072b6344f9aee1
23+
ghcr.io/open-eid/cdoc2-shares-server-liquibase:latest
2424
```
2525

2626
or use standard liquibase command:
2727

2828
```
29-
docker run --rm --link cdoc2-psql \
30-
ghcr.io/open-eid/cdoc2-server-liquibase:v1.4.1-rc.1-74cbc827e3cf08c2f4a51711a2072b6344f9aee1 \
29+
docker run --rm --link cdoc2-shares-psql \
30+
ghcr.io/open-eid/cdoc2-shares-server-liquibase:latest \
3131
--url jdbc:postgresql://cdoc2-psql/cdoc2-shares \
3232
--username=postgres \
3333
--password=secret \
@@ -39,7 +39,3 @@ Can also be used to update DB running in other host by changing `--url`, `--user
3939
Then `--link` is not required.
4040

4141
More info https://hub.docker.com/r/liquibase/liquibase
42-
43-
## Or use docker-compose.yml
44-
45-
Follow the instruction in `docker/README.md`.

0 commit comments

Comments
 (0)