From 2d3e92d01bc1976bff04829c1978b832c4e50b32 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sun, 22 Nov 2020 19:50:30 +0200 Subject: [PATCH] Fix dockerfiles, Update Makefile --- .dockerignore | 8 +++++--- docker/Makefile | 17 ++++++++++++----- docker/concordia-app/Dockerfile | 18 +++++++----------- docker/concordia-contracts/Dockerfile | 2 +- docker/concordia-contracts/migrate.sh | 2 +- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.dockerignore b/.dockerignore index e122bb6..1ed8525 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,13 +6,15 @@ node_modules docker/ !docker/concordia-contracts/migrate.sh !docker/concordia-contracts/test-contracts.sh +!docker/concordia-app/test-app.sh packages/*/node_modules packages/*/dist packages/*/coverage -# TO-NEVER-DO: exclude the build *folder* from contracts package, it's needed for building the app the JSON contract -# artifacts can be ignored -packages/concordia-contracts/build/* +# TO-NEVER-DO: exclude the build folder of the contracts package, it's needed for building the application image. packages/concordia-app/build Jenkinsfile + +README.md +packages/*/README.md \ No newline at end of file diff --git a/docker/Makefile b/docker/Makefile index 052ef00..db5c043 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -11,7 +11,7 @@ stop-clean-data: # Contracts targets build-contracts: @docker build ../ -f ./concordia-contracts/Dockerfile --target compile -t concordia-contracts --build-arg TZ=Europe/Athens -build-migrate-contracts: +build-contracts-migrate: @docker build ../ -f ./concordia-contracts/Dockerfile -t 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 @@ -20,11 +20,14 @@ run-contract-tests: run-contract-tests-host-chain: @docker run --rm -v `pwd`/reports/contracts/:/usr/test-reports/ --env-file=./env/contracts.env --net=host concordia-contracts-tests:latest run-contracts-migrate: - @docker run --rm --env-file=./env/contracts.env concordia-contracts-migrate:latest + @cd .. &&\ + docker run --rm -v `pwd`/packages/concordia-contracts/build/:/usr/src/concordia/packages/concordia-contracts/build/ --env-file=./docker/env/contracts.env concordia-contracts-migrate:latest run-contracts-migrate-host-chain: - @docker run --rm --env-file=./env/contracts.env --net=host concordia-contracts-migrate:latest + @cd .. &&\ + docker run --rm -v `pwd`/packages/concordia-contracts/build/:/usr/src/concordia/packages/concordia-contracts/build/ --env-file=./docker/env/contracts.env --net=host concordia-contracts-migrate:latest get-contracts: - @cd .. && docker run --rm -v `pwd`/packages/concordia-contracts/build/:/build --entrypoint=sh concordia-contracts:latest -c 'cp /usr/src/concordia/packages/concordia-contracts/build/* /build' + @cd .. && \ + docker run --rm -v `pwd`/packages/concordia-contracts/build/:/build --entrypoint=sh concordia-contracts:latest -c 'cp /usr/src/concordia/packages/concordia-contracts/build/* /build' # App targets build-app: @@ -32,7 +35,11 @@ build-app: build-app-tests: @docker build ../ -f ./concordia-app/Dockerfile --target test -t concordia-app-tests --build-arg TZ=Europe/Athens run-app-tests: - @docker run --rm -v `pwd`/reports/app/:/usr/test-reports/ --env-file=./env/app.env concordia-app-tests:latest + @docker run --rm -v `pwd`/reports/app/:/usr/test-reports/ --env-file=./env/concordia.env concordia-app-tests:latest +run-app: + @docker run -d --env-file=./env/concordia.env -p 8473:80 --name concordia-app concordia-app:latest +run-app-host-chain: + @docker run -d --env-file=./env/concordia.env --name concordia-app --net=host concordia-app:latest # Other clean-images: diff --git a/docker/concordia-app/Dockerfile b/docker/concordia-app/Dockerfile index f2f55c4..04c619c 100644 --- a/docker/concordia-app/Dockerfile +++ b/docker/concordia-app/Dockerfile @@ -1,20 +1,11 @@ # -------------------------------------------------- -# Stage 1 (Init contracts build base) +# Stage 1 (Init application build base) # -------------------------------------------------- -FROM node:14-alpine as base +FROM node:14-buster as base LABEL maintainers.1="Apostolos Fanakis " LABEL maintainers.2="Panagiotis Nikolaidis " LABEL gr.thmmy.ecentrics.concordia-image.name="app" -# Fix timezome (needed for timestamps on report files) -ARG TZ - -RUN apk add -U tzdata \ - && cp /usr/share/zoneinfo/$TZ /etc/localtime \ - && echo $TZ > /etc/timezone \ - && apk del tzdata \ - && rm -rf /var/cache/apk/* - WORKDIR /usr/src/concordia # Copy the root package.json and yarn.lock @@ -36,6 +27,11 @@ COPY ./packages/concordia-app ./packages/concordia-app # -------------------------------------------------- FROM base as test +# Fix timezome (needed for timestamps on report files) +ARG TZ +ENV TZ=${TZ} +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + WORKDIR /opt/concordia-app COPY ./docker/concordia-app/test-app.sh . diff --git a/docker/concordia-contracts/Dockerfile b/docker/concordia-contracts/Dockerfile index 44fb384..a928549 100644 --- a/docker/concordia-contracts/Dockerfile +++ b/docker/concordia-contracts/Dockerfile @@ -1,7 +1,7 @@ # -------------------------------------------------- # Stage 1 (Init contracts build base) # -------------------------------------------------- -FROM node:10-alpine as base +FROM node:14-alpine as base LABEL maintainers.1="Apostolos Fanakis " LABEL maintainers.2="Panagiotis Nikolaidis " LABEL gr.thmmy.ecentrics.concordia-image.name="contracts" diff --git a/docker/concordia-contracts/migrate.sh b/docker/concordia-contracts/migrate.sh index b021223..dd5cf00 100644 --- a/docker/concordia-contracts/migrate.sh +++ b/docker/concordia-contracts/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -cd /usr/src/concordia/packages/concordia-contracts && yarn _migrate --network "${MIGRATE_NETWORK}" +cd /usr/src/concordia/packages/concordia-contracts && yarn _migrate --network "${MIGRATE_NETWORK}" --reset