mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Add Dockerfile for the daemon
This commit is contained in:
parent
c22c06adbe
commit
1b721ea1ec
|
@ -5,7 +5,9 @@
|
|||
<br>
|
||||
- [For `init.d` users](#initd)
|
||||
- [Troubleshooting](#initd-troubleshooting)
|
||||
|
||||
<br>
|
||||
- [For `Docker` users](#docker)
|
||||
- [Troubleshooting](#docker-troubleshooting)
|
||||
|
||||
These instructions are primarily tested on Debian Linux, Wheezy for init.d and Jessie for systemd, but they should work on other POSIX-compliant systems too.
|
||||
|
||||
|
@ -146,3 +148,50 @@ sudo grep "tox-bootstrapd" /var/log/syslog
|
|||
- Make sure tox-bootstrapd has read permission for the config file.
|
||||
|
||||
- Make sure tox-bootstrapd location matches its path in the `/etc/init.d/tox-bootstrapd` init script.
|
||||
|
||||
|
||||
<a name="docker" />
|
||||
##For `Docker` users:
|
||||
|
||||
If you are familiar with Docker and would rather run the daemon in a Docker container, run the following from this directory:
|
||||
|
||||
```sh
|
||||
sudo docker build -t tox-bootstrapd docker/
|
||||
|
||||
sudo useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment "Account to run Tox's DHT bootstrap daemon" --user-group tox-bootstrapd
|
||||
sudo chmod 700 /var/lib/tox-bootstrapd
|
||||
|
||||
sudo docker run -d --name tox-bootstrapd --restart always -v /var/lib/tox-bootstrapd/:/var/lib/tox-bootstrapd/ -p 443:443 -p 3389:3389 -p 33445:33445 -p 33445:33445/udp tox-bootstrapd
|
||||
```
|
||||
|
||||
We create a new user and protect its home directory in order to mount it in the Docker image, so that the kyepair the daemon uses would be shared with the host system, which makes it less likely that you would loose the keypair while playing with the Docker container.
|
||||
|
||||
You can check logs for your public key or any errors:
|
||||
```sh
|
||||
sudo docker logs tox-bootstrapd
|
||||
```
|
||||
|
||||
If you are an experienced Docker user and have a version of Docker that supports `docker cp` both host->container and container->host directions, you might want to skip the directory mounting part and just do:
|
||||
|
||||
```sh
|
||||
sudo docker build -t tox-bootstrapd docker/
|
||||
sudo docker run -d --name tox-bootstrapd --restart always -p 443:443 -p 3389:3389 -p 33445:33445 -p 33445:33445/udp tox-bootstrapd
|
||||
sudo docker logs tox-bootstrapd
|
||||
```
|
||||
|
||||
The keypair is stored in `/var/lib/tox-bootstrapd/keys` file, so if you skipped the directory mounting part and want a new Docker container to retain the same public key that from an old one, just copy/overwrite it from the old container.
|
||||
|
||||
Note that the Docker container runs a script which pulls a list of bootstrap nodes off https://nodes.tox.chat/ and adds them in the config file.
|
||||
|
||||
<a name="docker-troubleshooting" />
|
||||
###Troubleshooting:
|
||||
|
||||
- Check if the container is running:
|
||||
```sh
|
||||
sudo docker ps -a
|
||||
```
|
||||
|
||||
- Check the log for errors:
|
||||
```sh
|
||||
sudo docker logs tox-bootstrapd
|
||||
```
|
||||
|
|
59
other/bootstrap_daemon/docker/Dockerfile
Normal file
59
other/bootstrap_daemon/docker/Dockerfile
Normal file
|
@ -0,0 +1,59 @@
|
|||
FROM debian:jessie
|
||||
|
||||
# get all deps
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
libtool \
|
||||
autotools-dev \
|
||||
automake \
|
||||
checkinstall \
|
||||
check \
|
||||
git \
|
||||
yasm \
|
||||
libsodium-dev \
|
||||
libconfig-dev \
|
||||
python3 \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# install toxcore and daemon
|
||||
WORKDIR /root/
|
||||
RUN git clone https://github.com/irungentoo/toxcore
|
||||
WORKDIR /root/toxcore/
|
||||
RUN ./autogen.sh
|
||||
RUN ./configure --enable-daemon
|
||||
RUN make -j`nproc`
|
||||
RUN make install -j`nproc`
|
||||
RUN ldconfig
|
||||
|
||||
WORKDIR /root/toxcore/other/bootstrap_daemon/
|
||||
|
||||
# add new user
|
||||
RUN useradd --home-dir /var/lib/tox-bootstrapd --create-home \
|
||||
--system --shell /sbin/nologin \
|
||||
--comment "Account to run Tox's DHT bootstrap daemon" \
|
||||
--user-group tox-bootstrapd
|
||||
RUN chmod 700 /var/lib/tox-bootstrapd
|
||||
|
||||
RUN cp tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
||||
|
||||
# remove all the example bootstrap nodes from the config file
|
||||
RUN N=-1 && \
|
||||
while grep -q "bootstrap_nodes =" /etc/tox-bootstrapd.conf; \
|
||||
do \
|
||||
head -n $N tox-bootstrapd.conf > /etc/tox-bootstrapd.conf; \
|
||||
N=$((N-1)); \
|
||||
done
|
||||
|
||||
# add bootstrap nodes from https://nodes.tox.chat/
|
||||
RUN python3 docker/get-nodes.py >> /etc/tox-bootstrapd.conf
|
||||
|
||||
USER tox-bootstrapd
|
||||
|
||||
ENTRYPOINT /usr/local/bin/tox-bootstrapd \
|
||||
--config /etc/tox-bootstrapd.conf \
|
||||
--log-backend stdout \
|
||||
--foreground
|
||||
|
||||
EXPOSE 443 3389 33445
|
||||
EXPOSE 33445/udp
|
49
other/bootstrap_daemon/docker/get-nodes.py
Normal file
49
other/bootstrap_daemon/docker/get-nodes.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Copyright (c) 2016 by nurupo <nurupo.contributions@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
"""
|
||||
|
||||
# Gets a list of nodes from https://nodes.tox.chat/json and prints them out
|
||||
# in the format of tox-bootstrapd config file.
|
||||
|
||||
import urllib.request
|
||||
import json
|
||||
|
||||
response = urllib.request.urlopen('https://nodes.tox.chat/json')
|
||||
raw_json = response.read().decode('ascii', 'ignore')
|
||||
nodes = json.loads(raw_json)['nodes']
|
||||
|
||||
output = 'bootstrap_nodes = ('
|
||||
|
||||
for node in nodes:
|
||||
node_output = ' { // ' + node['maintainer'] + '\n'
|
||||
node_output += ' public_key = "' + node['public_key'] + '"\n'
|
||||
node_output += ' port = ' + str(node['port']) + '\n'
|
||||
node_output += ' address = "'
|
||||
if len(node['ipv4']) > 4:
|
||||
output += node_output + node['ipv4'] + '"\n },\n'
|
||||
if len(node['ipv6']) > 4:
|
||||
output += node_output + node['ipv6'] + '"\n },\n'
|
||||
|
||||
# remove last comma
|
||||
output = output[:-2] + '\n)\n'
|
||||
|
||||
print(output)
|
Loading…
Reference in New Issue
Block a user