diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000000000000000000000000000000000000..34bfc8c275a6272358cdbeae71c930cc5c7fabb7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM ubuntu + +RUN mkdir -p /code +COPY requirements.txt /code +WORKDIR /code + +RUN apt update && apt install python3 python3-flask sqlite python3-requests python3-lxml python3-ldap3 python3-icalendar python3-mysql.connector locales -y +RUN locale-gen de_DE.utf8 +RUN apt install git -y + +# Install uwsgi +RUN apt update && apt install python3-pip -y +RUN pip3 install uwsgi + +# Install pylint +RUN pip3 install pylint + +# Install nginx +RUN apt install nginx -y + +COPY . /code + +CMD ["bash", "/code/docker_start.sh"] diff --git a/README.md b/README.md index 690f2ae056060a9c35db3fafb2c96d98e794562c..9e39f2f529277f13b96dcba4c37bac99c4aef7de 100644 --- a/README.md +++ b/README.md @@ -53,3 +53,23 @@ Kurzform unter Ubuntu: Mit python-eigenem Paketmanager: `pip install -r requirements.txt` + +--- + +### Alternative: Docker Image + +Alternativ zu vorigem Setup kann zum lokalen Testen Docker verwendet werden, um die Testversion zu starten: + +1. Lokal das Image erstellen mittels `docker build -t videoag .` in diesem Ordner. +2. Einen entsprechenden Container starten, z.B.: `docker run --rm --name=videoag -p 5000:5000 videoag` + - `--rm` löscht den Container nach dessen Terminierung + - `-p 5000:5000` mappt den Port, damit der Host auf die Webseite zugreifen kann. Nicht den lokalen Port ändern, da ansonsten ggf. Thumbnails oder Videos nicht mehr geladen werden können. + - Zusätzlich kann mittels `-v /lokaler/pfad/:/code` der Source-Code im Container mit dem Host gemounted werden. +3. Webseite unter `localhost:5000` besuchen. + +In dieser Variante sollte in der `config.py` folgendes gesetzt werden: + +``` +SERVER_IP = 'localhost' +VIDEOPREFIX = '/files' +``` diff --git a/docker_start.sh b/docker_start.sh new file mode 100755 index 0000000000000000000000000000000000000000..32c6ff2e686965b428d90ea39b61af240b712ea6 --- /dev/null +++ b/docker_start.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# This file is executed when the docker container starts! +cd /code; + +nginx -c nginx.conf.example -p . & +# Use -C argument to tell uwsgi to chmod 666 /uswgi.sock +exec uwsgi -C -s uwsgi.sock --manage-script-name --mount /=server:app --plugin python --enable-threads diff --git a/nginx.conf.example b/nginx.conf.example index ed1ec3161fae281375c61417dd571d22885ccb67..f81c2eba32dcaa4413f35b374f2e8be28d90390c 100644 --- a/nginx.conf.example +++ b/nginx.conf.example @@ -26,21 +26,22 @@ http { keepalive_timeout 65; types_hash_max_size 2048; server { - #listen 5000; + listen 5000; #listen [::]:5000; - listen localhost:5000; + #listen localhost:5000; error_page 502 /static/500.html; location /static/ { root .; } location /files/ { - auth_request /auth; + auth_request /internal/auth; auth_request_set $trackingcookie $upstream_http_set_cookie; # For use with sshfs (recommended) #alias /mnt/videoag/srv/videoag/released/; #add_header Set-Cookie $trackingcookie; # For use without sshfs - proxy_pass https://videoag.fsmpi.rwth-aachen.de/; + # NO TRAILING SLASH so that /files/ will not be skipped of the request! + proxy_pass https://videoag.fsmpi.rwth-aachen.de; proxy_set_header Host "videoag.fsmpi.rwth-aachen.de"; proxy_set_header Set-Cookie $trackingcookie; }