Browse Source

Init application dockerization

develop
Apostolos Fanakis 4 years ago
parent
commit
aacc50051e
  1. 10
      docker/Makefile
  2. 25
      docker/concordia-app/Dockerfile
  3. 11
      docker/concordia-app/test-app.sh

10
docker/Makefile

@ -16,9 +16,9 @@ build-migrate-contracts:
build-contracts-tests: 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 concordia-contracts-tests --build-arg TZ=Europe/Athens
run-contract-tests: 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: 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: run-contracts-migrate:
@docker run --rm --env-file=./env/contracts.env concordia-contracts-migrate:latest @docker run --rm --env-file=./env/contracts.env concordia-contracts-migrate:latest
run-contracts-migrate-host-chain: run-contracts-migrate-host-chain:
@ -28,11 +28,11 @@ get-contracts:
# App targets # App targets
build-app: 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: 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 concordia-app-tests --build-arg TZ=Europe/Athens
get-app-tests: run-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' @docker run --rm -v `pwd`/reports/app/:/usr/test-reports/ --env-file=./env/app.env concordia-app-tests:latest
# Other # Other
clean-images: clean-images:

25
docker/concordia-app/Dockerfile

@ -1,7 +1,7 @@
# -------------------------------------------------- # --------------------------------------------------
# Stage 1 (Init contracts build base) # Stage 1 (Init contracts build base)
# -------------------------------------------------- # --------------------------------------------------
FROM node:10-alpine as base FROM node:14-alpine as base
LABEL maintainers.1="Apostolos Fanakis <apostolof@auth.gr>" LABEL maintainers.1="Apostolos Fanakis <apostolof@auth.gr>"
LABEL maintainers.2="Panagiotis Nikolaidis <ezerous@gmail.com>" LABEL maintainers.2="Panagiotis Nikolaidis <ezerous@gmail.com>"
LABEL gr.thmmy.ecentrics.concordia-image.name="app" 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 RUN yarn install --frozen-lockfile
# Gets the rest of the source code # 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) # Stage 2 (Test)
# -------------------------------------------------- # --------------------------------------------------
FROM base as test FROM base as test
WORKDIR /opt/concordia-app
COPY ./docker/concordia-app/test-app.sh .
WORKDIR /usr/src/concordia/packages/concordia-app WORKDIR /usr/src/concordia/packages/concordia-app
ARG SKIP_TESTS ENTRYPOINT ["/opt/concordia-app/test-app.sh"]
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
# -------------------------------------------------- # --------------------------------------------------
# Stage 3 (Build) # Stage 3 (Build)

11
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
Loading…
Cancel
Save