Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tubular) make tubular configurable #4

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
FROM python:3.9.18-bullseye
VOLUME [ "/data" ]
WORKDIR /data

# Make /data, /videos, and port configurable with environment variables
ARG CONFIG_DIR=/data
ARG DOWNLOAD_DIR=/videos
ARG PORT=8000
ARG HOST=0.0.0.0

VOLUME [ "$CONFIG_DIR" ]
VOLUME [ "$DOWNLOAD_DIR" ]

WORKDIR $CONFIG_DIR

# Copy your application code
COPY . .
RUN pip install --no-cache-dir -r requirements.txt

RUN pip install --no-cache-dir -r requirements.txt

# Set the environment variables
ENV CONFIG_DIR=$CONFIG_DIR
ENV DOWNLOAD_DIR=$DOWNLOAD_DIR
ENV PORT=$PORT
ENV HOST=$HOST

# Expose the specified port
EXPOSE $PORT

# Start the application
CMD ["python3", "./app/tubular.py"]
EXPOSE 8000
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ Currently thanks to scrapetube and youtube_dl libraries with my own added specia
version: '3'
services:
app:
image: ghcr.io/beheadedstraw/tubular:main
image: ghcr.io/beheadedstraw/tubular:dev
container_name: tubular
restart: always
ports:
- 8000:8000
working_dir: /data
environment:
- HOST=0.0.0.0 # internal ip, leave as is.
- PORT=8000 # internal port
- CONFIG_DIR=/data # internal config path
- DOWNLOAD_DIR=/videos # internal download path
volumes:
- ./:/data #data folder for app src
- /Videos:/videos #folder to store videos ***CHANGE THIS TO WHERE YOU WANT TO STORE VIDS***
- /tubular/config:/data #data folder for app src
- /tubular/videos:/videos #folder to store videos ***CHANGE THIS TO WHERE YOU WANT TO STORE VIDS***
```

## FAQ
Expand Down
11 changes: 11 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

# Define environment variables
HOST = os.environ.get("HOST", "0.0.0.0")
PORT = int(os.getenv("PORT", 8000))
CONFIG_DIR = os.getenv("CONFIG_DIR", "/data")
DOWNLOAD_DIR = os.getenv("DOWNLOAD_DIR", "/videos")
5 changes: 3 additions & 2 deletions app/tubular.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
import time
from static import *
from db import DB
from config import PORT, HOST, DOWNLOAD_DIR

############ Change These ####################

#change this to set the download location for videos
download_location = "/videos"
download_location = DOWNLOAD_DIR

##############################################

Expand Down Expand Up @@ -231,4 +232,4 @@ def downloader_thread():
)

if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000, log_level=20)
uvicorn.run(app, host=HOST, port=PORT, log_level=20)
10 changes: 7 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ services:
restart: always
ports:
- 8000:8000
working_dir: /data
environment:
- HOST=0.0.0.0
- PORT=8000
- CONFIG_DIR=/data
- DOWNLOAD_DIR=/videos
volumes:
- ./:/data #data folder for app src
- /Videos:/videos #folder to store videos ***PLEASE CHANGE THIS***
- /tubular/config:/data
- /tubular/videos:/videos
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fastapi
scrapetube
requests
bs4
uvicorn
youtube_dl @ git+https://github.com/ytdl-org/youtube-dl@master
fastapi
starlette
starlette
scrapetube==2.5.1
requests==2.31.0
bs4==0.0.1
uvicorn==0.23.2
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll eventually make my own stable fork of youtube_dl as of right now the version in the pip repository are borked so be careful with versions here.

youtube_dl==2021.12.17
python-dotenv==1.0.0
Loading