Skip to content

Commit

Permalink
Update docker-compose example
Browse files Browse the repository at this point in the history
  • Loading branch information
fr33m0nk committed Jun 29, 2024
1 parent 42d0060 commit ab8e75e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 48 deletions.
15 changes: 7 additions & 8 deletions docker-compose/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
3 changes: 2 additions & 1 deletion docker-compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
49 changes: 24 additions & 25 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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}
Expand All @@ -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
Expand Down

0 comments on commit ab8e75e

Please sign in to comment.