From 967ebfdd37d056d86ed53039eb3a49bacef3c629 Mon Sep 17 00:00:00 2001 From: moochannel Date: Sun, 30 Dec 2018 02:55:32 +0900 Subject: [PATCH] Added Dockerfile and compose sample file. --- .dockerignore | 4 ++ .gitignore | 3 ++ Dockerfile | 108 ++++++++++++++++++++++++++++++++++++++ docker-compose.yml.sample | 18 +++++++ 4 files changed, 133 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml.sample diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000..c069b5cb875bf --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.github +Dockerfile +docker-compose.yml* diff --git a/.gitignore b/.gitignore index 1f77ec17e9d1a..5b42155c3c5e0 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,6 @@ test/cache/* libxpchainconsensus.pc contrib/devtools/split-debug.sh + +docker-compose.yml +docker-compose.override.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000..b500ced0a6ef5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,108 @@ +FROM ubuntu:bionic AS build + +# Change APT source (Development purpose only) +# RUN \ +# sed -i".bak" \ +# "s@http://archive\.ubuntu\.com@http://ubuntu-ashisuto\.ubuntulinux\.jp/ubuntu@" \ +# /etc/apt/sources.list + +# Basic settings +RUN \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + apt-utils && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + language-pack-en tzdata software-properties-common && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + update-locale LANG=en_US.UTF-8 + +# Prepare for build xpchaind +RUN \ + apt-add-repository ppa:bitcoin/bitcoin -y && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential libtool autotools-dev automake pkg-config libssl-dev \ + libevent-dev bsdmainutils python3 libboost-system-dev \ + libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev \ + libboost-test-dev libboost-thread-dev libdb4.8-dev libdb4.8++-dev \ + libminiupnpc-dev libzmq3-dev libunivalue-dev ca-certificates curl && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Build XPChaind +COPY . /usr/src/xpchain +WORKDIR /usr/src/xpchain +RUN \ + ./autogen.sh && \ + ./configure --without-gui && \ + make -j$(nproc) && \ + make install && \ + make clean + + +FROM ubuntu:bionic + +# Change APT source (Development purpose only) +# RUN \ +# sed -i".bak" \ +# "s@http://archive\.ubuntu\.com@http://ubuntu-ashisuto\.ubuntulinux\.jp/ubuntu@" \ +# /etc/apt/sources.list + +ENV \ + XPCHAIND_DATA_DIR=/home/wallet/.xpchain + +# Basic settings +RUN \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + apt-utils && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + language-pack-en tzdata software-properties-common gosu && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + update-locale LANG=en_US.UTF-8 + +# Create a normal user +RUN \ + useradd -d /home/wallet -m -s /bin/bash wallet && \ + gosu wallet mkdir ${XPCHAIND_DATA_DIR} + +# Prepare for run xpchaind +RUN \ + apt-add-repository ppa:bitcoin/bitcoin -y && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + libboost-chrono1.65.1 libboost-filesystem1.65.1 libboost-system1.65.1 \ + libboost-test1.65.1 libboost-thread1.65.1 libc6 libdb4.8++ libevent-2.1-6 \ + libevent-pthreads-2.1-6 libgcc1 libminiupnpc10 libnorm1 libpgm-5.2-0 \ + libsodium23 libssl1.1 libstdc++6 libzmq5 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Copy build xpchaind (and other tools) +COPY --from=build \ + /usr/local/bin/bench_bitcoin /usr/local/bin/test_bitcoin \ + /usr/local/bin/xpchain-cli /usr/local/bin/xpchain-tx /usr/local/bin/xpchaind \ + /usr/local/bin/ + +# Install debug tools (Development purpose only) +# RUN \ +# apt-get update && \ +# DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +# vim sudo && \ +# apt-get clean && \ +# rm -rf /var/lib/apt/lists/* && \ +# echo "wallet ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/wallet + +# Place an entrypoint script (No need at this point) +# COPY docker-entrypoint.sh / +# RUN \ +# chmod +x /docker-entrypoint.sh && \ + +USER wallet +WORKDIR /home/wallet +VOLUME ["${XPCHAIND_DATA_DIR}"] +EXPOSE 8798 18798 +# ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/usr/local/bin/xpchaind", "-printtoconsole", "-nodebuglogfile"] diff --git a/docker-compose.yml.sample b/docker-compose.yml.sample new file mode 100644 index 0000000000000..10f9101618891 --- /dev/null +++ b/docker-compose.yml.sample @@ -0,0 +1,18 @@ +version: '2.3' +services: + wallet: + build: + context: . + image: xpchaind + ports: + - 8798:8798 + - 18798:18798 + volumes: + - wallet-data:/home/wallet/.xpchain +volumes: + wallet-data: + ## Uncomment below to mount host's directory into container + # driver_opts: + # type: none + # device: /path/to/wallet-data + # o: bind