gbowne1 / codebooker

This is a book recommendation app created with React 18.2 and MUI for coders/programmers looking for reccomendations to books on programming/coding to read
MIT License
31 stars 57 forks source link

[FEAT] Docker Image, .devcontainer, etc. #187

Closed gbowne1 closed 1 year ago

gbowne1 commented 1 year ago

For some time, I have considered that some users might want an easy way to set up their development environment that would not take so much configuration to use. Lately we have had a few potential contributors who could have had a much easier job of it with a preconfigured environment.

I think we could solve this A Docker Image, devcontainer, or some other easily workable system could be used for the development environment, seeing as this project has gotten to the stage it is.

A devcontainer could work in VSCode as there are many different remote images and you just need to install the extension for remote.

I am not a Docker expert.

KitaPDev commented 1 year ago

IMO, the only step that's sort of time consuming is setting up MongoDB. Frontend and server just involves running npm install. Not sure if using devcontainers is necessary since there's also a learning curve to it. However, what I've done in my last PR was create a docker-compose.yml file to spin up a MongoDB instance. All that the new dev has to do to setup MongoDB is run docker-compose up -d in the same directory as the docker-compose.yml file. If you'd like me to add it to /src/server/setup/docker-compose.yml I'd be happy to. Just assign the issue to me. If you have any other suggestions, let me know.

gbowne1 commented 1 year ago

Yes @KitaPDev I agree, the most difficult and time consuming issue has been setting up the backend and database and getting the environment set up.

I usually start the project while in my IDE, VSCode, in this order

  1. Start mongod using mongod
  2. Start mongo or mongosh shell
  3. type use codebooker in the shell
  4. in the project root, run npm start to start the react development server and client
  5. run node index.js on this file https://github.com/gbowne1/codebooker/blob/master/src/server/index.js

Before this can be done, if you haven't created it, copy the contents of .variable.env into a new .env file. It's currently missing the mongodb connecting string and port number.

Then run the setup.js script here https://github.com/gbowne1/codebooker/blob/master/src/server/setup/setup.js with node setup.js to create a user.

I know a couple of our contributors use MongoDB Atlas and also MongoDB Compass. I don't know what that experience is like since I only use the command line stuff.

You won't be able to log in without using the test user credentials, or unless you create a user for yourself.

I welcome your ideas, thoughts, concerns, question, etc.

KitaPDev commented 1 year ago

I could create a bash file that would spin up the MongoDB instance in a docker container and run setup.js inside the server/setup folder to make setting up the database and seeding simpler. You wouldn't have to use the shell or any GUI to start the database, it will be started automatically upon creation.

As for the server, I could create a Dockerfile and use it to create a container for the server. But I personally feel like that's overkill and would make debugging more challenging. Not to mention the extra overhead which would require slightly more processing power to handle.

gbowne1 commented 1 year ago

Not everyone's gonna use the container, but I feel like its a good idea to have it there.

I also think it would be a good idea to have a Dockerfile too. I assume people will want to learn how to use Docker, like myself, so I feel like this is a win in either direction, so you could go ahead and make the scripts and Dockerfile. I have the Docker extension installed.