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

Make a Dockerfile #189

Closed
pineapples5972 opened this issue Dec 14, 2023 · 3 comments
Closed

Make a Dockerfile #189

pineapples5972 opened this issue Dec 14, 2023 · 3 comments

Comments

@pineapples5972
Copy link

pineapples5972 commented Dec 14, 2023

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
Copy link
Owner

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
Copy link
Author

pineapples5972 commented Dec 18, 2023

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
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants