From cd5bd0cd944a3155f9ffe7aff47370ad601745b8 Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 7 Feb 2021 22:58:52 +0200 Subject: [PATCH] fix: copy shared package in docker images --- .gitignore | 1 + docker/Makefile | 38 ++++++++----------- docker/concordia-app/Dockerfile | 6 ++- .../concordia-contracts-provider/Dockerfile | 4 +- docker/concordia-contracts/Dockerfile | 4 +- docker/concordia-contracts/migrate.sh | 2 +- docker/concordia-pinner/Dockerfile | 2 +- docker/docker-compose.yml | 7 ++-- docker/env/concordia.env | 1 + docker/env/contracts.env | 7 +++- docker/env/pinner.env | 7 ++-- 11 files changed, 41 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 9cafa6c..7bbaae4 100755 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ yarn-error.log* docker/volumes docker/ganache/volumes docker/concordia-contracts-provider/volumes +docker/concordia-pinner/volumes docker/reports # Misc diff --git a/docker/Makefile b/docker/Makefile index bcefc51..8645f13 100755 --- a/docker/Makefile +++ b/docker/Makefile @@ -4,11 +4,11 @@ REPORTS := $(abspath ${CURDIR}/reports) GANACHE_VOLUMES := $(abspath ${CURDIR}/ganache/volumes) CONTRACTS_PROVIDER_VOLUMES := $(abspath ${CURDIR}/concordia-contracts-provider/volumes) DOCKER_BUILDKIT = 1 -PINNER_VOLUMES := $(abspath ${CURDIR}/pinner/volumes) +PINNER_VOLUMES := $(abspath ${CURDIR}/concordia-pinner/volumes) -run: compose-run build-contracts-migrate run-contracts-migrate build-app run-app +run: compose-run build-contracts-provider run-contracts-provider build-contracts-migrate run-contracts-migrate build-pinner run-pinner 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 +run-staging: compose-run build-contracts-provider run-contracts-provider-staging build-contracts-migrate run-contracts-migrate build-pinner run-pinner-staging 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) @@ -25,16 +25,14 @@ compose-stop-clean-data: build-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.env --name concordia-ganache --net=concordia_ganache_network ecentrics/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_concordia_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.env --name concordia-ganache-test --net=concordia_ganache_test_network ecentrics/concordia-ganache:latest + @docker run --rm -d -p 8546:8546 --env-file=./env/ganache.test.env --name concordia-ganache-test --net=concordia_concordia_network ecentrics/concordia-ganache:latest # Rendezvous targets run-rendezvous: - @docker network create --driver bridge concordia_rendezvous_network || true &&\ - docker run -d -p 9090:9090 --name concordia-rendezvous libp2p/js-libp2p-webrtc-star:version-0.20.5 + @docker network create --driver bridge concordia_concordia_network || true &&\ + docker run -d -p 9090:9090 --name concordia-rendezvous --net=concordia_concordia_network libp2p/js-libp2p-webrtc-star:version-0.20.5 # Contracts targets build-contracts: @@ -44,11 +42,11 @@ build-contracts-migrate: build-contracts-tests: @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.env --net=concordia_ganache_test_network ecentrics/concordia-contracts-tests:latest + @docker run --rm -v ${REPORTS}/contracts/:/usr/test-reports/ --env-file=./env/contracts.env --net=concordia_concordia_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 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.env --net=concordia_ganache_network ecentrics/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_concordia_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 ecentrics/concordia-contracts-migrate:latest get-contracts: @@ -64,13 +62,9 @@ build-app-tests: run-app-tests: @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.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 + @docker run -d --env-file=./env/concordia.env -p 7777:80 --name concordia-app ecentrics/concordia-app:latest 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 + @docker run -itd --env-file=./env/concordia.env -p 7000:3000 --name concordia-app-staging ecentrics/concordia-app-staging:latest run-app-host-chain: @docker run -d --env-file=./env/concordia.env --name concordia-app --net=host ecentrics/concordia-app:latest @@ -78,17 +72,17 @@ run-app-host-chain: build-contracts-provider: @docker build ../ -f ./concordia-contracts-provider/Dockerfile -t ecentrics/concordia-contracts-provider --build-arg TZ=Europe/Athens run-contracts-provider-staging: - @docker run -d -v ${CONTRACTS_PROVIDER_VOLUMES}/contracts:/data/contracts --env-file=./env/contracts-provider.env -e NODE_ENV=production -p 8400:8400 --name concordia-contracts-provider ecentrics/concordia-contracts-provider:latest + @docker run -d -v ${CONTRACTS_PROVIDER_VOLUMES}/contracts:/data/contracts --env-file=./env/contracts-provider.env -e NODE_ENV=production -p 8400:8400 --name concordia-contracts-provider --net=concordia_concordia_network ecentrics/concordia-contracts-provider:latest run-contracts-provider: - @docker run -d -v ${CONTRACTS_PROVIDER_VOLUMES}/contracts:/data/contracts --env-file=./env/contracts-provider.env -p 8400:8400 --name concordia-contracts-provider ecentrics/concordia-contracts-provider:latest + @docker run -d -v ${CONTRACTS_PROVIDER_VOLUMES}/contracts:/data/contracts --env-file=./env/contracts-provider.env -p 8400:8400 --name concordia-contracts-provider --net=concordia_concordia_network ecentrics/concordia-contracts-provider:latest -# Contracts provider targets +# Pinner targets build-pinner: @docker build ../ -f ./concordia-pinner/Dockerfile -t ecentrics/concordia-pinner --build-arg TZ=Europe/Athens run-pinner-staging: - @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/data/orbitdb --env-file=./env/pinner.env -e NODE_ENV=production -p 4444:4444 --name concordia-pinner ecentrics/concordia-pinner:latest + @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/data/orbitdb --env-file=./env/pinner.env -e NODE_ENV=production -p 4444:4444 --name concordia-pinner --net=concordia_concordia_network ecentrics/concordia-pinner:latest run-pinner: - @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/data/orbitdb --env-file=./env/pinner.env -p 4444:4444 --name concordia-pinner ecentrics/concordia-pinner:latest + @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/data/orbitdb --env-file=./env/pinner.env -p 4444:4444 --name concordia-pinner --net=concordia_concordia_network ecentrics/concordia-pinner:latest run-pinner-staging-host: @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/data/orbitdb --env-file=./env/pinner.env -e NODE_ENV=production --net=host --name concordia-pinner ecentrics/concordia-pinner:latest run-pinner-host: diff --git a/docker/concordia-app/Dockerfile b/docker/concordia-app/Dockerfile index 0191145..132ec8b 100755 --- a/docker/concordia-app/Dockerfile +++ b/docker/concordia-app/Dockerfile @@ -12,14 +12,16 @@ WORKDIR /usr/src/concordia COPY ./package.json . COPY ./yarn.lock . -# Copy package.json files from contracts and app, then install base modules +# Copy package.json files from contracts, shared and app, then install modules COPY ./packages/concordia-contracts/package.json ./packages/concordia-contracts/package.json +COPY ./packages/concordia-shared/package.json ./packages/concordia-shared/package.json COPY ./packages/concordia-app/package.json ./packages/concordia-app/ RUN yarn install --frozen-lockfile # Gets the rest of the source code COPY ./packages/concordia-contracts ./packages/concordia-contracts +COPY ./packages/concordia-shared ./packages/concordia-shared COPY ./packages/concordia-app ./packages/concordia-app # Fix timezome @@ -38,7 +40,7 @@ COPY ./docker/concordia-app/test-app.sh . WORKDIR /usr/src/concordia/packages/concordia-app -RUN chmod +x /opt/concordia-app/test-app.sh +RUN ["chmod", "+x", "/opt/concordia-app/test-app.sh"] ENTRYPOINT ["/opt/concordia-app/test-app.sh"] diff --git a/docker/concordia-contracts-provider/Dockerfile b/docker/concordia-contracts-provider/Dockerfile index 452a69d..4fb356e 100644 --- a/docker/concordia-contracts-provider/Dockerfile +++ b/docker/concordia-contracts-provider/Dockerfile @@ -21,12 +21,14 @@ WORKDIR /usr/src/concordia COPY ./package.json . COPY ./yarn.lock . -# Copy the contracts provider package.json, then install modules +# Copy package.json files from shared and contracts provider, then install modules +COPY ./packages/concordia-shared/package.json ./packages/concordia-shared/ COPY ./packages/concordia-contracts-provider/package.json ./packages/concordia-contracts-provider/ RUN yarn install --frozen-lockfile --network-timeout 100000 # Gets the rest of the source code +COPY ./packages/concordia-shared ./packages/concordia-shared COPY ./packages/concordia-contracts-provider ./packages/concordia-contracts-provider WORKDIR /usr/src/concordia/packages/concordia-contracts-provider diff --git a/docker/concordia-contracts/Dockerfile b/docker/concordia-contracts/Dockerfile index 7fceb30..fe3b45c 100755 --- a/docker/concordia-contracts/Dockerfile +++ b/docker/concordia-contracts/Dockerfile @@ -21,12 +21,14 @@ WORKDIR /usr/src/concordia COPY ./package.json . COPY ./yarn.lock . -# Copy the contracts package.json, then install modules +# Copy package.json files from shared and contracts, then install modules +COPY ./packages/concordia-shared/package.json ./packages/concordia-shared/ COPY ./packages/concordia-contracts/package.json ./packages/concordia-contracts/ RUN yarn install --frozen-lockfile --network-timeout 100000 # Gets the rest of the source code +COPY ./packages/concordia-shared ./packages/concordia-shared COPY ./packages/concordia-contracts ./packages/concordia-contracts # -------------------------------------------------- diff --git a/docker/concordia-contracts/migrate.sh b/docker/concordia-contracts/migrate.sh index 29d7449..20a813f 100644 --- a/docker/concordia-contracts/migrate.sh +++ b/docker/concordia-contracts/migrate.sh @@ -3,4 +3,4 @@ export CHAIN_HOST="$DEPLOY_CHAIN_HOST" export CHAIN_PORT="$DEPLOY_CHAIN_PORT" -cd /usr/src/concordia/packages/concordia-contracts && yarn _migrate --network "${MIGRATE_NETWORK}" --reset +cd /usr/src/concordia/packages/concordia-contracts && yarn _migrate --network "${MIGRATE_NETWORK}" --reset && yarn upload diff --git a/docker/concordia-pinner/Dockerfile b/docker/concordia-pinner/Dockerfile index e44ad70..3a2bf8b 100644 --- a/docker/concordia-pinner/Dockerfile +++ b/docker/concordia-pinner/Dockerfile @@ -17,7 +17,7 @@ WORKDIR /usr/src/concordia COPY ./package.json . COPY ./yarn.lock . -# Copy the pinner, contracts and shared package.json files, then install modules +# Copy package.json files from contracts, shared and pinner, then install modules COPY ./packages/concordia-pinner/package.json ./packages/concordia-pinner/ COPY ./packages/concordia-contracts/package.json ./packages/concordia-contracts/ COPY ./packages/concordia-shared/package.json ./packages/concordia-shared/ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index e01c5c2..9ba19a1 100755 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -17,18 +17,17 @@ services: volumes: - ./ganache/volumes/ganache_keys:/home/ganache_keys networks: - ganache_network: + concordia_network: restart: always rendezvous: image: libp2p/js-libp2p-webrtc-star:version-0.20.5 container_name: concordia-rendezvous networks: - rendezvous_network: + concordia_network: ports: - 9090:9090 restart: always networks: - ganache_network: - rendezvous_network: + concordia_network: diff --git a/docker/env/concordia.env b/docker/env/concordia.env index d7a24a8..42652e7 100755 --- a/docker/env/concordia.env +++ b/docker/env/concordia.env @@ -1,3 +1,4 @@ # Variables needed in runtime (in browser) REACT_APP_RENDEZVOUS_HOST=127.0.0.1 REACT_APP_RENDEZVOUS_PORT=9090 +USE_EXTERNAL_CONTRACTS_PROVIDER=true diff --git a/docker/env/contracts.env b/docker/env/contracts.env index de9dc52..f5d51f8 100755 --- a/docker/env/contracts.env +++ b/docker/env/contracts.env @@ -1,7 +1,10 @@ # Variables needed in runtime MIGRATE_NETWORK=env -DEPLOY_CHAIN_HOST=concordia-ganache -DEPLOY_CHAIN_PORT=8545 +WEB3_HOST=concordia-ganache +WEB3_PORT=8545 + +CONTRACTS_PROVIDER_HOST=concordia-contracts-provider +CONTRACTS_PROVIDER_PORT=8400 TEST_CHAIN_HOST=concordia-ganache-test TEST_CHAIN_PORT=8546 diff --git a/docker/env/pinner.env b/docker/env/pinner.env index e723d45..84fb01e 100644 --- a/docker/env/pinner.env +++ b/docker/env/pinner.env @@ -1,16 +1,15 @@ USE_EXTERNAL_CONTRACTS_PROVIDER=true ORBIT_DIRECTORY=/data/orbitdb -#CONTRACTS_PROVIDER_HOST=contracts-provider -CONTRACTS_PROVIDER_HOST=127.0.0.1 +CONTRACTS_PROVIDER_HOST=concordia-contracts-provider CONTRACTS_PROVIDER_PORT=8400 CONTRACTS_VERSION_HASH=latest PINNER_API_HOST=127.0.0.1 PINNER_API_PORT=4444 -RENDEZVOUS_HOST=127.0.0.1 +RENDEZVOUS_HOST=concordia-rendezvous RENDEZVOUS_PORT=9090 -WEB3_HOST=127.0.0.1 +WEB3_HOST=concordia-ganache WEB3_PORT=8545