From a0a6d57c9fe1d8d639088393c86c3fc0ef7ef6df Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Fri, 7 Jun 2019 13:13:11 +0200 Subject: [PATCH] fix(core): update --- .gitlab-ci.yml | 52 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 32 +++++++++++++++++++++++ README.md | 4 +++ connect-to-mainnet | 50 ++++++++++++++++++++++++++++++++++++ default.conf | 21 +++++++++++++++ start-cardano-container.sh | 14 ++++++++++ 6 files changed, 173 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 connect-to-mainnet create mode 100644 default.conf create mode 100644 start-cardano-container.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..c2efe76 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,52 @@ +# gitzone ci_docker +image: hosttoday/ht-docker-node:npmci + +cache: + paths: + - .npmci-cache/ + key: "$CI_BUILD_STAGE" + +before_script: + - npmci npm prepare + +stages: +- test +- release +- trigger +- pages + +testSTABLE: + stage: test + script: + - npmci node install stable + - npmci npm install + - npmci npm test + coverage: /\d+.?\d+?\%\s*coverage/ + tags: + - docker + +release: + image: hosttoday/ht-docker-dbase:npmci + services: + - docker:dind + stage: release + script: + - npmci node install stable + - npmci docker login + - npmci docker build + - npmci docker test + - npmci docker push registry.gitlab.com + only: + - tags + tags: + - docker + - priv + +trigger: + stage: trigger + script: + - npmci trigger + only: + - tags + tags: + - docker diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..051fe99 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM ubuntu:18.04 + +RUN apt-get update &&\ + apt-get install -y git curl bzip2 nginx sudo nano &&\ + useradd -ms /bin/bash cardano &&\ + mkdir -m 0755 /nix &&\ + chown cardano /nix &&\ + mkdir -p /etc/nix &&\ + echo sandbox = false >> /etc/nix/nix.conf &&\ + echo binary-caches = https://cache.nixos.org https://hydra.iohk.io >> /etc/nix/nix.conf &&\ + echo binary-cache-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= >> /etc/nix/nix.conf &&\ + su - cardano -c 'git clone https://github.com/input-output-hk/cardano-sl.git /home/cardano/cardano-sl' + +RUN cat /etc/nix/nix.conf + +ADD default.conf /etc/nginx/conf.d/ + +ADD start-cardano-container.sh /home/cardano/cardano-sl/ +RUN chmod a+x /home/cardano/cardano-sl/start-cardano-container.sh + +RUN echo "cardano ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +USER cardano +ENV USER cardano +RUN curl https://nixos.org/nix/install | sh + +WORKDIR /home/cardano/cardano-sl +RUN git checkout tags/3.0.1 +RUN . /home/cardano/.nix-profile/etc/profile.d/nix.sh &&\ + nix-build -A connectScripts.mainnet.wallet -o connect-to-mainnet + +CMD /home/cardano/cardano-sl/start-cardano-container.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..ed30b0c --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +This repository contains a Dockerfile used to build a docker image of the Cardano SL node with wallet features. + +For more informations read https://cardanodocs.com/introduction/ + diff --git a/connect-to-mainnet b/connect-to-mainnet new file mode 100644 index 0000000..cb57153 --- /dev/null +++ b/connect-to-mainnet @@ -0,0 +1,50 @@ +#!/nix/store/zqh3l3lyw32q1ayb15bnvg9f24j5v2p0-bash-4.4-p12/bin/bash -e + +if [[ "$1" == "--delete-state" ]]; then + echo "Deleting state-wallet-mainnet ... " + rm -Rf state-wallet-mainnet + shift +fi +if [[ "$1" == "--runtime-args" ]]; then + RUNTIME_ARGS=$2 + shift 2 +else + RUNTIME_ARGS="" +fi + +echo "Keeping state in state-wallet-mainnet" +mkdir -p state-wallet-mainnet/logs + +echo "Launching a node connected to 'mainnet' ..." +export LC_ALL=en_GB.UTF-8 +export LANG=en_GB.UTF-8 +if [ ! -d state-wallet-mainnet/tls ]; then + mkdir -p state-wallet-mainnet/tls/server && mkdir -p state-wallet-mainnet/tls/client + /nix/store/q6ji7sdkrw00cdmqvcxdi41xsab5v9f5-cardano-sl-tools-1.3.0/bin/cardano-x509-certificates \ + --server-out-dir state-wallet-mainnet/tls/server \ + --clients-out-dir state-wallet-mainnet/tls/client \ + --configuration-key mainnet_full \ + --configuration-file /nix/store/49jpvj5znnnbw2b326bc7dbcvhsfpm13-cardano-sl-config/lib/configuration.yaml +fi + + +exec /nix/store/g1z2splkx9wb0sgyj1yn8gba1f4ic3sg-cardano-sl-wallet-new-1.3.0/bin/cardano-node \ + --configuration-file /nix/store/49jpvj5znnnbw2b326bc7dbcvhsfpm13-cardano-sl-config/lib/configuration.yaml \ + --configuration-key mainnet_full \ + --tlscert state-wallet-mainnet/tls/server/server.crt \ + --tlskey state-wallet-mainnet/tls/server/server.key \ + --tlsca state-wallet-mainnet/tls/server/ca.crt \ + --log-config /nix/store/49jpvj5znnnbw2b326bc7dbcvhsfpm13-cardano-sl-config/log-configs/connect-to-cluster.yaml \ + --topology "/nix/store/qslalll5z2cyf7cl9ysiv6by4g6arvfx-topology-mainnet" \ + --logs-prefix "state-wallet-mainnet/logs" \ + --db-path "state-wallet-mainnet/db" \ + --wallet-db-path 'state-wallet-mainnet/wallet-db' \ + \ + \ + --keyfile state-wallet-mainnet/secret.key \ + --wallet-address localhost:8090 \ + --wallet-doc-address localhost:8091 \ + --ekg-server localhost:8000 --metrics \ + +RTS -N2 -qg -A1m -I0 -T -RTS \ + \ + $RUNTIME_ARGS diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..7f2f653 --- /dev/null +++ b/default.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name localhost; + + location / { + proxy_pass http://localhost:8090/; + } +} + +server { + listen 443 ssl; + server_name localhost; + + ssl_certificate /home/cardano/cardano-sl/state-wallet-mainnet/tls/server/server.crt; + ssl_certificate_key /home/cardano/cardano-sl/state-wallet-mainnet/tls/server/server.key; + #ssl_client_certificate /home/cardano/cardano-sl/state-wallet-mainnet/tls/server/ca.crt; + + location / { + proxy_pass http://localhost:8090/; + } +} \ No newline at end of file diff --git a/start-cardano-container.sh b/start-cardano-container.sh new file mode 100644 index 0000000..598d443 --- /dev/null +++ b/start-cardano-container.sh @@ -0,0 +1,14 @@ +#!/bin/bash +echo "Docker container ::: Starting node cardano-sl, wallet mode" + +# remove default nginx config +sudo rm -f /etc/nginx/sites-enabled/default + +# try to remove lock file from previous execution +sudo rm -f /home/cardano/cardano-sl/state-wallet-mainnet/wallet-db/open.lock + +# restart nginx service in bg, give 10 sec that cardano node create ssl certif. +sleep 10 && sudo /usr/sbin/service nginx restart && echo "Docker container ::: Nginx service restarted" & + +# start node +sudo /home/cardano/cardano-sl/connect-to-mainnet --runtime-args --no-tls \ No newline at end of file