From e03be11a0ee5e9944e99d72c2d3d7e8f8bc7781c Mon Sep 17 00:00:00 2001 From: Bruno Clermont Date: Fri, 17 Nov 2017 12:14:19 +0800 Subject: [PATCH 1/4] fix and improve docker image, add doc for docker-compose --- .dockerignore | 1 - Dockerfile | 67 +++++++++++++++++++++++++++------------------------ README.md | 3 +++ 3 files changed, 38 insertions(+), 33 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 72e8ffc0d..000000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/Dockerfile b/Dockerfile index 37f212b73..5f0097be0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,40 @@ +# Multistage docker build, requires docker 17.05 + +# builder stage +FROM ubuntu:16.04 as builder + +RUN apt-get update && \ + apt-get --no-install-recommends --yes install \ + ca-certificates \ + cmake \ + g++ \ + libboost1.58-all-dev \ + libssl-dev \ + libzmq-dev \ + make \ + pkg-config \ + graphviz \ + doxygen \ + git + +WORKDIR /src +COPY . . +RUN rm -rf build && \ + qmake -j$(nproc) release-static + +# runtime stage FROM ubuntu:16.04 -ENV SRC_DIR /usr/local/src/monero +RUN apt-get update && \ + apt-get --no-install-recommends --yes install \ + ca-certificates \ + libboost1.58-all \ + libssl1.0.0 \ + libzmq1 && \ + apt-get clean && \ + rm -rf /var/lib/apt -RUN set -x \ - && buildDeps=' \ - ca-certificates \ - cmake \ - g++ \ - git \ - libboost1.58-all-dev \ - libssl-dev \ - libzmq3-dev \ - libsodium-dev \ - make \ - pkg-config \ - ' \ - && apt-get -qq update \ - && apt-get -qq --no-install-recommends install $buildDeps - -RUN git clone https://github.com/monero-project/monero.git $SRC_DIR -WORKDIR $SRC_DIR -RUN make -j$(nproc) release-static - -RUN cp build/release/bin/* /usr/local/bin/ \ - \ - && rm -r $SRC_DIR \ - && apt-get -qq --auto-remove purge $buildDeps +COPY --from=builder /src/build/release/bin/* /usr/local/bin/ # Contains the blockchain VOLUME /root/.bitmonero @@ -35,13 +44,7 @@ VOLUME /root/.bitmonero # monero-wallet-cli VOLUME /wallet -ENV LOG_LEVEL 0 -ENV P2P_BIND_IP 0.0.0.0 -ENV P2P_BIND_PORT 18080 -ENV RPC_BIND_IP 127.0.0.1 -ENV RPC_BIND_PORT 18081 - EXPOSE 18080 EXPOSE 18081 -CMD monerod --log-level=$LOG_LEVEL --p2p-bind-ip=$P2P_BIND_IP --p2p-bind-port=$P2P_BIND_PORT --rpc-bind-ip=$RPC_BIND_IP --rpc-bind-port=$RPC_BIND_PORT +ENTRYPOINT ["monerod", "--p2p-bind-ip=0.0.0.0", "--p2p-bind-port=18080", "--rpc-bind-ip=127.0.0.1", "--rpc-bind-port=18081"] diff --git a/README.md b/README.md index 2dec65465..b200d0e32 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,9 @@ Installing a snap is very quick. Snaps are secure. They are isolated with all of # or in background docker run -it -d -v /monero/chain:/root/.bitmonero -v /monero/wallet:/wallet -p 18080:18080 monero + +**Warning** make sure to use `tty: true` with `docker-compose`, if `monerod` don't have a tty it will exit once it's initialized. + Packaging for your favorite distribution would be a welcome contribution! ## Compiling Monero from Source From 81ac0e91cb7302461020eacd1ba5103ceb10cf4a Mon Sep 17 00:00:00 2001 From: Bruno Clermont Date: Sat, 18 Nov 2017 11:22:45 +0800 Subject: [PATCH 2/4] Force docker image to use --non-interactive --- Dockerfile | 2 +- README.md | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f0097be0..329d4f75d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,4 +47,4 @@ VOLUME /wallet EXPOSE 18080 EXPOSE 18081 -ENTRYPOINT ["monerod", "--p2p-bind-ip=0.0.0.0", "--p2p-bind-port=18080", "--rpc-bind-ip=127.0.0.1", "--rpc-bind-port=18081"] +ENTRYPOINT ["monerod", "--p2p-bind-ip=0.0.0.0", "--p2p-bind-port=18080", "--rpc-bind-ip=127.0.0.1", "--rpc-bind-port=18081", "--non-interactive"] diff --git a/README.md b/README.md index b200d0e32..2dec65465 100644 --- a/README.md +++ b/README.md @@ -144,9 +144,6 @@ Installing a snap is very quick. Snaps are secure. They are isolated with all of # or in background docker run -it -d -v /monero/chain:/root/.bitmonero -v /monero/wallet:/wallet -p 18080:18080 monero - -**Warning** make sure to use `tty: true` with `docker-compose`, if `monerod` don't have a tty it will exit once it's initialized. - Packaging for your favorite distribution would be a welcome contribution! ## Compiling Monero from Source From 2ddbc3ef6e808f457550c9e98fe77121aaef6d26 Mon Sep 17 00:00:00 2001 From: Bruno Clermont Date: Sat, 18 Nov 2017 11:27:14 +0800 Subject: [PATCH 3/4] use make --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 329d4f75d..4ba6781fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN apt-get update && \ WORKDIR /src COPY . . RUN rm -rf build && \ - qmake -j$(nproc) release-static + make -j$(nproc) release-static # runtime stage FROM ubuntu:16.04 From e41cc58d7af25b0e6e944864bf83a2a5eb4232c4 Mon Sep 17 00:00:00 2001 From: Bruno Clermont Date: Sat, 18 Nov 2017 14:45:39 +0800 Subject: [PATCH 4/4] Fix docker image dependencies, don't install libraries statically linked --- Dockerfile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4ba6781fc..71b0658a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,9 @@ RUN apt-get update && \ g++ \ libboost1.58-all-dev \ libssl-dev \ - libzmq-dev \ + libzmq3-dev \ + libreadline-dev \ + libsodium-dev \ make \ pkg-config \ graphviz \ @@ -26,11 +28,7 @@ RUN rm -rf build && \ FROM ubuntu:16.04 RUN apt-get update && \ - apt-get --no-install-recommends --yes install \ - ca-certificates \ - libboost1.58-all \ - libssl1.0.0 \ - libzmq1 && \ + apt-get --no-install-recommends --yes install ca-certificates && \ apt-get clean && \ rm -rf /var/lib/apt