diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f6c710c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:latest +RUN apk update && apk add --no-cache python3 py3-pip +RUN mkdir -p /opt/ydl_web_ui +ADD requirements.txt web_ui/ /opt/ydl_web_ui +WORKDIR /opt/ydl_web_ui +RUN pip install --disable-pip-version-check --requirement requirements.txt +RUN pip install --disable-pip-version-check gunicorn +EXPOSE 3000 +USER nobody +ENV YDL_API_HOST= +CMD gunicorn router:app --bind :3000 diff --git a/Makefile b/Makefile index 6869cfa..fd8346e 100644 --- a/Makefile +++ b/Makefile @@ -10,3 +10,7 @@ run: lint: pipenv run black $(SRCDIR) pipenv run pylint $(SRCDIR) + +image: + ver=$$(awk -F'= ' '/__version__/{gsub("\"", ""); print $$2}' web_ui/router.py) && \ + sudo docker build . -t ydl-web-ui:$$ver -t ydl-web-ui:latest diff --git a/README.md b/README.md index db339cc..ad9f5aa 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,11 @@ This UI is written for my personal use and may not have the features you would l # Roadmap -- [ ] Add Dockerfile and docker-compose.yml +- [x] Add Dockerfile and docker-compose.yml - [ ] Handle non-youtube links - [ ] Twitter - [ ] Nicovideo + - [ ] vk.com - [ ] Handle unsupported URLs - [ ] YouTube playlists download - [ ] Advanced settings @@ -22,7 +23,50 @@ This UI is written for my personal use and may not have the features you would l # Installation -I recomment setup with Docker via [docker-compose.yml](docker-compose.yml). +## Docker Compose (easiest) + +Copy [docker-compose.yml](docker-compose.yml) and edit if you want. + +Then up containers: + +``` +docker compose up -d +``` + +ydl-web-ui will listen port 4011/tcp. + +## Docker + +1. [Setup ydl_api_ng](https://github.com/Totonyus/ydl_api_ng#installation). + +2. Install Web UI. + +You must specify your ydl_api_ng instance host as `YDL_API_HOST` environment variable. + +``` +docker run -d \ + --name ydl_web_ui \ + -p 4011:3000 \ + -e YDL_API_HOST=http://1.2.3.4:5011 \ + nxhs/ydl-web-ui:latest +``` + +## Without Docker + +Use python 3.6 or newer. + +Replace `YDL_API_HOST` value to your actual ydl_api_ng instance URL. + +``` +python3 -m venv env +. env/bin/activate +pip install -r requirements.txt +pip install gunicorn +export YDL_API_HOST=http://1.2.3.4:5011 +gunicorn --chdir=./web_ui router:app -b :3000 +``` + +See also gunicorn deployment options: https://docs.gunicorn.org/en/latest/deploy.html # Development diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..87f4361 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,50 @@ +version: "3.1" +services: + web_ui: + container_name: ydl_web_ui + image: nxhs/ydl-web-ui + restart: unless-stopped + depends_on: + - api + ports: + - 4011:3000 + environment: + - YDL_API_HOST=http://api:80 + networks: + - ydl_api_ng + + api: + container_name: ydl_api_ng + image: totonyus/ydl_api_ng + restart: unless-stopped + depends_on: + - redis + ports: + - 5011:80 + volumes: + - ./params:/app/params + - ./logs:/app/logs + - ./downloads:/app/downloads + - ./data:/app/data + - /etc/localtime:/etc/localtime:ro + environment: + - UID=1000 + - GID=1000 + - NB_WORKERS=5 + - LOG_LEVEL=error + # Redis will be disable is this value is not false, remember to also change the setting in params.ini file + - DISABLE_REDIS=false + networks: + - ydl_api_ng + + redis: + container_name: ydl_api_ng_redis + image: redis + restart: unless-stopped + networks: + - ydl_api_ng + volumes: + - /etc/localtime:/etc/localtime:ro + +networks: + ydl_api_ng: