start-again / spookyBot

🎃 A spooky Discord bot
MIT License
9 stars 12 forks source link

Dockerize project #20

Closed mralanlee closed 4 years ago

mralanlee commented 4 years ago

Closes #17

To build run: docker build --build-arg NODE_VERSION=12.18.2 -t spookybot:latest .

Currently, blocked by #19, otherwise docker run spookybot:latest would work

illusi0nary commented 4 years ago

@mralanlee wouldn't it be cool if we have a make file with the regarding commands? So we do not need to build the image manually

Also it would be beneficial if we have a docker-compose file for it. What do you think?

mralanlee commented 4 years ago

A Makefile could make sense but I was thinking if you wanted to pipe this project into a CI and if you wanted to set a span of support on NodeJS versions (i.e. 8-12 for example), you can build multiple images and have it available or tested. Let me know your thoughts on that and I could create a makefile around those requirements.

As for the docker-compose, I'm not sure you're using any other dependencies. I see that you have lowdb setup, which seems to use local volume storage as a database. I would think if you have any additional dependencies like redis, mysql, or etc, it would probably make the most sense to add a docker-compose requirement then.

LucasCtrl commented 4 years ago

I have never used a docker in the past. How does it work and what does it bring to the project? I thought I read that the data in the container can be deleted if it crashes. There wouldn't be any problems with the project especially since the data is stored in the db/servers.json file?

illusi0nary commented 4 years ago

@LucasCtrl the benefits of docker here would be that we can also deploy it easily to another server if your raspberry pi get overheated :ghost: It also makes it easier to maintain for new contributors, because they do not need the prerequisite of npm beeing installed on their computer, they only need docker and in theory they could just use one command to start the bot. We could also add some github actions based on that if its dockerized - to keep a little bit of standard up.

Docker in general is a seperated environment which is the same for everyone so we do not tackle the issue that node versions are not matching or new contributors complain about that it is not working for them.

For the persistance we could use a mounted volume which is then not deleting stuff or just a simple docker volume which is a bit more temporary - but i would suggest going with a mounted volume.

mralanlee commented 4 years ago

Pretty much with @illusi0nary has stated.

It pretty much guarantees that if the docker image builds and runs on your computer (or a contributors setup) fine, it should work fine in a CI environment, others computers, or a server without any problem.

LucasCtrl commented 4 years ago

Ok thanks! I know that @illusi0nary has started working on it and will explain me how it works in detail. Either he'll merge the PR because it's good or we'll do it later in the week 😉

illusi0nary commented 4 years ago

@LucasCtrl i will just do the server infrastructure and the github actions and we can possibly look forward to use this branch as a base for the dockerisation :-)

ghost commented 4 years ago

What is Docker?

illusi0nary commented 4 years ago

@dragonDScript maybe i should give an introduction like a little "Meetup" about docker and how it works?

ghost commented 4 years ago

🐱‍👤 I'm a ninja cat. @illusi0nary

mralanlee commented 4 years ago

What is Docker?

In short, Docker is containerization technology. It lets you isolate the dependencies and the application an image. It packs all the things you need to run this application and ensures that if someone else was to run it, it'd work exactly the same. For this specific case, it means that people with different versions of Node.js OR if they do not have Node.js installed, they can run this application on their computer without worrying about dependency issues (because its already baked into the application).

Now, imagine you have to deploy this to a server or the cloud. You may do your dev work on MacOS or Windows, but say you'd want to deploy this to an Ubuntu server, where the requirements or specs of the server differs from your own environment. Before Docker, you'd have to make sure you provision your server with the right dependencies of Node.js or anything else that the host may require to run an application. Docker pretty much simplifies that.

illusi0nary commented 4 years ago

It is accepted, but will not be merged because it will come soon with a new update! :-)