From 7b5380668c7fc099bfb1f45217b8a8b4d454bdca Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 7 Feb 2021 19:04:49 +0200 Subject: [PATCH] feat: dockerize pinner application --- docker/Makefile | 13 ++++++++++++ docker/concordia-pinner/Dockerfile | 34 ++++++++++++++++++++++++++++++ docker/env/pinner.env | 16 ++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 docker/concordia-pinner/Dockerfile create mode 100644 docker/env/pinner.env diff --git a/docker/Makefile b/docker/Makefile index 0b47f47..4221351 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -1,6 +1,7 @@ PACKAGES := $(abspath ${CURDIR}/../packages) REPORTS := $(abspath ${CURDIR}/reports) GANACHE_VOLUMES := $(abspath ${CURDIR}/ganache/volumes) +PINNER_VOLUMES := $(abspath ${CURDIR}/pinner/volumes) run: compose-run build-contracts-migrate run-contracts-migrate build-app run-app @echo "Concordia is up and running, head over to http://localhost:7777." @@ -62,6 +63,18 @@ run-app: run-app-host-chain: @docker run -d --env-file=./env/concordia.env --name concordia-app --net=host concordia-app:latest +# Contracts provider 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 +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 +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: + @docker run -d -v ${PINNER_VOLUMES}/orbitdb:/data/orbitdb --env-file=./env/pinner.env --net=host --name concordia-pinner ecentrics/concordia-pinner:latest + # Other clean-images: @docker rmi `docker images -q -f "dangling=true"` diff --git a/docker/concordia-pinner/Dockerfile b/docker/concordia-pinner/Dockerfile new file mode 100644 index 0000000..e44ad70 --- /dev/null +++ b/docker/concordia-pinner/Dockerfile @@ -0,0 +1,34 @@ +# -------------------------------------------------- +# Stage 1 (Runtime) +# -------------------------------------------------- +FROM node:14-buster as runtime +LABEL maintainers.1="Apostolos Fanakis " +LABEL maintainers.2="Panagiotis Nikolaidis " +LABEL gr.thmmy.ecentrics.concordia-image.name="pinner" + +# 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 /usr/src/concordia + +# Copy the root package.json and yarn.lock +COPY ./package.json . +COPY ./yarn.lock . + +# Copy the pinner, contracts and shared package.json files, 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/ + +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 +COPY ./packages/concordia-pinner ./packages/concordia-pinner + +WORKDIR /usr/src/concordia/packages/concordia-pinner + +ENTRYPOINT ["yarn", "start"] \ No newline at end of file diff --git a/docker/env/pinner.env b/docker/env/pinner.env new file mode 100644 index 0000000..e723d45 --- /dev/null +++ b/docker/env/pinner.env @@ -0,0 +1,16 @@ +USE_EXTERNAL_CONTRACTS_PROVIDER=true +ORBIT_DIRECTORY=/data/orbitdb + +#CONTRACTS_PROVIDER_HOST=contracts-provider +CONTRACTS_PROVIDER_HOST=127.0.0.1 +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_PORT=9090 + +WEB3_HOST=127.0.0.1 +WEB3_PORT=8545