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

Commit 8ad341f

Browse files
committed
2 parents d9e81ab + 12604f1 commit 8ad341f

File tree

6 files changed

+154
-22
lines changed

6 files changed

+154
-22
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: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ a Kademlia style DHT. Rest and websocket APIs are available for clients to commu
88

99
Pre-built installers which bundle the client and server components can be found [here](https://github.com/OpenBazaar/OpenBazaar-Installer/releases).
1010

11+
Depending on your system configuration you may need to install some additional dependencies. You can find more detailed, OS specific, instructions [here](https://slack-files.com/T02FPGBKB-F0KJU1CLX-cbbcf8a02c).
12+
1113
To install just this server:
14+
1215
```bash
13-
pip install -r requirements.txt
16+
sudo pip install -r requirements.txt
1417
```
1518

16-
Depending on your system configuration you may need to install some additional dependencies. You can find more detailed, OS specific, instructions [here](https://slack-files.com/T02FPGBKB-F0KJU1CLX-cbbcf8a02c).
17-
1819
## Usage
1920

2021
```bash
@@ -45,5 +46,40 @@ optional arguments:
4546
--pidfile PIDFILE name of the pid file
4647
```
4748

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

market/protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ def rpc_follow(self, sender, proto, signature):
161161

162162
# Send SMTP notification
163163
notification = SMTPNotification(self.db)
164-
notification.send("[OpenBazaar] %s is now following you!" % m.name,
164+
notification.send("[OpenBazaar] %s is now following you!" % f.metadata.name,
165165
"You have a new follower:<br><br>Name: %s<br>GUID: <a href=\"ob://%s\">%s</a><br>"
166166
"Handle: %s" %
167-
(m.name, f.guid.encode('hex'), f.guid.encode('hex'), m.handle))
167+
(f.metadata.name, f.guid.encode('hex'), f.guid.encode('hex'), f.metadata.handle))
168168

169169
return ["True", m.SerializeToString(), self.signing_key.sign(m.SerializeToString())[:64]]
170170
except Exception:

0 commit comments

Comments
 (0)