From dd5c0c6f6aa18ed99d52c6527cad834873b2261e Mon Sep 17 00:00:00 2001 From: naviocean Date: Wed, 7 Apr 2021 15:17:41 +0700 Subject: [PATCH] remove submodule, update graphql, add explorer --- .gitmodules | 6 ------ README.md | 8 ++++--- build.sh | 10 ++++++--- docker-compose.yml | 26 +++++++++++++++++----- explorer/Dockerfile | 49 ++++++++++++++++++++++++++++++++++++++++++ explorer/app | 1 - explorer/entrypoint.sh | 11 ++++++++++ 7 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 explorer/Dockerfile delete mode 160000 explorer/app create mode 100644 explorer/entrypoint.sh diff --git a/.gitmodules b/.gitmodules index 988650c..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +0,0 @@ -[submodule "graphql/cardano-graphql"] - path = graphql/cardano-graphql - url = https://github.com/input-output-hk/cardano-graphql.git -[submodule "explorer/app"] - path = explorer/app - url = https://github.com/input-output-hk/cardano-explorer-app.git diff --git a/README.md b/README.md index 5d34aac..606764c 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,7 @@ git clone \ --single-branch \ --branch \ https://github.com/hawkingnetwork/cardano-node-docker.git \ - && cd cardano-node-docker \ - && git submodule update --init --recursive + && cd cardano-node-docker ``` ## Build and Run via Docker Compose @@ -23,7 +22,10 @@ git clone \ bash build.sh ``` -2. Run docker +2. Config Explorer + Change your server's IP in line 184 `- GRAPHQL_API_HOST=192.168.1.219` + +3. Run docker ```console docker-compose up -d && docker-compose logs -f diff --git a/build.sh b/build.sh index 4e98ca2..90ff7de 100644 --- a/build.sh +++ b/build.sh @@ -3,9 +3,9 @@ NODE_VERSION=1.25.1 MONITOR_VERSION=1.0.0 HASURA_VERSION=4.0.0 GRAPHQL_VERSION=4.0.0 - +EXPLORER_VERSION=1.5.0 #build node -docker build ./node -t naviocean/cardano-node:${NODE_VERSION} +docker build ./node -t naviocean/cardano-node:${NODE_VERSION} --build-arg RELEASE=${NODE_VERSION} docker image tag naviocean/cardano-node:${NODE_VERSION} naviocean/cardano-node:latest #build monitor @@ -17,5 +17,9 @@ docker build ./hasura -t naviocean/cardano-graphql-hasura:${HASURA_VERSION} docker image tag naviocean/cardano-graphql-hasura:${HASURA_VERSION} naviocean/cardano-graphql-hasura:latest #build graphql -docker build ./graphql -t naviocean/cardano-graphql:${GRAPHQL_VERSION} +docker build ./graphql -t naviocean/cardano-graphql:${GRAPHQL_VERSION} --build-arg RELEASE=${GRAPHQL_VERSION} docker image tag naviocean/cardano-graphql:${GRAPHQL_VERSION} naviocean/cardano-graphql:latest + +#build explorer +docker build ./explorer -t naviocean/cardano-explorer:${EXPLORER_VERSION} --build-arg RELEASE=${EXPLORER_VERSION} +docker image tag naviocean/cardano-explorer:${EXPLORER_VERSION} naviocean/cardano-explorer:latest diff --git a/docker-compose.yml b/docker-compose.yml index 6558cd1..de7c8b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,6 @@ services: stop_grace_period: 10s ports: - 3001:3001 - - 12798:12798 volumes: - type: volume source: node-ipc @@ -56,8 +55,6 @@ services: postgres: image: postgres:13-alpine - ports: - - 5432:5432 secrets: - postgres_db - postgres_password @@ -123,8 +120,6 @@ services: hasura: image: naviocean/cardano-graphql-hasura:latest - ports: - - 8080:8080 depends_on: - postgres networks: [cardano] @@ -175,6 +170,27 @@ services: max-size: "200k" max-file: "10" + cardano-explorer: + image: naviocean/cardano-explorer:latest + depends_on: + - cardano-graphql + ports: + - 4000:4000 + networks: [cardano] + restart: on-failure + environment: + - CARDANO_NETWORK=testnet + - GRAPHQL_API_PROTOCOL=http + - GRAPHQL_API_HOST=192.168.1.219 + - GRAPHQL_API_PORT=3100 + - GRAPHQL_API_PATH=graphql + - DEBUG=true + - PORT=4000 + logging: + driver: "json-file" + options: + max-size: "200k" + max-file: "10" secrets: postgres_db: file: ./configs/secrets/postgres_db diff --git a/explorer/Dockerfile b/explorer/Dockerfile new file mode 100644 index 0000000..93c3ed9 --- /dev/null +++ b/explorer/Dockerfile @@ -0,0 +1,49 @@ +FROM debian:stable-slim +LABEL name="cardano-node-explorer" +LABEL maintainer="https://github.com/hawkingnetwork" + +ARG NODEJS_MAJOR_VERSION=12 +ARG RELEASE=1.5.0 + +ENV DEBIAN_FRONTEND=nonintercative + +WORKDIR / + +RUN apt-get update && apt-get install curl -y &&\ + curl --proto '=https' --tlsv1.2 -sSf -L https://deb.nodesource.com/setup_${NODEJS_MAJOR_VERSION}.x | bash - &&\ + apt-get install nodejs git -y + +RUN curl --proto '=https' --tlsv1.2 -sSf -L https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list &&\ + apt-get update && apt-get install gcc g++ make gnupg2 yarn -y + +# Clone source code +RUN git clone https://github.com/input-output-hk/cardano-explorer-app.git /app +WORKDIR /app +RUN git fetch --all --recurse-submodules --tags +RUN git tag +RUN git checkout tags/${RELEASE} + +# Creating non root user cardano +RUN useradd -m cardano + +# # Add permissions +RUN chown -R cardano:cardano /app +RUN chmod g+s /app + +# Image clean-up +RUN apt-get autoremove -y +RUN apt-get clean +RUN apt-get autoclean + + + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +RUN chown cardano:cardano /entrypoint.sh +# Switch user +USER cardano:cardano + +EXPOSE 4000 + +CMD ["/entrypoint.sh"] \ No newline at end of file diff --git a/explorer/app b/explorer/app deleted file mode 160000 index bfd86ea..0000000 --- a/explorer/app +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bfd86ea843cc97937b8e283f836c259f466eb7a9 diff --git a/explorer/entrypoint.sh b/explorer/entrypoint.sh new file mode 100644 index 0000000..dc4561a --- /dev/null +++ b/explorer/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +echo "CARDANO_NETWORK=${CARDANO_NETWORK:-testnet}" > .env +echo "GRAPHQL_API_HOST=${GRAPHQL_API_HOST:-cardano-graphql}" >> .env +echo "GRAPHQL_API_PATH=${GRAPHQL_API_PATH:-graphql}" >> .env +echo "GRAPHQL_API_PORT=${GRAPHQL_API_PORT:-3100}" >> .env +echo "GRAPHQL_API_PROTOCOL=${GRAPHQL_API_PROTOCOL:-http}" >> .env + +yarn --offline && yarn static:build + +yarn static:serve -p ${PORT:-4000} \ No newline at end of file