Skip to content

Commit

Permalink
Add docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
PixelSergey committed Dec 31, 2021
1 parent 61a544f commit 4419283
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Finnish-language music server

- Add the server IP to `serverip.txt` (used by the client)
- Add the client IP to `adminips.txt` (used by the server)
- On the music server: `python3 manage.py runserver`
- On the music server: `python3 manage.py runserver` or `sudo docker-compose up --build` if using docker
- On the client: `python3 musa_client.py`
- Siinäpä se
4 changes: 2 additions & 2 deletions client/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
TIMEOUT = 20

with open("serverip.txt", "r") as f:
SERVU = f"http://{f.readlines()[0]}:8000"
SERVU = f"http://{f.readlines()[0]}"

instance = vlc.Instance()
player = instance.media_player_new()
Expand All @@ -20,7 +20,7 @@
print("Getting next song...")
r = requests.post(SERVU + "/next/", verify=False)
if not r.status_code == 200:
print("Not 200 status")
print(f"Invalid response: {r.status_code}\n{r.text}")
break

url = r.text
Expand Down
2 changes: 1 addition & 1 deletion client/serverip.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
127.0.0.1
127.0.0.1:8000
1 change: 1 addition & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
musa.tar
9 changes: 9 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# syntax=docker/dockerfile:1
FROM python:3
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
8 changes: 8 additions & 0 deletions server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.3"

services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
ports:
- "127.0.0.1:8000:8000"
1 change: 1 addition & 0 deletions server/player/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def is_admin(request):
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get('REMOTE_ADDR')
print("Admin check on IP", ip)
return ip in admins


Expand Down
2 changes: 2 additions & 0 deletions server/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Django>=3.0,<4.0
requests>=2.22.0

0 comments on commit 4419283

Please sign in to comment.