labrocadabro / communitytaught

MIT License
78 stars 31 forks source link

Guide for running the app locally #44

Open labrocadabro opened 8 months ago

labrocadabro commented 8 months ago

We need a comprehensive guide to getting the app running locally.

This includes: forking the repo, installing Node and the necessary dependencies, getting your DB connection (local or remote), importing the data, editing the .env (and some guidance on what each field means), setting up mailhog (with a note that it's optional, and in what circumstances you need it), and guides to Pug and Tailwind.

Links to external documentation are fine, where appropriate, but the goal here is to make the process as step-by-step as possibly.

KhuloodHassan commented 8 months ago

Hii! Can I be assigned this? (I can only start working from 3rd of Jan though as I'm on holiday)

labrocadabro commented 8 months ago

Sure that's no problem at all.

labrocadabro commented 8 months ago

@coltonehrman did some work on this already, with a guide to getting the DB working with Docker. Here it is:

### Setup Local MongoDB using Docker

#### Pre-requisites

1. Install Docker Desktop - https://www.docker.com/products/docker-desktop/

#### Run Docker Image of Mongo

Run this command to create new Docker container for MongoDB.

`docker run --name mongodb -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=user -e MONGO_INITDB_ROOT_PASSWORD=pass mongodb/mongodb-community-server:6.0-ubi8`

- `-p 27017:27017` is used to expose the MongoDB port to your host machine - allowing the app to connect to it directly.
- `-e MONGO_INITDB_ROOT_USERNAME=<user>` is used to set the root username when creating the MongoDB container
- `-e MONGO_INITDB_ROOT_PASSWORD=<pass>` is used to set the root password when creating the MongoDB container.

[Reference](https://www.mongodb.com/compatibility/docker)
### Summary

After doing this, you will have a local MongoDB running on your computer which is assessible throught this URI - `mongodb://user:pass@localhost:27017/admin?retryWrites=true&w=majority`

This connects to the default `admin` database. I was not able to figure out how to get a new DB working locally for some reason. Issues with the Authentication outside of `admin`.
labrocadabro commented 8 months ago

Just an FYI, the database connection has changed slightly and you'll need to update your .env if you've already forked the repo. See example.env for details.

labrocadabro commented 8 months ago

I think I didn't make this clear, but I'd like to keep the setup guide in a separate markdown file, and link to it from the readme.