Skip to content

Commit 43648bf

Browse files
Add Torrent client
1 parent 9ef31eb commit 43648bf

8 files changed

Lines changed: 79 additions & 7 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@ Run the server:
3838

3939
Now the application should be accessible from your browser at `http://localhost:1337/streaming/`.
4040

41+
A built-in torrent server is available at: `http://localhost:1337/transmission/web/`
42+
4143

4244
#### CONFIGURATION
4345

46+
Change torrent admin password:
47+
48+
docker-compose -f docker-compose-prod.yml run --rm nginx htpasswd -c /usr/torrent/.htpasswd user1
49+
4450
The videos contained in the Videos/ folder are indexed everytime the populatedb command is launched.
4551

4652
If you want to trigger an update, use the following command

backend/Dockerfile.prod

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,28 @@ RUN npm run build
1212

1313
FROM python:3.8
1414

15-
RUN apt-get update -y && apt-get install -y ffmpeg
15+
RUN apt-get update -y && apt-get install -y ffmpeg transmission-daemon
16+
17+
RUN service transmission-daemon stop
18+
COPY ./backend/transmission.json /etc/transmission-daemon/settings.json
19+
RUN service transmission-daemon start
20+
RUN update-rc.d transmission-daemon defaults
21+
1622

1723
COPY ./backend/openssl.cnf /etc/ssl/openssl.cnf
1824

1925
ENV PYTHONUNBUFFERED 1
2026
COPY --from=0 /usr/src/frontend/build/ /usr/src/frontend/build/
21-
COPY ./backend /usr/src/app/
27+
28+
ADD ./backend/requirements.txt /srv/requirements.txt
29+
RUN pip install -r /srv/requirements.txt
30+
2231
WORKDIR /usr/src/app
2332

24-
RUN pip3 install -r requirements.txt
33+
RUN mkdir /usr/torrent/
34+
RUN chgrp -R debian-transmission /usr/torrent/
35+
RUN chmod -R 777 /usr/torrent/
36+
VOLUME /usr/torrent/
37+
RUN usermod -a -G debian-transmission root
2538

2639

backend/StreamServerApp/management/commands/populatedb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ def handle(self, *args, **kwargs):
2020
keep_files = True
2121
delete_DB_Infos()
2222
populate_db_from_local_folder(settings.VIDEO_ROOT, settings.VIDEO_URL, keep_files)
23+
populate_db_from_local_folder("/usr/torrent/", "/torrents/", keep_files)

backend/StreamServerApp/management/commands/updatedb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ def handle(self, *args, **kwargs):
1919
if kwargs['keepfiles']:
2020
keep_files = True
2121
update_db_from_local_folder(settings.VIDEO_ROOT, settings.VIDEO_URL, keep_files)
22+
update_db_from_local_folder("/usr/torrent/", "/torrents/", keep_files)

backend/transmission.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"blocklist-enabled": 0,
3+
"download-dir": "/usr/torrent/",
4+
"download-limit": 100,
5+
"download-limit-enabled": 0,
6+
"encryption": 1,
7+
"max-peers-global": 200,
8+
"pex-enabled": 1,
9+
"port-forwarding-enabled": 1,
10+
"rpc-authentication-required": 0,
11+
"rpc-password": "transmission",
12+
"rpc-port": 9091,
13+
"rpc-username": "transmission",
14+
"rpc-whitelist": "*",
15+
"rpc-whitelist-enabled": 0,
16+
"rpc-host-whitelist-enabled": 0,
17+
"rpc-enabled":1,
18+
"upload-limit": 100,
19+
"upload-limit-enabled": 0
20+
}

docker-compose-prod.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ volumes:
44
dbvolume:
55
ipython:
66
static_volume:
7+
torrent:
78

89
services:
910
db:
@@ -20,8 +21,8 @@ services:
2021
context: .
2122
dockerfile: ./backend/Dockerfile.prod
2223
restart: always
23-
expose:
24-
- 8000
24+
ports:
25+
- 51413:51413
2526
env_file:
2627
- .env
2728
environment:
@@ -32,7 +33,8 @@ services:
3233
- ./backend/:/usr/src/app/
3334
- /static/
3435
- ipython:/root/.ipython
35-
command: bash -c "python3 /usr/src/app/manage.py collectstatic --no-input && gunicorn StreamingServer.wsgi:application --bind 0.0.0.0:8000"
36+
- torrent:/usr/torrent/:rw
37+
command: bash -c "service transmission-daemon start && python3 /usr/src/app/manage.py collectstatic --no-input && gunicorn StreamingServer.wsgi:application --bind 0.0.0.0:8000"
3638
depends_on:
3739
- db
3840
- redis
@@ -43,6 +45,7 @@ services:
4345
- ./backend/:/usr/src/app/
4446
- ./Videos/:/usr/src/app/Videos
4547
- static_volume:/usr/src/app/staticfiles
48+
- torrent:/usr/torrent/:rw
4649
ports:
4750
- 1337:80
4851
depends_on:

nginx/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
FROM nginx:1.15.0-alpine
22

3+
RUN apk add --no-cache apache2-utils
4+
35
RUN rm /etc/nginx/conf.d/default.conf
4-
COPY nginx.conf /etc/nginx/conf.d
6+
COPY nginx.conf /etc/nginx/conf.d

nginx/nginx.conf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ upstream web {
22
server web:8000;
33
}
44

5+
upstream transmission {
6+
server web:9091;
7+
}
8+
59
server {
610

711
listen 80;
@@ -25,4 +29,26 @@ server {
2529
alias /usr/src/app/Videos/;
2630
}
2731

32+
location /torrents/ {
33+
alias /usr/torrent/;
34+
}
35+
36+
location /transmission/rpc {
37+
auth_basic "Restricted";
38+
auth_basic_user_file /usr/torrent/.htpasswd;
39+
proxy_pass http://transmission;
40+
}
41+
42+
location /transmission/web/ {
43+
auth_basic "Restricted";
44+
auth_basic_user_file /usr/torrent/.htpasswd;
45+
proxy_pass http://transmission;
46+
}
47+
48+
location /transmission/upload {
49+
auth_basic "Restricted";
50+
auth_basic_user_file /usr/torrent/.htpasswd;
51+
proxy_pass http://transmission;
52+
}
53+
2854
}

0 commit comments

Comments
 (0)