Skip to content

Commit

Permalink
feat: Update Compose Builder to Support PostgreSQL as Database
Browse files Browse the repository at this point in the history
closes #463

Signed-off-by: Jack Chen <[email protected]>
  • Loading branch information
jackchenjc committed Sep 29, 2024
1 parent 0404495 commit 3534b87
Show file tree
Hide file tree
Showing 7 changed files with 476 additions and 58 deletions.
13 changes: 13 additions & 0 deletions compose-builder/.env
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,26 @@ CP_FLAGS='-cp=consul.http://edgex-core-consul:8500'
REGISTRY_HOST=edgex-core-consul
REGISTRY_PORT=8500
REGISTRY_TYPE=consul
DATABASE_HOST=edgex-redis
DATABASE_TYPE=redis
DATABASE_PORT=6379
MESSAGEBUS_HOST=edgex-redis
MESSAGEBUS_SECRETNAME=redisdb
MESSAGEBUS_AUTHMODE=none
MESSAGEBUS_PORT=6379
MESSAGEBUS_PROTOCOL=redis
MESSAGEBUS_TYPE=redis
WRITABLE_INSECURESECRETS_DB_SECRETNAME=redisdb
WRITABLE_INSECURESECRETS_DB_SECRETDATA_USERNAME=
WRITABLE_INSECURESECRETS_DB_SECRETDATA_PASSWORD=

# Lock on Vault 1.14 (last MPL-2.0 version)
VAULT_VERSION=1.14
# Lock on Consul 1.16 (last MPL-2.0 version)
CONSUL_VERSION=1.16
# Lock on Redis 7.0 until EdgeX 4.0
REDIS_VERSION=7.0-alpine
POSTGRES_VERSION=16.3-alpine3.20
KUIPER_VERSION=v1.14.0-alpha.2
MOSQUITTO_VERSION=2.0
NANOMQ_VERSION=0.18
Expand Down
20 changes: 20 additions & 0 deletions compose-builder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ define OPTIONS
- asc-http asc-mqtt asc-sample asc-metrics as-llrp as-record-replay asc-ex-mqtt -
- modbus-sim zero-trust no-cleanup -
- consul keeper -
- postgres -
endef
export OPTIONS

Expand Down Expand Up @@ -139,6 +140,25 @@ ifeq (keeper, $(filter keeper,$(ARGS)))
export STAGEGATE_REGISTRY_HOST=edgex-core-keeper
export STAGEGATE_REGISTRY_PORT=59890
endif

ifeq (postgres, $(filter postgres,$(ARGS)))
export DATABASE_HOST=edgex-postgres
export DATABASE_TYPE=postgres
export DATABASE_PORT=5432
export MESSAGEBUS_HOST=edgex-mqtt-broker
export MESSAGEBUS_PORT=1883
export MESSAGEBUS_PROTOCOL=tcp
export MESSAGEBUS_TYPE=mqtt
ifeq (no-secty, $(filter no-secty,$(ARGS)))
export WRITABLE_INSECURESECRETS_DB_SECRETNAME=postgres
export WRITABLE_INSECURESECRETS_DB_SECRETDATA_USERNAME=postgres
export WRITABLE_INSECURESECRETS_DB_SECRETDATA_PASSWORD=postgres
endif
endif
endif

ifeq (postgres, $(filter postgres,$(ARGS)))
COMPOSE_FILES:= -f docker-compose-base-postgres.yml
endif

# When in delay-start mode, ensure support services are delay-start-compliant by adding runtime-token configuration
Expand Down
8 changes: 7 additions & 1 deletion compose-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ The `Extending using multiple Compose files` approach along with environment fil
This folder contains the following compose files:

- **docker-compose-base.yml**<br/>
Base non-secure mode compose file. Contains all the services that run in the non-secure configuration, including the UI.
Base non-secure mode compose file. Contains all the services that run in the non-secure configuration, including the UI.
- **docker-compose-base-postgres.yml**<br/>
Base non-secure mode compose file with PostgreSQL as database. Contains all the services that run in the non-secure configuration, including the UI.
- **add-security.yml**<br/>
Security **extending** compose file. Adds the additional security services and configuration of services so that all the services are running in the secure configuration.
- **add-secure-redis-messagebus.yml**<br/>
Expand Down Expand Up @@ -256,6 +258,7 @@ Options:
The NATS Server service is also included.
no-cleanup: Leaves generated files behind for debugging purposes.
keeper: Runs to registry service to core-keeper
postgres: Runs with PostgreSQL as database, 'mqtt-bus' is required when using this option
Services:
<names...>: Runs only services listed (and their dependent services) where 'name' matches a service name in one of the compose files used
```
Expand Down Expand Up @@ -315,6 +318,7 @@ Options:
nats-bus: Pull includes additional services for NATS Message Bus
no-cleanup: Leaves generated files behind for debugging purposes
keeper: Pull includes core-keeper
postgres: Pull includes PostgreSQL
Services:
<names...>: Pulls only images for the service(s) listed
Expand Down Expand Up @@ -373,6 +377,7 @@ Options:
no-cleanup: Leaves generated files behind for debugging purposes.
keeper: Generates compose file with services registry to core-keeper
The core-keeper service is also included
postgres: Generates compose file with PostgreSQL as database, 'mqtt-bus' is required when using this option
```
#### Clean

Expand Down Expand Up @@ -486,6 +491,7 @@ Options:
The NATS Server service is also included.
no-cleanup: Leaves generated files behind for debugging purposes.
keeper: Generates compose file to registry service to core-keeper
postgres: Generates compose file with PostgreSQL as database, 'mqtt-bus' is required when using this option
```

#### TAF Compose
Expand Down
13 changes: 11 additions & 2 deletions compose-builder/add-keeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ services:
env_file:
- common-non-security.env
environment:
DATABASE_HOST: edgex-redis
MESSAGEBUS_HOST: edgex-redis
DATABASE_HOST: ${DATABASE_HOST}
DATABASE_TYPE: ${DATABASE_TYPE}
DATABASE_PORT: ${DATABASE_PORT}
MESSAGEBUS_HOST: ${MESSAGEBUS_HOST}
MESSAGEBUS_AUTHMODE: ${MESSAGEBUS_AUTHMODE}
MESSAGEBUS_PORT: ${MESSAGEBUS_PORT}
MESSAGEBUS_PROTOCOL: ${MESSAGEBUS_PROTOCOL}
MESSAGEBUS_TYPE: ${MESSAGEBUS_TYPE}
WRITABLE_INSECURESECRETS_DB_SECRETNAME: ${WRITABLE_INSECURESECRETS_DB_SECRETNAME}
WRITABLE_INSECURESECRETS_DB_SECRETDATA_USERNAME: ${WRITABLE_INSECURESECRETS_DB_SECRETDATA_USERNAME}
WRITABLE_INSECURESECRETS_DB_SECRETDATA_PASSWORD: ${WRITABLE_INSECURESECRETS_DB_SECRETDATA_PASSWORD}
SERVICE_HOST: edgex-core-keeper
security_opt:
- no-new-privileges:true
Expand Down
Loading

0 comments on commit 3534b87

Please sign in to comment.