From 1e3acd78ac32c68d796a58dbb4be164abe726213 Mon Sep 17 00:00:00 2001 From: apostolof Date: Tue, 2 Feb 2021 22:47:18 +0200 Subject: [PATCH] refactor: simplify env files, add makefile targets for app staging runtime, include ecentrics in image names, use docker build-kit --- .gitignore | 4 -- docker/Makefile | 42 ++++++++++++------- docker/docker-compose.yml | 4 +- docker/env/concordia.env | 3 ++ docker/env/concordia.example.env | 20 --------- .../{contracts.docker.env => contracts.env} | 7 ---- docker/env/contracts.example.env | 7 ---- .../env/{ganache.docker.env => ganache.env} | 0 ...nache.test.docker.env => ganache.test.env} | 0 9 files changed, 31 insertions(+), 56 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 docker/Makefile mode change 100644 => 100755 docker/docker-compose.yml create mode 100755 docker/env/concordia.env delete mode 100644 docker/env/concordia.example.env rename docker/env/{contracts.docker.env => contracts.env} (51%) mode change 100644 => 100755 delete mode 100644 docker/env/contracts.example.env rename docker/env/{ganache.docker.env => ganache.env} (100%) mode change 100644 => 100755 rename docker/env/{ganache.test.docker.env => ganache.test.env} (100%) mode change 100644 => 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 31c619d..9a3b513 --- a/.gitignore +++ b/.gitignore @@ -24,10 +24,6 @@ docker/volumes docker/ganache/volumes docker/reports -# Env var files -docker/env/concordia.env -docker/env/contracts.env - # Misc .env.local .env.development.local diff --git a/docker/Makefile b/docker/Makefile old mode 100644 new mode 100755 index 0b47f47..2a746a5 --- a/docker/Makefile +++ b/docker/Makefile @@ -1,9 +1,13 @@ +.EXPORT_ALL_VARIABLES: PACKAGES := $(abspath ${CURDIR}/../packages) REPORTS := $(abspath ${CURDIR}/reports) GANACHE_VOLUMES := $(abspath ${CURDIR}/ganache/volumes) +DOCKER_BUILDKIT = 1 run: compose-run build-contracts-migrate run-contracts-migrate build-app run-app @echo "Concordia is up and running, head over to http://localhost:7777." +run-staging: compose-run build-contracts-migrate run-contracts-migrate build-app-staging run-app-staging + @echo "Concordia is up and running, head over to http://localhost:7000." # Targets for building/running/stopping the blockchain and rendezvous server (using the docker-compose file) compose-build: @@ -17,13 +21,13 @@ compose-stop-clean-data: # Ganache targets build-ganache: - @docker build ../ -f ./ganache/Dockerfile -t concordia-ganache + @docker build ../ -f ./ganache/Dockerfile -t ecentrics/concordia-ganache run-ganache: @docker network create --driver bridge concordia_ganache_network || true &&\ - docker run -d -v ${GANACHE_VOLUMES}/ganache_keys:/home/ganache_keys -p 8545:8545 --env-file=./env/ganache.docker.env --name concordia-ganache --net=concordia_ganache_network concordia-ganache:latest + docker run -d -v ${GANACHE_VOLUMES}/ganache_keys:/home/ganache_keys -p 8545:8545 --env-file=./env/ganache.env --name concordia-ganache --net=concordia_ganache_network ecentrics/concordia-ganache:latest run-ganache-test: @docker network create --driver bridge concordia_ganache_test_network || true &&\ - docker run --rm -d -p 8546:8546 --env-file=./env/ganache.test.docker.env --name concordia-ganache-test --net=concordia_ganache_test_network concordia-ganache:latest + docker run --rm -d -p 8546:8546 --env-file=./env/ganache.test.env --name concordia-ganache-test --net=concordia_ganache_test_network ecentrics/concordia-ganache:latest # Rendezvous targets run-rendezvous: @@ -32,35 +36,41 @@ run-rendezvous: # Contracts targets build-contracts: - @docker build ../ -f ./concordia-contracts/Dockerfile --target compile -t concordia-contracts --build-arg TZ=Europe/Athens + @docker build ../ -f ./concordia-contracts/Dockerfile --target compile -t ecentrics/concordia-contracts --build-arg TZ=Europe/Athens build-contracts-migrate: - @docker build ../ -f ./concordia-contracts/Dockerfile -t concordia-contracts-migrate --build-arg TZ=Europe/Athens + @docker build ../ -f ./concordia-contracts/Dockerfile -t ecentrics/concordia-contracts-migrate --build-arg TZ=Europe/Athens build-contracts-tests: - @docker build ../ -f ./concordia-contracts/Dockerfile --target test -t concordia-contracts-tests --build-arg TZ=Europe/Athens + @docker build ../ -f ./concordia-contracts/Dockerfile --target test -t ecentrics/concordia-contracts-tests --build-arg TZ=Europe/Athens run-contracts-tests: - @docker run --rm -v ${REPORTS}/contracts/:/usr/test-reports/ --env-file=./env/contracts.docker.env --net=concordia_ganache_test_network concordia-contracts-tests:latest + @docker run --rm -v ${REPORTS}/contracts/:/usr/test-reports/ --env-file=./env/contracts.env --net=concordia_ganache_test_network ecentrics/concordia-contracts-tests:latest run-contracts-tests-host-chain: - @docker run --rm -v ${REPORTS}/contracts/:/usr/test-reports/ --env-file=./env/contracts.env --net=host concordia-contracts-tests:latest + @docker run --rm -v ${REPORTS}/contracts/:/usr/test-reports/ --env-file=./env/contracts.env --net=host ecentrics/concordia-contracts-tests:latest run-contracts-migrate: - @docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/usr/src/concordia/packages/concordia-contracts/build/ --env-file=./env/contracts.docker.env --net=concordia_ganache_network concordia-contracts-migrate:latest + @docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/usr/src/concordia/packages/concordia-contracts/build/ --env-file=./env/contracts.env --net=concordia_ganache_network ecentrics/concordia-contracts-migrate:latest run-contracts-migrate-host-chain: - @docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/usr/src/concordia/packages/concordia-contracts/build/ --env-file=./env/contracts.env --net=host concordia-contracts-migrate:latest + @docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/usr/src/concordia/packages/concordia-contracts/build/ --env-file=./env/contracts.env --net=host ecentrics/concordia-contracts-migrate:latest get-contracts: - @docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/build --entrypoint=sh concordia-contracts:latest -c 'cp /usr/src/concordia/packages/concordia-contracts/build/* /build' + @docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/build --entrypoint=sh ecentrics/concordia-contracts:latest -c 'cp /usr/src/concordia/packages/concordia-contracts/build/* /build' # App targets build-app: - @docker build ../ -f ./concordia-app/Dockerfile -t concordia-app --build-arg TZ=Europe/Athens + @docker build ../ -f ./concordia-app/Dockerfile -t ecentrics/concordia-app --build-arg TZ=Europe/Athens +build-app-staging: + @docker build ../ -f ./concordia-app/Dockerfile --target staging -t ecentrics/concordia-app-staging --build-arg TZ=Europe/Athens build-app-tests: - @docker build ../ -f ./concordia-app/Dockerfile --target test -t concordia-app-tests --build-arg TZ=Europe/Athens + @docker build ../ -f ./concordia-app/Dockerfile --target test -t ecentrics/concordia-app-tests --build-arg TZ=Europe/Athens run-app-tests: - @docker run --rm -v ${REPORTS}/app/:/usr/test-reports/ --env-file=./env/concordia.docker.env concordia-app-tests:latest + @docker run --rm -v ${REPORTS}/app/:/usr/test-reports/ --env-file=./env/concordia.env ecentrics/concordia-app-tests:latest run-app: - @docker create --env-file=./env/concordia.docker.env -p 7777:80 --name concordia-app --net=concordia_ganache_network concordia-app:latest &&\ + @docker create --env-file=./env/concordia.env -p 7777:80 --name concordia-app --net=concordia_ganache_network ecentrics/concordia-app:latest &&\ docker network connect concordia_rendezvous_network concordia-app &&\ docker start concordia-app +run-app-staging: + @docker create -it --env-file=./env/concordia.env -p 7000:3000 --name concordia-app-staging --net=concordia_ganache_network ecentrics/concordia-app-staging:latest &&\ + docker network connect concordia_rendezvous_network concordia-app-staging &&\ + docker start concordia-app-staging run-app-host-chain: - @docker run -d --env-file=./env/concordia.env --name concordia-app --net=host concordia-app:latest + @docker run -d --env-file=./env/concordia.env --name concordia-app --net=host ecentrics/concordia-app:latest # Other clean-images: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml old mode 100644 new mode 100755 index 3fa4386..e01c5c2 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -5,10 +5,10 @@ services: build: context: ../ dockerfile: ./docker/ganache/Dockerfile - image: concordia-ganache + image: ecentrics/concordia-ganache container_name: concordia-ganache env_file: - - env/ganache.docker.env + - env/ganache.env expose: - 8545 ports: diff --git a/docker/env/concordia.env b/docker/env/concordia.env new file mode 100755 index 0000000..d7a24a8 --- /dev/null +++ b/docker/env/concordia.env @@ -0,0 +1,3 @@ +# Variables needed in runtime (in browser) +REACT_APP_RENDEZVOUS_HOST=127.0.0.1 +REACT_APP_RENDEZVOUS_PORT=9090 diff --git a/docker/env/concordia.example.env b/docker/env/concordia.example.env deleted file mode 100644 index c593d66..0000000 --- a/docker/env/concordia.example.env +++ /dev/null @@ -1,20 +0,0 @@ -# Set to "CI" if in CI environment, anything else (including unset) will be ignored -BUILD_ENV={CI} - -# Docker compose variables -VIRTUAL_HOST=example.com -VIRTUAL_PORT=3000 - -# If you uncomment the lines below, Concordia will become available through https BUT the rendezvous -# server will stop working and IPFS initialization won't complete -#LETSENCRYPT_HOST=example.com -#LETSENCRYPT_EMAIL=someemail.email.com - -# Variables needed in runtime -# TO-NEVER-DO: change CONCORDIA_HOST to localhost -CONCORDIA_HOST=0.0.0.0 -CONCORDIA_PORT=3000 - -# Variables needed in runtime (in browser) -REACT_APP_RENDEZVOUS_HOST=xx.xxx.xxx.xxx -REACT_APP_RENDEZVOUS_PORT=9090 diff --git a/docker/env/contracts.docker.env b/docker/env/contracts.env old mode 100644 new mode 100755 similarity index 51% rename from docker/env/contracts.docker.env rename to docker/env/contracts.env index 1b6d49c..de9dc52 --- a/docker/env/contracts.docker.env +++ b/docker/env/contracts.env @@ -5,10 +5,3 @@ DEPLOY_CHAIN_PORT=8545 TEST_CHAIN_HOST=concordia-ganache-test TEST_CHAIN_PORT=8546 - -# If the blockchain is running on host use these instead -#DEPLOY_CHAIN_HOST=127.0.0.1 -#DEPLOY_CHAIN_PORT=8545 - -#TEST_CHAIN_HOST=127.0.0.1 -#TEST_CHAIN_PORT=8546 diff --git a/docker/env/contracts.example.env b/docker/env/contracts.example.env deleted file mode 100644 index 3194b9c..0000000 --- a/docker/env/contracts.example.env +++ /dev/null @@ -1,7 +0,0 @@ -# Variables needed in runtime -MIGRATE_NETWORK=env -DEPLOY_CHAIN_HOST=xx.xxx.xxx.xxx -DEPLOY_CHAIN_PORT=8545 - -TEST_CHAIN_HOST=xx.xxx.xxx.xxx -TEST_CHAIN_PORT=8545 diff --git a/docker/env/ganache.docker.env b/docker/env/ganache.env old mode 100644 new mode 100755 similarity index 100% rename from docker/env/ganache.docker.env rename to docker/env/ganache.env diff --git a/docker/env/ganache.test.docker.env b/docker/env/ganache.test.env old mode 100644 new mode 100755 similarity index 100% rename from docker/env/ganache.test.docker.env rename to docker/env/ganache.test.env