user234683 / youtube-local

browser-based client for watching Youtube anonymously and with greater page performance
GNU Affero General Public License v3.0
544 stars 66 forks source link

Make a Dockerfile #189

Closed pineapples5972 closed 11 months ago

pineapples5972 commented 11 months ago

Containerizing is efficient way to ship and deploy application on various servers and platforms. I am having trouble particular to this application no matter which fork I try to containerize. However there is a Docker Image already available [link] however it lacks certain features that even original fork provide like settings interface for example. A dockerfile would be great to build the image and deploy it. I tried using bard, chat gpt anything but couldnt get the service deploy correctly. And always get this error in browser "Error Connection Reset".

For example try running this dockerfile

FROM python:3.10-alpine AS builder

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .

# Create a virtual environment
RUN python3 -m venv venv

# Install dependencies into the virtual environment
RUN . venv/bin/activate && pip install -r requirements.txt

# Switch to the virtual environment for the rest of the build
WORKDIR venv/bin

# Expose the application port
EXPOSE 8080

# Copy the server file
COPY server.py .

# Run the application
CMD ["./", "python3", "server.py"]

Build using: docker build -t youtube-local .

Run using docker run -p 8080:8080 youtube-local

at the end you will the "connection reset error" in browser.

user234683 commented 11 months ago

I've never used docker before, but my guess is that the problem here is that the setting allow_foreign_addresses is False by default. You need to set that to True, as you can see in https://hub.docker.com/r/rusian/yt-local/

You will also need allow_foreign_post_requests to be True if you want write-access features like adding to playlists or changing settings. Of course if you're hosting this on a VPS, you will want some authentication mechanism so the public cannot access it.

pineapples5972 commented 11 months ago

Thanks man its working now what I did now is I changed those settings you mentioned and added -r flag in python3 server.py -r to reload all modules. It turn out it wasnt reloading settings even after I edited settings.py file. Now this is my edited dockerfile which is working.

FROM python:3.10

WORKDIR /app

COPY . .

RUN pip install -r requirements.txt

RUN . venv/bin/activate

EXPOSE 8080

CMD ["bash", "-c", "python server.py -r"]

Note: This will not pull the original fork but in whichever directory you saved it as Dockerfile it will build the image from it. also note that this docker file relies on virtualenv commands ran before dockerizing the application so run virtualenv -p python3 venv before dockerizing it.

to build the image run: docker build -t yt-local .

to run: docker run -d -p 8080:8080 --name yt-local yt-local

dsg-sudo commented 3 months ago

I could manage to create a container for youtube-local. But in container, tor routing don't work. Is there a way to make work tor routing while app working in container?