Parcourir la source

docker-compose: persist voumes

Mokhtar Naamani il y a 3 ans
Parent
commit
6dd6b1304f
2 fichiers modifiés avec 65 ajouts et 29 suppressions
  1. 38 12
      docker-compose.yml
  2. 27 17
      start.sh

+ 38 - 12
docker-compose.yml

@@ -12,7 +12,7 @@ services:
       dockerfile: joystream-node.Dockerfile
     container_name: joystream-node
     volumes:
-      - /data
+      - chain-data:/data
     command: --dev --alice --validator --unsafe-ws-external --unsafe-rpc-external --rpc-methods Unsafe --rpc-cors=all --log runtime --base-path /data
     ports:
       - '127.0.0.1:9944:9944'
@@ -23,8 +23,8 @@ services:
     container_name: colossus-1
     restart: on-failure
     volumes:
-      - /data
-      - /keystore
+      - colossus-1-data:/data
+      - colossus-1-keystore:/keystore
       - type: bind
         source: .
         target: /joystream
@@ -49,9 +49,9 @@ services:
     container_name: distributor-1
     restart: on-failure
     volumes:
-      - /data
-      - /cache
-      - /logs
+      - distributor-1-data:/data
+      - distributor-1-cache:/cache
+      - distributor-1-logs:/logs
       - type: bind
         source: .
         target: /joystream
@@ -86,8 +86,8 @@ services:
     container_name: colossus-2
     restart: on-failure
     volumes:
-      - /data
-      - /keystore
+      - colossus-2-data:/data
+      - colossus-2-keystore:/keystore
       - type: bind
         source: .
         target: /joystream
@@ -112,9 +112,9 @@ services:
     container_name: distributor-2
     restart: on-failure
     volumes:
-      - /data
-      - /cache
-      - /logs
+      - distributor-2-data:/data
+      - distributor-2-cache:/cache
+      - distributor-2-logs:/logs
       - type: bind
         source: .
         target: /joystream
@@ -151,7 +151,7 @@ services:
     ports:
       - '127.0.0.1:${DB_PORT}:${DB_PORT}'
     volumes:
-      - /var/lib/postgresql/data
+      - query-node-data:/var/lib/postgresql/data
     env_file:
       # relative to working directory where docker-compose was run from
       - .env
@@ -263,3 +263,29 @@ services:
       - "127.0.0.1:3000:80"
     environment:
       - NGINX_PORT=80
+
+volumes:
+  chain-data:
+    driver: local
+  query-node-data:
+    driver: local
+  colossus-1-data:
+    driver: local
+  colossus-1-keystore:
+    driver: local
+  colossus-2-data:
+    driver: local
+  colossus-2-keystore:
+    driver: local
+  distributor-1-logs:
+    driver: local
+  distributor-1-cache:
+    driver: local
+  distributor-1-data:
+    driver: local
+  distributor-2-logs:
+    driver: local
+  distributor-2-cache:
+    driver: local
+  distributor-2-data:
+    driver: local

+ 27 - 17
start.sh

@@ -1,26 +1,32 @@
 #!/usr/bin/env bash
 set -e
 
-# Run a complete joystream development network on your machine using docker.
-# Make sure to run build-docker-images.sh prior to running this script to use
-# the local build.
+# Run a complete joystream development network on your machine using docker
 
-# Clean start!
-docker-compose down -v
+INIT_CHAIN_SCENARIO=${INIT_CHAIN_SCENARIO:=setup-new-chain}
 
-function down()
-{
-    # Stop containers and clear volumes
-    docker-compose down -v
-}
+if [ "${PERSIST}" == true ]
+then
+  echo "Services startup up.."
+else
+  # Clean start!
+  docker-compose down -v
 
-trap down EXIT
+  function down()
+  {
+      # Stop containers and clear volumes
+      docker-compose down -v
+  }
+
+  trap down EXIT
+fi
 
 ## Run a local development chain
 docker-compose up -d joystream-node
 
 ## Init the chain with some state
-SKIP_MOCK_CONTENT=true ./tests/network-tests/run-test-scenario.sh setup-new-chain
+export SKIP_MOCK_CONTENT=true
+./tests/network-tests/run-test-scenario.sh ${INIT_CHAIN_SCENARIO}
 
 ## Set sudo as the membership screening authority
 yarn workspace api-scripts set-sudo-as-screening-auth
@@ -35,8 +41,12 @@ docker-compose up -d distributor-1
 ## Pioneer UI
 docker-compose up -d pioneer
 
-echo "use Ctrl+C to shutdown the development network."
-
-while true; do 
-  read
-done
+if [ "${PERSIST}" == true ]
+then
+  echo "All services started in the background"
+else
+  echo "use Ctrl+C to shutdown the development network."
+  while true; do
+    read
+  done
+fi