diff --git a/docker-compose/.env b/docker-compose/.env index 802a547..0d686b4 100644 --- a/docker-compose/.env +++ b/docker-compose/.env @@ -4,9 +4,16 @@ MEMCACHED_HOST_MAPPING_PORT=11211 POSTGRES_CONTAINER_TAG=16.1-bullseye POSTGRES_HOST_MAPPING_PORT=5432 +POSTGRES_USER=postgres POSTGRES_PASSWORD=mysecretpassword +SQL_USER=datomic +SQL_PASSWORD=datomic +SQL_JDBC_URL=jdbc:postgresql://postgres:5432/datomic +SQL_DRIVER_CLASS=org.postgresql.Driver + DATOMIC_VERSION=1.0.7075 +PROTOCOL=SQL DATOMIC_DB_NAME=test-database DATOMIC_DB_CREATION_RETRIES=5 @@ -18,11 +25,3 @@ CONSOLE_HOST_MAPPING_PORT=8888 IPV4_SUBNET_CIDR=192.168.29.0/24 IP_RANGE=192.168.29.64/26 GATEWAY_IP=192.168.29.1 - -MEMCACHED_IP=192.168.29.101 -PG_IP=192.168.29.102 -PG_MIGRATOR_IP=192.168.29.103 -DATOMIC_TRANSACTOR_IP=192.168.29.104 -DATOMIC_DB_INIT_IP=192.168.29.105 -DATOMIC_PEER_IP=192.168.29.106 -DATOMIC_CONSOLE_IP=192.168.29.107 diff --git a/docker-compose/README.md b/docker-compose/README.md index f5216f2..1ac1760 100644 --- a/docker-compose/README.md +++ b/docker-compose/README.md @@ -28,7 +28,8 @@ docker compose up --build transactor peer datomic-db-initialization console -d (require '[datomic.api :as d]) ;; nil -(def db-uri (format "datomic:sql://%s?jdbc:postgresql://localhost:5432/datomic?user=datomic&password=datomic" DATOMIC_DB_NAME)) +;; assuming DATOMIC DB name is stored in environment variable `DATOMIC_DB_NAME` +(def db-uri (format "datomic:sql://%s?jdbc:postgresql://localhost:5432/datomic?user=datomic&password=datomic" (System/getenv "DATOMIC_DB_NAME"))) ;; #'user/db-uri user=> (d/connect db-uri) diff --git a/docker-compose/datomic-database-initialization/initialize_database.clj b/docker-compose/datomic-database-initialization/initialize_database.clj index 1174cc0..ef0d2d5 100644 --- a/docker-compose/datomic-database-initialization/initialize_database.clj +++ b/docker-compose/datomic-database-initialization/initialize_database.clj @@ -1,20 +1,11 @@ (require '[datomic.api :as d]) (import '[clojure.lang ExceptionInfo]) -(def DATOMIC_DB_NAME (System/getenv "DATOMIC_DB_NAME")) - -(def PG_HOST (System/getenv "PG_HOST")) - -(def PG_PORT (System/getenv "PG_PORT")) - -(def PG_DATABASE (System/getenv "PG_DATABASE")) - -(def PG_USER (System/getenv "PG_USER")) - -(def PG_PASSWORD (System/getenv "PG_PASSWORD")) - -(def uri (format "datomic:sql://%s?jdbc:postgresql://%s:%s/%s?user=%s&password=%s" - DATOMIC_DB_NAME PG_HOST PG_PORT PG_DATABASE PG_USER PG_PASSWORD)) +(def uri (format "datomic:sql://%s?%s?user=%s&password=%s" + (System/getenv "DATOMIC_DB_NAME") + (System/getenv "SQL_JDBC_URL") + (System/getenv "SQL_USER") + (System/getenv "SQL_PASSWORD"))) (defn database-migrator [uri] diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 8b2849b..8af008c 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -20,7 +20,7 @@ services: postgres: container_name: postgres environment: - - POSTGRES_USER=postgres + - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} image: postgres:${POSTGRES_CONTAINER_TAG} command: postgres -c 'max_connections=1024' @@ -41,7 +41,7 @@ services: postgres-migrator: container_name: postgres-migrator environment: - - PGUSER=postgres + - PGUSER=${POSTGRES_USER} - PGPASSWORD=${POSTGRES_PASSWORD} image: postgres:16.1-bullseye volumes: @@ -70,13 +70,13 @@ services: - "9999:9999" environment: - RUN_MODE=TRANSACTOR + - PROTOCOL=${PROTOCOL} + - SQL_USER=${SQL_USER} + - SQL_PASSWORD=${SQL_PASSWORD} - TRANSACTOR_HOST=192.168.200.4 - TRANSACTOR_ALT_HOST=127.0.0.1 - - PG_HOST=postgres - - PG_PORT=5432 - - PG_PASSWORD=datomic - - PG_USER=datomic - - PG_DATABASE=datomic + - SQL_JDBC_URL=${SQL_JDBC_URL} + - SQL_DRIVER_CLASS=${SQL_DRIVER_CLASS} - MEMCACHED_HOST=192.168.200.2 volumes: - datomic-transactor-log:/datomic-pro/log @@ -101,14 +101,14 @@ services: build: context: ../ args: - DATOMIC_VERSION: 1.0.7075 + DATOMIC_VERSION: ${DATOMIC_VERSION} dockerfile: Dockerfile environment: - - PG_HOST=postgres - - PG_PORT=5432 - - PG_PASSWORD=datomic - - PG_USER=datomic - - PG_DATABASE=datomic + - RUN_MODE=TRANSACTOR + - PROTOCOL=${PROTOCOL} + - SQL_USER=${SQL_USER} + - SQL_PASSWORD=${SQL_PASSWORD} + - SQL_JDBC_URL=${SQL_JDBC_URL} - DATOMIC_DB_NAME=${DATOMIC_DB_NAME} - RETRIES=${DATOMIC_DB_CREATION_RETRIES} volumes: @@ -132,18 +132,17 @@ services: build: context: ../ args: - DATOMIC_VERSION: 1.0.7075 + DATOMIC_VERSION: ${DATOMIC_VERSION} dockerfile: Dockerfile ports: - "8998:8998" environment: - RUN_MODE=PEER + - PROTOCOL=${PROTOCOL} - PEER_HOST=192.168.200.5 - - PG_HOST=postgres - - PG_PORT=5432 - - PG_PASSWORD=datomic - - PG_USER=datomic - - PG_DATABASE=datomic + - SQL_USER=${SQL_USER} + - SQL_PASSWORD=${SQL_PASSWORD} + - SQL_JDBC_URL=${SQL_JDBC_URL} - DATOMIC_DB_NAME=${DATOMIC_DB_NAME} - PEER_ACCESSKEY=${PEER_ACCESSKEY} - PEER_SECRET=${PEER_SECRET} @@ -166,17 +165,17 @@ services: build: context: ../ args: - DATOMIC_VERSION: 1.0.7075 + DATOMIC_VERSION: ${DATOMIC_VERSION} dockerfile: Dockerfile ports: - ${CONSOLE_HOST_MAPPING_PORT}:8888 environment: - RUN_MODE=CONSOLE - - PG_HOST=postgres - - PG_PORT=5432 - - PG_PASSWORD=datomic - - PG_USER=datomic - - PG_DATABASE=datomic + - PROTOCOL=${PROTOCOL} + - SQL_JDBC_URL=${SQL_JDBC_URL} + - SQL_USER=${SQL_USER} + - SQL_PASSWORD=${SQL_PASSWORD} + - TRANSACTOR_ALIAS=home-txn networks: datomic-network: ipv4_address: 192.168.200.6