From 51a365729ac7f652ae7e9e30b2a6613cbab5cfa6 Mon Sep 17 00:00:00 2001 From: apostolof Date: Mon, 8 Feb 2021 21:16:04 +0200 Subject: [PATCH] refactor: lock docker images, normalize mount paths, minor fixes --- docker/Makefile | 24 +++++++++---------- docker/concordia-app/Dockerfile | 7 ++++-- docker/concordia-app/test-app.sh | 2 +- .../concordia-contracts-provider/Dockerfile | 2 +- docker/concordia-contracts/Dockerfile | 2 +- docker/concordia-contracts/test-contracts.sh | 6 ++--- docker/concordia-pinner/Dockerfile | 2 +- docker/docker-compose.yml | 2 +- docker/env/contracts-provider.env | 2 +- docker/env/pinner.env | 2 +- docker/ganache/Dockerfile | 2 +- docker/ganache/start-blockchain.sh | 8 +++---- 12 files changed, 32 insertions(+), 29 deletions(-) diff --git a/docker/Makefile b/docker/Makefile index 8645f13..3ddded8 100755 --- a/docker/Makefile +++ b/docker/Makefile @@ -3,8 +3,8 @@ PACKAGES := $(abspath ${CURDIR}/../packages) 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}/concordia-pinner/volumes) +DOCKER_BUILDKIT = 1 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." @@ -25,7 +25,7 @@ compose-stop-clean-data: build-ganache: @docker build ../ -f ./ganache/Dockerfile -t ecentrics/concordia-ganache run-ganache: - @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 + @docker run -d -v ${GANACHE_VOLUMES}/ganache_keys:/mnt/concordia/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 run --rm -d -p 8546:8546 --env-file=./env/ganache.test.env --name concordia-ganache-test --net=concordia_concordia_network ecentrics/concordia-ganache:latest @@ -42,15 +42,15 @@ 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_concordia_network ecentrics/concordia-contracts-tests:latest + @docker run --rm -v ${REPORTS}/contracts/:/mnt/concordia/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 + @docker run --rm -v ${REPORTS}/contracts/:/mnt/concordia/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_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: - @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' + @docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/mnt/concordia/build --entrypoint=sh ecentrics/concordia-contracts:latest -c 'cp /usr/src/concordia/packages/concordia-contracts/build/* /mnt/concordia/build' # App targets build-app: @@ -60,7 +60,7 @@ build-app-staging: build-app-tests: @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.env ecentrics/concordia-app-tests:latest + @docker run --rm -v ${REPORTS}/app/:/mnt/concordia/test-reports/ --env-file=./env/concordia.env ecentrics/concordia-app-tests:latest run-app: @docker run -d --env-file=./env/concordia.env -p 7777:80 --name concordia-app ecentrics/concordia-app:latest run-app-staging: @@ -72,21 +72,21 @@ 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 --net=concordia_concordia_network ecentrics/concordia-contracts-provider:latest + @docker run -d -v ${CONTRACTS_PROVIDER_VOLUMES}/contracts:/mnt/concordia/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 --net=concordia_concordia_network ecentrics/concordia-contracts-provider:latest + @docker run -d -v ${CONTRACTS_PROVIDER_VOLUMES}/contracts:/mnt/concordia/contracts --env-file=./env/contracts-provider.env -p 8400:8400 --name concordia-contracts-provider --net=concordia_concordia_network ecentrics/concordia-contracts-provider:latest # 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 --net=concordia_concordia_network ecentrics/concordia-pinner:latest + @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/mnt/concordia/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 --net=concordia_concordia_network ecentrics/concordia-pinner:latest + @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/mnt/concordia/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 + @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/mnt/concordia/orbitdb --env-file=./env/pinner.env -e NODE_ENV=production --net=host --name concordia-pinner ecentrics/concordia-pinner:latest run-pinner-host: - @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/data/orbitdb --env-file=./env/pinner.env --net=host --name concordia-pinner ecentrics/concordia-pinner:latest + @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/mnt/concordia/orbitdb --env-file=./env/pinner.env --net=host --name concordia-pinner ecentrics/concordia-pinner:latest # Other clean-images: diff --git a/docker/concordia-app/Dockerfile b/docker/concordia-app/Dockerfile index 132ec8b..6673dbb 100755 --- a/docker/concordia-app/Dockerfile +++ b/docker/concordia-app/Dockerfile @@ -1,7 +1,7 @@ # -------------------------------------------------- # Stage 1 (Init application build base) # -------------------------------------------------- -FROM node:14-buster as base +FROM node:14-alpine@sha256:51e341881c2b77e52778921c685e711a186a71b8c6f62ff2edfc6b6950225a2f as base LABEL maintainers.1="Apostolos Fanakis " LABEL maintainers.2="Panagiotis Nikolaidis " LABEL gr.thmmy.ecentrics.concordia-image.name="app" @@ -17,6 +17,9 @@ COPY ./packages/concordia-contracts/package.json ./packages/concordia-contracts/ COPY ./packages/concordia-shared/package.json ./packages/concordia-shared/package.json COPY ./packages/concordia-app/package.json ./packages/concordia-app/ +# Install required packages +RUN apk update && apk --no-cache add g++ make python + RUN yarn install --frozen-lockfile # Gets the rest of the source code @@ -65,7 +68,7 @@ ENTRYPOINT ["yarn", "start"] # -------------------------------------------------- # Stage 4 (Production runtime) # -------------------------------------------------- -FROM nginx:1.17-alpine as production +FROM nginx:1.17-alpine@sha256:01747306a7247dbe928db991eab42e4002118bf636dd85b4ffea05dd907e5b66 as production LABEL maintainers.1="Apostolos Fanakis " LABEL maintainers.2="Panagiotis Nikolaidis /usr/test-reports/concordia-contracts-solhint.report) && - (yarn test --network env >/usr/test-reports/concordia-contracts-truffle-tests.report) +yarn _eslint -f html -o /mnt/concordia/test-reports/concordia-contracts-eslint.html --no-color && + (yarn _solhint >/mnt/concordia/test-reports/concordia-contracts-solhint.report) && + (yarn test --network env >/mnt/concordia/test-reports/concordia-contracts-truffle-tests.report) if [ $? -eq 0 ]; then echo "TESTS RAN SUCCESSFULLY!" diff --git a/docker/concordia-pinner/Dockerfile b/docker/concordia-pinner/Dockerfile index 3a2bf8b..3c9389c 100644 --- a/docker/concordia-pinner/Dockerfile +++ b/docker/concordia-pinner/Dockerfile @@ -1,7 +1,7 @@ # -------------------------------------------------- # Stage 1 (Runtime) # -------------------------------------------------- -FROM node:14-buster as runtime +FROM node:14-buster@sha256:32362e2ea89c62d77c86c8f26ad936dbbdc170cd6c06c4d7ff7a809012bb0c32 as runtime LABEL maintainers.1="Apostolos Fanakis " LABEL maintainers.2="Panagiotis Nikolaidis " LABEL gr.thmmy.ecentrics.concordia-image.name="pinner" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 9ba19a1..db5f1ea 100755 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -15,7 +15,7 @@ services: - 8545:8545 user: root volumes: - - ./ganache/volumes/ganache_keys:/home/ganache_keys + - ./ganache/volumes/ganache_keys:/mnt/concordia/ganache_keys networks: concordia_network: restart: always diff --git a/docker/env/contracts-provider.env b/docker/env/contracts-provider.env index 6903a65..17f9e0d 100644 --- a/docker/env/contracts-provider.env +++ b/docker/env/contracts-provider.env @@ -1 +1 @@ -UPLOAD_CONTRACTS_DIRECTORY=/data/contracts/ +UPLOAD_CONTRACTS_DIRECTORY=/mnt/concordia/contracts/ diff --git a/docker/env/pinner.env b/docker/env/pinner.env index 84fb01e..e3ebe65 100644 --- a/docker/env/pinner.env +++ b/docker/env/pinner.env @@ -1,5 +1,5 @@ USE_EXTERNAL_CONTRACTS_PROVIDER=true -ORBIT_DIRECTORY=/data/orbitdb +ORBIT_DIRECTORY=/mnt/concordia/orbitdb CONTRACTS_PROVIDER_HOST=concordia-contracts-provider CONTRACTS_PROVIDER_PORT=8400 diff --git a/docker/ganache/Dockerfile b/docker/ganache/Dockerfile index 80eba88..11e7f39 100644 --- a/docker/ganache/Dockerfile +++ b/docker/ganache/Dockerfile @@ -1,4 +1,4 @@ -FROM trufflesuite/ganache-cli:latest +FROM trufflesuite/ganache-cli:v6.12.2@sha256:c062707f17f355872d703cde3de6a12fc45a027ed42857c72514171a5f466ab7 RUN mkdir /home/ganache_db /home/ganache_keys diff --git a/docker/ganache/start-blockchain.sh b/docker/ganache/start-blockchain.sh index 36aceea..0a373b8 100644 --- a/docker/ganache/start-blockchain.sh +++ b/docker/ganache/start-blockchain.sh @@ -14,8 +14,8 @@ if [ -z "${MNEMONIC}" ]; then --host "$HOST" \ --port "$PORT" \ --networkId "$ID" \ - --account_keys_path "/home/ganache_keys/keys.json" \ - --db "/home/ganache_db/" \ + --account_keys_path "/mnt/concordia/ganache_keys/keys.json" \ + --db "/mnt/concordia/ganache_db/" \ --allowUnlimitedContractSize \ --noVMErrorsOnRPCResponse \ --verbose @@ -28,8 +28,8 @@ else --host "$HOST" \ --port "$PORT" \ --networkId "$ID" \ - --account_keys_path "/home/ganache_keys/keys.json" \ - --db "/home/ganache_db/" \ + --account_keys_path "/mnt/concordia/ganache_keys/keys.json" \ + --db "/mnt/concordia/ganache_db/" \ --allowUnlimitedContractSize \ --noVMErrorsOnRPCResponse \ --deterministic \