ChocoMeow / Vocard

Vocard is a simple music bot. It leads to a comfortable experience which is user-friendly, It supports Youtube, Soundcloud, Spotify, Twitch and more!
MIT License
111 stars 38 forks source link

Use Python Virtual Environment in the Docker Image. #24

Closed DaanSelen closed 2 months ago

DaanSelen commented 3 months ago

Hello, I would like to ask if there would be a benefit of installing the dependencies using a Virtual Environment in the Dockerfile.

And also to upload this image to a registry.

For what purpose does the docker-compose.yml have multiple services? Are they needed for operation of Vocard?

Azarath7 commented 3 months ago

Hello! I have been trying to figure out what you've meant by "installing the dependencies using virtual environment in a Dockerfile". I didn't get it... Please explain. As of services in docker-compose - well, both lavalink and mongo are optional, and used for selfhosting those services(you can build the bot without selfhosting them), but they are mandatory for the bot to work, so I strongly advise you to have them in your build, unless you are willing to use public lavalink servers(which are unstable) or free cloud storage(cloud mongodb was working fine for me so far)

DaanSelen commented 3 months ago

I mean getting the Python dependencies like I did in this repo: https://github.com/DaanSelen/WGDashboard-dockerized/tree/main/docker

venv? If you know the package?

Azarath7 commented 3 months ago

Oh, I get it now. Yes, I think it might be better than what we have now. Now all the required libraries are installed from requirements.txt on the host machine. Installing them locally within the container would be better. Docker files were written by me as I was learning and had no experience with Docker at that moment. I want to make Vocard Dashboard work in Docker, it is another separate service, unfortunately, I won't have access to my pc until the end of June.

Azarath7 commented 3 months ago

Oh, I get it now. Yes, I think it might be better than what we have now. Now all the required libraries are installed from requirements.txt on the host machine. Installing them locally within the container would be better. Docker files were written by me as I was learning and had no experience with Docker at that moment. I want to make Vocard Dashboard work in Docker, it is another separate service, unfortunately, I won't have access to my pc until the end of June.

UPD On the second thought though, I've spoken to ChatGPT and it said the following: "The current Dockerfile installs dependencies directly in the Docker container using pip install -r requirements.txt, not on the host machine." So if that is the case, I do not see any benefit from installing dependencies using virtual environment, as it is not necessary and adds more complexity to a simple project. But I'm still learning, maybe I'm wrong?

DaanSelen commented 3 months ago

So if that is the case, I do not see any benefit from installing dependencies using virtual environment, as it is not necessary and adds more complexity to a simple project. But I'm still learning, maybe I'm wrong?

You might be right on this, it would add extra complexity without specifically needing it. I am just looking through certain source files and asking why decisions have been made.

Furthermore, do with my suggestions as you wish, but I see you using path bindings in your docker-compose.yml but they are not exposed as volumes within the Dockerfile. Is this because they are not essential? And perhaps a way to integrate the .env file directly into the Docker (compose) environment argument?

I look forward into hearing your opinion and reasons on these questions.

Azarath7 commented 3 months ago

Thank you for the feedback. The path bindings in the docker-compose.yml are intended to allow for easier development and testing, as they enable changes to be reflected immediately without needing to rebuild the Docker image. These bindings are not essential for the application to run, which is why they are not exposed as volumes within the Dockerfile itself. When it comes to .env file mount - I've had a conversation with the Vocard dev about it. While I personally prefer setting all envs within the docker-compose.yml, we decided to stick with .env file for now.

Azarath7 commented 3 months ago

I have to add that many aspects of running this project in docker are unpolished/unfinished, so if you have suggestions or are willing to contribute - we would totally appreciate that! Thank you in advance!

DaanSelen commented 3 months ago

Sure if you want I can write some bash along the lines of: https://github.com/DaanSelen/WGDashboard-dockerized/blob/main/docker/entrypoint.sh

To handle certain environment variables, or even put them into a files which Vocard can read from? I'll create a fork and go experiment with it.

Azarath7 commented 3 months ago

Yeah, sure, go ahead! Thank you very much!

Azarath7 commented 3 months ago

@DaanSelen how does this docker-compose.yml look?

ChocoMeow commented 3 months ago

Please note that starting from version 2.6.9, all environment configurations will be consolidated within the settings.json file. Please be aware that the .env file and environment settings within docker-compose.yml will be deprecated in the upcoming release.