Skip to content

Commit 7796cc6

Browse files
committed
Rework. See notes below.
Notes: 1. Refactored: * Dockerfile: exploit image caching * Create directory `nodes` for node conf, data, etc. 2. Updates: * bitcoin-cli: `getwalletinfo` command replaces `getinfo` 3. Use supervisord to make container detachable References: 1. PR (for supervisord code): freewil#30
1 parent 7504b3a commit 7796cc6

File tree

12 files changed

+58
-30
lines changed

12 files changed

+58
-30
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.dockerignore
2+
.git
3+
.gitignore
4+
Dockerfile
5+
nodes/logs/.gitkeep
6+
script/

Dockerfile

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,38 @@ FROM ubuntu:14.04
55
MAINTAINER Sean Lavine <lavis88@gmail.com>
66

77
# add bitcoind from the official PPA
8+
# phase 1 (make `add-apt-repository` available):
89
RUN apt-get update
910
RUN apt-get install --yes software-properties-common
11+
# phase 2 (add PPAs -> update cache -> install pkgs):
1012
RUN add-apt-repository --yes ppa:bitcoin/bitcoin
1113
RUN apt-get update
12-
13-
# install bitcoind (from PPA) and make
14-
RUN apt-get install --yes bitcoind make
14+
RUN apt-get install --yes \
15+
bitcoind \
16+
make \
17+
supervisor
1518

1619
# create a non-root user
17-
RUN adduser --disabled-login --gecos "" tester
20+
RUN adduser --disabled-login --gecos "" tester && \
21+
mkdir /home/tester/bitcoin-testnet-box
22+
23+
# run commands from inside the testnet-box directory
24+
WORKDIR /home/tester/bitcoin-testnet-box
25+
26+
# expose two rpc ports for the nodes to allow outside container access
27+
EXPOSE 19001 19011
1828

19-
# run following commands from user's home directory
20-
WORKDIR /home/tester
29+
# describe how to start container
30+
CMD ["/usr/bin/supervisord"]
2131

2232
# copy the testnet-box files into the image
2333
ADD . /home/tester/bitcoin-testnet-box
2434

2535
# make tester user own the bitcoin-testnet-box
2636
RUN chown -R tester:tester /home/tester/bitcoin-testnet-box
2737

38+
# create volume for the nodes
39+
# VOLUME /home/tester/bitcoin-testnet-box/nodes
40+
2841
# use the tester user when running the image
2942
USER tester
30-
31-
# run commands from inside the testnet-box directory
32-
WORKDIR /home/tester/bitcoin-testnet-box
33-
34-
# expose two rpc ports for the nodes to allow outside container access
35-
EXPOSE 19001 19011
36-
CMD ["/bin/bash"]

Makefile

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
BITCOIND=bitcoind
2-
BITCOINGUI=bitcoin-qt
31
BITCOINCLI=bitcoin-cli
42
B1_FLAGS=
53
B2_FLAGS=
6-
B1=-datadir=1 $(B1_FLAGS)
7-
B2=-datadir=2 $(B2_FLAGS)
4+
B1=-datadir=nodes/1 $(B1_FLAGS)
5+
B2=-datadir=nodes/2 $(B2_FLAGS)
86
BLOCKS=1
97
ADDRESS=
108
AMOUNT=
119
ACCOUNT=
1210

13-
start:
14-
$(BITCOIND) $(B1) -daemon
15-
$(BITCOIND) $(B2) -daemon
16-
17-
start-gui:
18-
$(BITCOINGUI) $(B1) &
19-
$(BITCOINGUI) $(B2) &
20-
2111
generate:
2212
$(BITCOINCLI) $(B1) generate $(BLOCKS)
2313

24-
getinfo:
25-
$(BITCOINCLI) $(B1) getinfo
26-
$(BITCOINCLI) $(B2) getinfo
14+
getwalletinfo:
15+
$(BITCOINCLI) $(B1) getwalletinfo
16+
$(BITCOINCLI) $(B2) getwalletinfo
2717

2818
sendfrom1:
2919
$(BITCOINCLI) $(B1) sendtoaddress $(ADDRESS) $(AMOUNT)
@@ -42,5 +32,5 @@ stop:
4232
$(BITCOINCLI) $(B2) stop
4333

4434
clean:
45-
find 1/regtest/* -not -name 'server.*' -delete
46-
find 2/regtest/* -not -name 'server.*' -delete
35+
find nodes/1/regtest/* -not -name 'server.*' -delete
36+
find nodes/2/regtest/* -not -name 'server.*' -delete
File renamed without changes.
File renamed without changes.

nodes/logs/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)