Commit 858b6ffd authored by TonyFord's avatar TonyFord
Browse files

integrate faircoind to docker composition. deployment improvements.

parent 215bca3e
scripts/ssl.conf
stages:
- build
- start
- new_ssl
- stop
- uninstall
- remove
......@@ -13,14 +14,13 @@ build-electrumfairchainsx:
refs:
- master
variables:
- $CMD =~ /build/
- $CMD =~ /build|^install/
before_script:
- export RUNNER_UID=`id -u`
- export RUNNER_GID=`id -g`
script:
- docker-compose stop
- docker-compose down
- docker-compose build
- chmod +x deploy/build.sh && deploy/build.sh
start-electrumfairchainsx:
stage: start
tags:
......@@ -29,20 +29,27 @@ start-electrumfairchainsx:
refs:
- master
variables:
- $CMD =~ /build|start/
- $CMD =~ /start|^install/
before_script:
- export RUNNER_UID=`id -u`
- export RUNNER_GID=`id -g`
script:
- chmod +x deploy/start.sh && deploy/start.sh
new_ssl-electrumfairchainsx:
stage: new_ssl
tags:
- FairCoin.Co
only:
refs:
- master
variables:
- $CMD =~ /new_ssl|^install/
before_script:
- export RUNNER_UID=`id -u`
- export RUNNER_GID=`id -g`
- cat ${FAIRCHAINS_CONF} > ~/.faircoin2/fairchains.conf
- cat ${ELECTRUMX_CSR} > ~/.faircoin2/electrumx.csr
- cat ${ELECTRUMX_CRT} > ~/.faircoin2/electrumx.crt
- cat ${ELECTRUMX_KEY} > ~/.faircoin2/electrumx.key
- cat ${FAIRCOINCHAIN_JSON} > ~/.faircoin2/FairCoinChain.json
- cat ${FAIRCOINCHAIN_ELECTRUMX_JSON} > ~/.faircoin2/FairCoinChain.electrumx.json
script:
- docker-compose stop
- docker-compose down
- docker-compose up -d
- chmod +x deploy/new_ssl.sh && deploy/new_ssl.sh
stop-electrumfairchainsx:
stage: stop
......@@ -54,7 +61,7 @@ stop-electrumfairchainsx:
variables:
- $CMD =~ /stop/
script:
- docker-compose stop
- chmod +x deploy/stop.sh && deploy/stop.sh
uninstall-electrumfairchainsx:
stage: uninstall
......@@ -66,8 +73,7 @@ uninstall-electrumfairchainsx:
variables:
- $CMD =~ /uninstall/
script:
- docker-compose stop
- docker-compose down
- chmod +x deploy/uninstall.sh && deploy/uninstall.sh
remove-electrumfairchainsx:
stage: remove
......@@ -79,5 +85,4 @@ remove-electrumfairchainsx:
variables:
- $CMD =~ /remove/
script:
- docker-compose stop
- docker-compose down
- chmod +x deploy/remove.sh && deploy/remove.sh
# Pull base image.
FROM ubuntu:18.04@sha256:5f4bdc3467537cbbe563e80db2c3ec95d548a9145d64453b06939c4592d67b6d
FROM ubuntu:18.04
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8
......@@ -10,7 +10,8 @@ RUN apt-get update -q && \
net-tools \
git \
python3-pyqt5 \
openssl
openssl \
coreutils
#####################################################################################root##
### install nano commandline editor [optional] ( to edit faircoin.conf later if necessary )
......@@ -18,7 +19,9 @@ RUN apt-get install -qy nano
#####################################################################################root##
### install python packages
RUN apt-get install -qy python3-pip
RUN apt-get install -qy \
python3-pip \
libleveldb-dev
RUN python3 -m pip install \
aiorpcx \
......@@ -38,12 +41,15 @@ RUN rm -rf /var/lib/apt/lists/* && \
ARG RUNNER_GID
ARG RUNNER_UID
ENV USER=faircoin
ENV FAIRCHAINS_PATH=/home/faircoin/.faircoin2/
ENV FAIRCHAINS_PATH=/home/faircoin/.fairchains/
RUN groupadd -g $RUNNER_GID faircoin
RUN useradd --create-home --shell /bin/bash faircoin --uid $RUNNER_UID --gid $RUNNER_GID
RUN mkdir -p /home/faircoin/.fairchains
RUN chown -R faircoin:faircoin /home/faircoin/.fairchains
RUN mkdir -p /home/faircoin/.faircoin2
RUN chown -R faircoin:faircoin /home/faircoin/.faircoin2
RUN mkdir -p /home/faircoin/scripts
RUN chown -R faircoin:faircoin /home/faircoin/scripts
USER faircoin
#################################################################################faircoin##
......@@ -53,5 +59,3 @@ RUN git clone https://github.com/fairchainsx/electrumfairchainsx.git
WORKDIR /home/faircoin/electrumfairchainsx
RUN python3 setup.py build
ENTRYPOINT ["./efcx_server"]
# Pull base image.
FROM ubuntu:18.04
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8
#####################################################################################root##
### install base libraries and dependencies for faircoin daemon ###########################
RUN apt-get update -q && \
apt-get install -qy \
git \
make \
autotools-dev \
autoconf \
libtool \
libssl-dev \
libboost-all-dev \
libevent-dev \
libdb++-dev \
libdb-dev
#####################################################################################root##
### install nano commandline editor [optional] ( to edit faircoin.conf later if necessary )
RUN apt-get install -qy nano
#####################################################################################root##
### install python packages
RUN apt-get install -qy python3-pip
RUN python3 -m pip install \
python-bitcoinrpc
#####################################################################################root##
### system cleanup ########################################################################
RUN rm -rf /var/lib/apt/lists/* && \
apt-get autoremove -y && \
apt-get clean
#####################################################################################root##
### create and run user account to image ##################################################
ARG RUNNER_GID
ARG RUNNER_UID
RUN groupadd -g $RUNNER_GID faircoin
RUN useradd --create-home --shell /bin/bash faircoin --uid $RUNNER_UID --gid $RUNNER_GID
USER faircoin
#################################################################################faircoin##
### download and build faircoin daemon and cli ############################################
WORKDIR /home/faircoin
ARG source_repository
RUN git clone $source_repository /home/faircoin/faircoin
WORKDIR /home/faircoin/faircoin
RUN ./autogen.sh && \
./configure --disable-tests --disable-bench --with-incompatible-bdb --disable-wallet && \
make
#################################################################################faircoin##
### initialize blockchain with txindex=1 ##################################################
WORKDIR /home/faircoin/faircoin/src
RUN mv ./faircoind /home/faircoin/faircoind
RUN mv ./faircoin-cli /home/faircoin/faircoin-cli
USER root
RUN apt-get update -q && \
apt-get install -qy \
curl \
net-tools \
telnet
###########################################################################################
### install dependencies for explorer.faircoin.co ###################################root##
RUN python3 -m pip install \
simplejson \
requests \
interruptingcow \
PyMySQL
RUN mkdir -p /home/faircoin/.faircoin2
RUN chown -R faircoin:faircoin /home/faircoin/.faircoin2
WORKDIR /home/faircoin
COPY ./entrypoint.sh ./entrypoint.sh
RUN chown faircoin:faircoin ./entrypoint.sh
USER faircoin
ENTRYPOINT ["./entrypoint.sh"]
......@@ -6,6 +6,8 @@ The service is made for/controlled by gitlab runner.
## Usage
### by Gitlab-Runner
Go Gitlab **CI/CD** -> **Pipeline** and **Run Pipeline**
Enter variable name **CMD**
......@@ -15,7 +17,9 @@ Enter variable name **CMD**
~~~
build # build container ( changes of Dockerfile )
start # start container ( changes of scripts )
new_ssl # create new ssl file for electrumx server
stop # stop container
install # runs build, start and new_ssl stages
uninstall # remove container without to delete the data
remove # remove all data
~~~
......@@ -30,16 +34,40 @@ Go Gitlab **Settings** -> **CI/CD** -> **Variables**
FAIRCHAINS_CONF # conf
~~~
## Development <small>( manual usage )</small>
### by SSH access <small>( manually without gitlab-runner )</small>
#### install docker and docker-compose ( https://docs.docker.com/compose/install/ )
#### clone this project
If you want create an instance manual then follow the instructions.
#### change configuration in ./env and ./env_file
#### Initialize env vars
~~~
chmod +x ./setenv.sh && . setenv.sh
~~~
1. install docker and docker-compose ( https://docs.docker.com/compose/install/ )
1. clone this project
1. change configuration in ./env
1. initialize env vars ./setenv.sh
1. now you can run docker-compose commands
#### Deployment stages
run command from project root folder
~~~
chmod +x ./setenv.sh
deploy/build
deploy/start
deploy/new_ssl
deploy/stop
deploy/install
deploy/uninstall
deploy/remove
~~~
#### Troubleshooting
some commands can be helpful getting shell access to container or get some status info
~~~
console/electrumx # get access to container of electrumfairchainsx server ( same as electrumfairchainsx )
console/electrumfairchainsx # get access to container of electrumfairchainsx server
console/faircoin # get access to container of faircoind
console/ps # list containers status info
console/status # list all ports / processes and faircoind info
~~~
#!/bin/bash
docker-compose exec electrumfairchainsx bash
#!/bin/bash
docker-compose exec electrumfairchainsx bash
#!/bin/bash
docker-compose exec faircoin bash
#!/bin/bash
echo ""
echo -e "console/electrumx\t\t( run container shell )"
echo -e "console/electrumfairchainsx \t( run container shell )"
echo -e "console/faircoin \t\t( run container shell )"
echo -e "console/help"
echo -e "console/ps \t\t\t( list containers )"
echo -e "console/status \t\t\t( network / processes / ... status overview )"
echo ""
#!/bin/bash
docker-compose ps
#!/bin/bash
echo ""
echo "NETWORK"
echo "======================================================================="
echo "container:faircoin"
echo ""
docker-compose exec faircoin netstat -tulpen
echo ""
echo "_______________________________________________________________________"
echo "container:electrumfairchainsx"
echo ""
docker-compose exec electrumfairchainsx netstat -tulpen
echo ""
echo ""
echo ""
echo "PROCESSES"
echo "======================================================================="
echo "container:faircoin"
echo ""
docker-compose exec faircoin ps aux
echo ""
echo "_______________________________________________________________________"
echo "container:electrumfairchainsx"
echo ""
docker-compose exec electrumfairchainsx ps aux
echo ""
echo ""
echo ""
echo "FAIRCOIND"
echo "======================================================================="
echo "container:faircoin"
echo ""
docker-compose exec faircoin ./faircoin-cli getinfo
#!/bin/bash
docker-compose stop --timeout 30
docker-compose down
chmod +x ./entrypoint.sh
docker-compose build
#!/bin/bash
echo ""
echo -e "deploy/build \t\t( build container images )"
echo -e "deploy/start \t\t( start container )"
echo -e "deploy/new_ssl \t\t( create new ssl cert for electrumx server )"
echo -e "deploy/stop \t\t( stop container )"
echo -e "deploy/uninstall \t( stop and remove container, named volumes will NOT removed )"
echo -e "deploy/remove \t\t( stop and remove container and images, named volumes WILL REMOVED )"
echo ""
#!/bin/bash
deploy/build
deploy/start
deploy/new_ssl
#!/bin/bash
chmod +x scripts/create_ssl.sh
docker-compose exec -T electrumfairchainsx /home/faircoin/scripts/create_ssl.sh
docker-compose stop electrumfairchainsx
docker-compose start electrumfairchainsx
#!/bin/bash
docker-compose stop --timeout 30
docker-compose down -v --rmi all --remove-orphans
#!/bin/bash
### configuration files will created or overwritten if exists
cat ${FAIRCHAINS_CONF} > scripts/fairchains.conf
cat ${FAIRCHAINS_CONF} | sed -e s/netname/\#\ netname/g > scripts/faircoin.conf
cat ${FAIRCOINCHAIN_JSON} > scripts/FairCoinChain.json
cat ${FAIRCOINCHAIN_ELECTRUMX_JSON} > scripts/FairCoinChain.electrumx.json
docker-compose stop --timeout 30
docker-compose up -d faircoin
docker-compose exec -T faircoin mv -f scripts/fairchains.conf .faircoin2/
docker-compose exec -T faircoin mv -f scripts/faircoin.conf .faircoin2/
docker-compose exec -T faircoin mv -f scripts/FairCoinChain.json .faircoin2/
docker-compose exec -T faircoin mv -f scripts/FairCoinChain.electrumx.json .faircoin2/
docker-compose exec -T faircoin ./faircoind -disablewallet -daemon
docker-compose up -d electrumfairchainsx
#!/bin/bash
docker-compose stop --timeout 30
#!/bin/bash
docker-compose stop --timeout 30
docker-compose down
......@@ -2,14 +2,39 @@ version: "3.1"
services:
faircoin:
build:
context: ./
dockerfile: Dockerfile_faircoin
args:
source_repository: "https://github.com/faircoin/faircoin.git"
RUNNER_UID: "${RUNNER_UID:-1000}"
RUNNER_GID: "${RUNNER_GID:-1000}"
container_name: electrumfairchainsx-faircoind
restart: always
user: "${RUNNER_UID:-1000}:${RUNNER_GID:-1000}"
volumes:
- fairchains:/home/faircoin/.faircoin2
- ./scripts:/home/faircoin/scripts
electrumfairchainsx:
build:
context: ./
args:
RUNNER_UID: "${RUNNER_UID}"
RUNNER_GID: "${RUNNER_GID}"
container_name: FairCoin.Co-electrumfairchainsx
network_mode: "host"
RUNNER_UID: "${RUNNER_UID:-1000}"
RUNNER_GID: "${RUNNER_GID:-1000}"
container_name: electrumfairchainsx
command: ./efcx_server
ports:
- 51811:51811
- 51812:51812
user: "${RUNNER_UID}:${RUNNER_GID}"
depends_on:
- faircoin
volumes:
- ~/.faircoin2:/home/faircoin/.faircoin2
- fairchains:/home/faircoin/.fairchains
- ./scripts:/home/faircoin/scripts
- ${SSL_CONF}:/home/faircoin/scripts/ssl.conf
volumes:
fairchains:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment