diff --git a/.gitignore b/.gitignore index 0d5db5f..b310ab8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ .DS_Store + +# docker volumes +/dockervolume \ No newline at end of file diff --git a/README.md b/README.md index 062b57f..b8daf92 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ To run this server, you have to connect to a MongoDB database. Your server will Two options for getting a MONGO_URI for development: 1. (most recommended) Sign up for Mongo Atlas yourself and create a databse for yourself, find the URI by going through the 'connect' flow. -2. Run a local MongoDB instance and connect. +2. Run a local MongoDB instance using Docker Compose with the command `docker compose up`. +3. Run a local MongoDB instance and connect. ### Set up .env @@ -45,6 +46,12 @@ Set your `MONGO_URI` evironment variable in a `.env` file inside `server/`. If y MONGO_URI="mongodb+srv://:@cluster0-cusns.mongodb.net/?retryWrites=true&w=majority" ``` +If you're using Docker Compose, set you `MONGO_URI` to: + +``` +MONGO_URI="mongodb://admin:password@localhost:27017?retryWrites=true&w=majority" +``` + I put an example `.env` file in `.env.sample` feel free to `mv .env.sample .env` to get started. ### To Test diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..7bb1bed --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +version: '3' +services: + mongo: + image: mongo:5.0 + restart: always + ports: + - 27017:27017 + environment: + - MONGO_INITDB_ROOT_USERNAME=admin + - MONGO_INITDB_ROOT_PASSWORD=password + container_name: mongo + volumes: + - './dockervolume/mongodb:/data/db' \ No newline at end of file diff --git a/server/.env.sample b/server/.env.sample new file mode 100644 index 0000000..d40926f --- /dev/null +++ b/server/.env.sample @@ -0,0 +1 @@ +MONGO_URI="mongodb://admin:password@localhost:27017?retryWrites=true&w=majority" \ No newline at end of file