add docker

This commit is contained in:
ge 2023-02-19 22:03:19 +03:00
parent 44158c15a5
commit 743f272072
4 changed files with 111 additions and 2 deletions

11
Dockerfile Normal file
View File

@ -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

View File

@ -10,3 +10,7 @@ run:
lint: lint:
pipenv run black $(SRCDIR) pipenv run black $(SRCDIR)
pipenv run pylint $(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

View File

@ -11,10 +11,11 @@ This UI is written for my personal use and may not have the features you would l
# Roadmap # Roadmap
- [ ] Add Dockerfile and docker-compose.yml - [x] Add Dockerfile and docker-compose.yml
- [ ] Handle non-youtube links - [ ] Handle non-youtube links
- [ ] Twitter - [ ] Twitter
- [ ] Nicovideo - [ ] Nicovideo
- [ ] vk.com
- [ ] Handle unsupported URLs - [ ] Handle unsupported URLs
- [ ] YouTube playlists download - [ ] YouTube playlists download
- [ ] Advanced settings - [ ] Advanced settings
@ -22,7 +23,50 @@ This UI is written for my personal use and may not have the features you would l
# Installation # 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 # Development

50
docker-compose.yml Normal file
View File

@ -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: