docker refactor

- use latest tag
- use launcher (which builds and deploys the docker compose)
- small fixes
- updated README
This commit is contained in:
pedro 2024-02-16 11:01:46 +01:00
parent 77dd11ea23
commit 397e4978e2
6 changed files with 41 additions and 11 deletions

View File

@ -2,7 +2,8 @@ project := dkr-dsg.ac.upc.edu/ereuse
branch := `git branch --show-current`
commit := `git log -1 --format=%h`
tag := ${branch}__${commit}
#tag := ${branch}__${commit}
tag := latest
# docker images
devicehub_image := ${project}/devicehub:${tag}

View File

@ -55,9 +55,9 @@ If you want to use oidc4vp you need set the vars:
```
You can see the [manual install step 9]('https://github.com/eReuse/devicehub-teal/blob/oidc4vp/README_MANUAL_INSTALLATION.md#installing') for get more detail.
4. Run the docker containers:
4. Build and run the docker containers:
```
docker compose up
./launcher.sh
```
To stop these docker containers you can use Ctl+C, and if you run again "compose up" you'll maintain the data and infrastructure state.
@ -79,6 +79,17 @@ If the deployment was end-to-end successful (two running Devicehub instances suc
That means the two Devicehub instances are running in their containers, that can be reached as http://localhost:5000/ and http://localhost:5001/
Once the devicehub instances are running, you might want to register a user bind to the DLT with the following commands (here, assumes you want to execute it on devicehub-id-client, you might also want to do it in devicehub-id-server). Change the variables accordingly
```
FILE=my_users_devicehub.json
DOCKER_SERVICE=devicehub-id-server
docker compose cp /path/to/${FILE} ${DOCKER_SERVICE}:/tmp/
docker compose exec ${DOCKER_SERVICE} flask dlt_register_user /tmp/${FILE}
```
**my_users_devicehub.json** is a custom file which is similar to the one provided in `examples/users_devicehub.json`
5. To shut down the services and remove the corresponding data, you can use:
```
docker compose down -v

View File

@ -3,7 +3,7 @@ services:
devicehub-id-server:
init: true
image: dkr-dsg.ac.upc.edu/ereuse/devicehub:dpp__c6ec6658
image: dkr-dsg.ac.upc.edu/ereuse/devicehub:latest
environment:
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
@ -32,7 +32,7 @@ services:
- app_id_server:/opt/devicehub:rw
postgres-id-server:
image: dkr-dsg.ac.upc.edu/ereuse/postgres:dpp__c6ec6658
image: dkr-dsg.ac.upc.edu/ereuse/postgres:latest
# 4. To create the database.
# 5. Give permissions to the corresponding users in the database.
# extra src https://github.com/docker-library/docs/blob/master/postgres/README.md#environment-variables
@ -49,7 +49,7 @@ services:
devicehub-id-client:
init: true
image: dkr-dsg.ac.upc.edu/ereuse/devicehub:dpp__c6ec6658
image: dkr-dsg.ac.upc.edu/ereuse/devicehub:latest
environment:
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
@ -78,7 +78,7 @@ services:
- app_id_client:/opt/devicehub:rw
postgres-id-client:
image: dkr-dsg.ac.upc.edu/ereuse/postgres:dpp__c6ec6658
image: dkr-dsg.ac.upc.edu/ereuse/postgres:latest
# 4. To create the database.
# 5. Give permissions to the corresponding users in the database.
# extra src https://github.com/docker-library/docs/blob/master/postgres/README.md#environment-variables

View File

@ -67,6 +67,7 @@ init_data() {
# 11. Generate a minimal data structure.
# TODO it has some errors (?)
flask initdata || true
#flask dlt_register_user /opt/devicehub/examples/users_devicehub.json || true
}
big_error() {
@ -166,7 +167,8 @@ config_dpp_part1() {
config_dpp_part2() {
# 16.
flask check_install "${EMAIL_DEMO}" ${PASSWORD_DEMO}
# commented because this fails with wrong DLT credentials
#flask check_install "${EMAIL_DEMO}" "${PASSWORD_DEMO}"
# 20. config server or client ID
config_oidc
}
@ -187,7 +189,8 @@ config_phase() {
# # 15. Add inventory snapshots for user "${EMAIL_DEMO}".
if [ "${IMPORT_SNAPSHOTS}" = 'y' ]; then
cp /mnt/snapshots/snapshot*.json ereuse_devicehub/commands/snapshot_files
mkdir -p ereuse_devicehub/commands/snapshot_files
cp /mnt/snapshots/snapshot*.json ereuse_devicehub/commands/snapshot_files/
/usr/bin/time flask snapshot "${EMAIL_DEMO}" ${PASSWORD_DEMO}
fi

View File

@ -8,8 +8,8 @@ ABAC_URL=$ABAC_URL
# you might change or register ID_FEDERATED if you change DEVICEHUB_HOST
ID_FEDERATED='DH12'
# TODO this should be guessed by DEVICEHUB_HOST, and avoid hardcode of ID_FEDERATED
SERVER_ID_FEDERATED='DH12'
CLIENT_ID_FEDERATED='DH20'
SERVER_ID_FEDERATED='DH8'
CLIENT_ID_FEDERATED='DH5'
# Database Variables
DB_USER='dhub'

15
launcher.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
set -e
set -u
# DEBUG
set -x
main() {
cd "$(dirname "${0}")"
make docker_build
docker compose up
}
main "${@}"