Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 4ed17c0

Browse files
committed
Merge pull request #351 from eiabea/docker
Docker
2 parents 61f915c + c41e3a6 commit 4ed17c0

File tree

5 files changed

+148
-17
lines changed

5 files changed

+148
-17
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ target/
5959

6060
.idea/
6161
_trial_temp/
62+
63+
# Docker data
64+
data/
65+
66+
# SSL
67+
ssl/

Dockerfile

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,44 @@
1-
FROM ubuntu:14.04
2-
3-
MAINTAINER Joshua Sindy <[email protected]>
4-
# Examples
5-
# docker build -t observer .
6-
# docker run --rm -it -e flags="--help" observer
7-
# docker run -d --name observer -e flags="--testnet" observer
8-
# docker logs observer
9-
10-
RUN apt-get update
11-
RUN apt-get install -y python-dev python-pip build-essential git libffi-dev libssl-dev
12-
RUN pip install pyopenssl ndg-httpsclient pyasn1
13-
RUN pip install --upgrade pip virtualenv
14-
RUN pip install mock coverage nose pylint
1+
FROM ubuntu:15.04
2+
MAINTAINER eiabea <[email protected]>
3+
4+
# Install required Debian packages
5+
RUN set -ex \
6+
&& echo "deb http://us.archive.ubuntu.com/ubuntu vivid main universe" | tee -a /etc/apt/sources.list \
7+
&& apt-get update -q \
8+
&& apt-get install -q -y build-essential libssl-dev libffi-dev python-dev openssl python-pip libzmq3-dev libsodium-dev autoconf automake pkg-config libtool git \
9+
&& apt-get clean autoclean -q -y \
10+
&& apt-get autoremove -q -y \
11+
&& rm -rf /var/lib/apt/lists/* /var/lib/apt/lists/partial/* /tmp/* /var/tmp/*
12+
13+
# Install libzmq from github
14+
RUN git clone https://github.com/zeromq/libzmq
15+
WORKDIR /libzmq
16+
RUN ./autogen.sh
17+
RUN ./configure
18+
RUN make
19+
RUN make install
20+
RUN ldconfig
21+
22+
# Install cryptography
23+
WORKDIR /
24+
RUN pip install cryptography
25+
26+
# Install Openbazaar-Server from github
1527
RUN git clone https://github.com/OpenBazaar/OpenBazaar-Server.git
1628
WORKDIR /OpenBazaar-Server/
17-
RUN pip install -r requirements.txt && pip install -r test_requirements.txt
29+
RUN pip install -r requirements.txt -r test_requirements.txt
1830
RUN make
31+
32+
# Copy entrypoint script and mark it executable
33+
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
34+
RUN chmod +x /docker-entrypoint.sh
35+
36+
# Create Openbazaar user and set correct permissions
1937
RUN adduser --disabled-password --gecos \"\" openbazaar
2038
RUN chown -R openbazaar:openbazaar /OpenBazaar-Server
2139

22-
USER openbazaar
23-
CMD python openbazaard.py start $flags
40+
VOLUME /root/.openbazaar
41+
VOLUME /ssl
42+
43+
ENTRYPOINT ["/docker-entrypoint.sh"]
44+
CMD ["python", "openbazaard.py", "start"]

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,40 @@ optional arguments:
4545
--pidfile PIDFILE name of the pid file
4646
```
4747

48+
## Docker
49+
50+
- Install [Docker](https://docs.docker.com/engine/installation/).
51+
- Install [DockerCompose](https://docs.docker.com/compose/install/).
52+
53+
#### Set Username and Password
54+
```bash
55+
nano ./docker-compose.yml
56+
```
57+
58+
#### Build and run
59+
```bash
60+
docker-compose up
61+
```
62+
63+
#### Backup
64+
All relevant data will go to
65+
```bash
66+
./data
67+
```
68+
69+
#### SSL Support
70+
- Generate certificate as described [here](https://slack-files.com/T02FPGBKB-F0XK9ND2Q-fc5e6500a3)
71+
72+
- Place the *server.crt* and *server.key* into
73+
```bash
74+
./ssl
75+
```
76+
77+
- Enable SSL in
78+
```bash
79+
./docker-compose.yml
80+
```
81+
82+
4883
## License
4984
OpenBazaar Server is licensed under the [MIT License](LICENSE).

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: "2"
2+
3+
services:
4+
openbazaard:
5+
build: "."
6+
network_mode: "host"
7+
ports:
8+
- "18467:18467"
9+
- "18469:18469/udp"
10+
- "18466:18466"
11+
- "18470:18470"
12+
volumes:
13+
- "./data:/root/.openbazaar"
14+
- "./ssl:/ssl"
15+
environment:
16+
# Should be changed to more secure values
17+
- "OB_USERNAME=username"
18+
- "OB_PASSWORD=password"
19+
- "OB_SSL=false"
20+
- "OB_SSL_CERT=/ssl/server.crt"
21+
- "OB_SSL_KEY=/ssl/server.key"

docker-entrypoint.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
set_username() {
6+
sedEscapedValue="$(echo "$1" | sed 's/[\/&]/\\&/g')"
7+
sed -ri "s/^#?(USERNAME\s*=\s*)\S+/\1$sedEscapedValue/" "/OpenBazaar-Server/ob.cfg"
8+
}
9+
10+
set_password() {
11+
sedEscapedValue="$(echo "$1" | sed 's/[\/&]/\\&/g')"
12+
sed -ri "s/^#?(PASSWORD\s*=\s*)\S+/\1$sedEscapedValue/" "/OpenBazaar-Server/ob.cfg"
13+
}
14+
15+
set_ssl() {
16+
sedEscapedValue="$(echo "$1" | sed 's/[\/&]/\\&/g')"
17+
sed -ri "s/^#?(SSL\s*=\s*)\S+/\1$sedEscapedValue/" "/OpenBazaar-Server/ob.cfg"
18+
}
19+
20+
set_ssl_cert() {
21+
sedEscapedValue="$(echo "$1" | sed 's/[\/&]/\\&/g')"
22+
sed -ri "s/^#?(SSL_CERT\s*=\s*)\S+/\1$sedEscapedValue/" "/OpenBazaar-Server/ob.cfg"
23+
}
24+
25+
set_ssl_key() {
26+
sedEscapedValue="$(echo "$1" | sed 's/[\/&]/\\&/g')"
27+
sed -ri "s/^#?(SSL_KEY\s*=\s*)\S+/\1$sedEscapedValue/" "/OpenBazaar-Server/ob.cfg"
28+
}
29+
30+
echo "Setting username"
31+
set_username $OB_USERNAME
32+
33+
echo "Setting password"
34+
set_password $OB_PASSWORD
35+
36+
if [ "$OB_SSL" = true ] ; then
37+
echo "Setting up SSL"
38+
set_ssl "True"
39+
40+
echo "Setting SSL cert location"
41+
set_ssl_cert $OB_SSL_CERT
42+
43+
echo "Setting SSL key location"
44+
set_ssl_key $OB_SSL_KEY
45+
fi
46+
47+
echo "Executing ${@}"
48+
exec "$@"

0 commit comments

Comments
 (0)