diff --git a/docker/Makefile b/docker/Makefile index 6fbc491..052ef00 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -16,9 +16,9 @@ build-migrate-contracts: build-contracts-tests: @docker build ../ -f ./concordia-contracts/Dockerfile --target test -t concordia-contracts-tests --build-arg TZ=Europe/Athens run-contract-tests: - @docker run --rm -v `pwd`/reports/:/usr/test-reports/ --env-file=./env/contracts.env concordia-contracts-tests:latest + @docker run --rm -v `pwd`/reports/contracts/:/usr/test-reports/ --env-file=./env/contracts.env concordia-contracts-tests:latest run-contract-tests-host-chain: - @docker run --rm -v `pwd`/reports/:/usr/test-reports/ --env-file=./env/contracts.env --net=host concordia-contracts-tests:latest + @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 run-contracts-migrate-host-chain: @@ -28,11 +28,11 @@ get-contracts: # App targets build-app: - @docker build ../ -f ./concordia-app/Dockerfile -t concordia-app --build-arg TZ=Europe/Athens --build-arg SKIP_TESTS="true" + @docker build ../ -f ./concordia-app/Dockerfile -t concordia-app --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 -get-app-tests: - @docker run --rm -v `pwd`/reports/:/app concordia-app-tests:latest sh -c 'mkdir -p /app/app && cp /usr/test-reports/* /app/app' +run-app-tests: + @docker run --rm -v `pwd`/reports/app/:/usr/test-reports/ --env-file=./env/app.env concordia-app-tests:latest # Other clean-images: diff --git a/docker/concordia-app/Dockerfile b/docker/concordia-app/Dockerfile index c2c4e51..f2f55c4 100644 --- a/docker/concordia-app/Dockerfile +++ b/docker/concordia-app/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="app" @@ -28,30 +28,21 @@ COPY ./packages/concordia-app/package.json ./packages/concordia-app/ RUN yarn install --frozen-lockfile # Gets the rest of the source code -COPY ./packages ./packages +COPY ./packages/concordia-contracts ./packages/concordia-contracts +COPY ./packages/concordia-app ./packages/concordia-app # -------------------------------------------------- # Stage 2 (Test) # -------------------------------------------------- FROM base as test +WORKDIR /opt/concordia-app + +COPY ./docker/concordia-app/test-app.sh . + WORKDIR /usr/src/concordia/packages/concordia-app -ARG SKIP_TESTS -ARG CI - -RUN if [ -z "${SKIP_TESTS}" ]; then \ - yarn lint -f html -o /usr/test-reports/concordia-app-eslint.html --no-color; \ - if [ $? -eq 0 ]; then \ - if [ -n "${CI}" ]; then \ - mkdir /usr/test-results && touch /usr/test-results/pass; \ - fi \ - else \ - echo "SOME TESTS FAILED!"; \ - fi \ - else \ - echo "Skipping tests..."; \ - fi +ENTRYPOINT ["/opt/concordia-app/test-app.sh"] # -------------------------------------------------- # Stage 3 (Build) diff --git a/docker/concordia-app/test-app.sh b/docker/concordia-app/test-app.sh new file mode 100644 index 0000000..70c4d9d --- /dev/null +++ b/docker/concordia-app/test-app.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +yarn lint -f html -o /usr/test-reports/concordia-app-eslint.html --no-color + +if [ $? -eq 0 ]; then + echo "TESTS RAN SUCCESSFULLY!" + exit 0 +else + echo "SOME TESTS FAILED!" + exit 1 +fi