calzoneman / sync

Node.JS Server and JavaScript/HTML Client for synchronizing online media
Other
1.45k stars 235 forks source link

Dockerfile and docker support #953

Open davidsiaw opened 1 year ago

davidsiaw commented 1 year ago

I have recently needed to update my branch to the latest changes of the cytube branch and redid the Docker support for my own purposes.

I realize this PR is not immediately mergeable due to several issues:

  1. cyzon may not want the Dockerfile to be in this repo
  2. there are some invasive changes to the package json
  3. it is not clear how to use the Dockerfile correctly (the README additions are very basic and assume a lot of things). I am open to improving the documentation for these purposes.

The changes are a lot simpler compared to when I last proposed docker support (5 years ago) due to advances in both Docker and the MySQL images that are now available, and improvements to cytube that no longer required the invasive changes I once needed to do to get it to work.

Unfortunately I have not thought deeply about how we can incorporate these changes as part of cytube-docker, which has been maintained by someone else for a while now. It is my opinion that these changes are much simpler being in the repository itself.

I am putting this PR in the hopes that perhaps someone will find it useful and perhaps someone will find this the key to providing more meaningful docker support in the future, and also to serve as a point of contact for anyone who wishes to ask me questions about how to set up cytube on Docker.

There are several things that can/need to be improved

  1. Moving the startup to a non-root user internal to the container
  2. Making the environment variables used to configure the server better
  3. Automatically selecting cloudflare IPs instead of hardcoding them in the config template as it is right now
  4. Automatically build a docker container and send it up to dockerhub. (this no longer requires giving perms to dockerhub for anything anymore)

It is my hope that we can find a path forward towards some level of rudimentary Docker support that does not need maintenance, as I did not have to do much to make this work and it is not very complicated to get it working.

In any case if cyzon does not wish for an open ended PR to be here he is free to close it.

calzoneman commented 1 year ago

If you wanted to try to get this into a mergeable state, I'm open to working with you on that review.

Regarding the cytube-docker repository, I'm not sure it's really maintained, the last commit is 3 years ago and I'm not sure anyone is using it. I think the concept is similar, with the main difference being that that repo provides a Docker compose file to model the application + MariaDB stack, which probably makes it a bit easier for users to get started.

davidsiaw commented 1 year ago

Thanks. I am cleaning up the sources now to make them easier to inspect, and the next steps I will take is to remove some of the changes that turn out to no longer be necessary such as my old modifications to the cytube filters.

My goal here is to introduce a Dockerfile that will produce a docker image that anyone who uses docker-based solutions can readily pull in, and that the Dockerfile will require very little maintenance, and that most relevant configuration for docker is exposed via environment variables.

I would like to hear any concerns you may have.

davidsiaw commented 1 year ago

Alright, so this is more or less all that you need to launch cytube on docker. This and knowledge of how to start up a mysql container and expose your ports (basic docker server knowledge).

All that is needed now is possibly an example docker-compose.yml or some documentation on how to set it up for people who just want to paste some stuff onto their console.

My goal is to make it so one can create a container image

docker build -t cytube .

And then run it

docker run -d --name db --network cytube_network ... mariadb
docker run -d --network cytube_network -p 8080:8080 cytube

And have a cytube.

I can go on to write some of that documentation when I catch a breather.

willjr880 commented 1 year ago

Hello, I didn't realise something was in the works already. I have created a docker container (with the expectation that you run it behind a reverse proxy.) So far it appears to be working as expected. https://github.com/willjr880/cytube_docker

Feel free to use to your liking. Wil