Skip to content

Commit 783c590

Browse files
Merge pull request #28 from MichaelZhao21/mongo-atlas
Added default support for MongoDB Atlas
2 parents 0314c92 + b88bad4 commit 783c590

6 files changed

+163
-90
lines changed

.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
JURY_NAME=
22
JURY_ADMIN_PASSWORD=
33

4+
MONGODB_URI=
45
MONGODB_USER=
56
MONGODB_PASS=

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,28 @@ A project designed to create a new pairwise judging system using modern technolo
44

55
# Deployment
66

7+
## Setup
8+
9+
Copy `.env.template` into `.env` and fill in the environmental variables
10+
11+
Environmental Variables:
12+
13+
```
14+
JURY_NAME="Name of the jury app [Displays on the app!]"
15+
JURY_ADMIN_PASSWORD="Password used to log into the admin dashboard"
16+
17+
MONGODB_URI="MongoDB connection URI string [ONLY for MongoDB Atlas]"
18+
MONGODB_USER="Username for local mongo container [ONLY use if running local mongo instance]"
19+
MONGODB_PASS="Password for local mongo container [ONLY use if running local mongo instance]"
20+
```
21+
22+
I suggest you run the app with MongoDB Atlas! Create a free account and database [here](https://www.mongodb.com/atlas/database). It should provide you a URI string to fill into the `.env` file.
23+
24+
If you would rather use a local instance deployed with docker-compose, you can simply fill in the username and password you want to use with that database.
25+
726
## With Docker
827

9-
Run `docker compose up`
28+
Run `docker compose up` after configuring the `.env` file. If you want to run mongo locally, run `docker compose -f docker-compose-mongo.yml`.
1029

1130
# Developing
1231

@@ -16,9 +35,11 @@ Requirements:
1635

1736
* [Docker](https://www.docker.com/)
1837

19-
Copy `.env.template` into `.env` and fill in the environmental variables
38+
Copy `.env.template` into `.env` and fill in the environmental variables (see above).
39+
40+
Simply run `docker compose -f docker-compose.dev.yml up` and open the page at `localhost:3000`.
2041

21-
Simply run `docker compose -f docker-compose.dev.yml up` and open the page at `localhost:3000`
42+
If you want to run mongo locally, run `docker compose -f docker-compose-mongo.dev.yml`.
2243

2344
## Manual Installation
2445

docker-compose-mongo.dev.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
version: '3.9'
2+
services:
3+
mongo:
4+
build:
5+
context: './'
6+
dockerfile: mongo.Dockerfile
7+
restart: always
8+
environment:
9+
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER}
10+
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASS}
11+
- MONGO_INITDB_DATABASE=jury
12+
- MONGO_REPLICA_SET_NAME=rs0
13+
ports:
14+
- 127.0.0.1:27107:27017
15+
volumes:
16+
- './data:/data/db'
17+
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
18+
- ./init-mongo-dummy.js:/docker-entrypoint-initdb.d/init-mongo-dummy.js
19+
networks:
20+
- jury-dev-network
21+
22+
mongorssetup:
23+
depends_on:
24+
- 'mongo'
25+
image: mongo:latest
26+
environment:
27+
- MONGODB_USER=${MONGODB_USER}
28+
- MONGODB_PASS=${MONGODB_PASS}
29+
volumes:
30+
- .:/scripts
31+
restart: "no"
32+
entrypoint: [ 'bash', '/scripts/init-mongo-rs.sh' ]
33+
networks:
34+
- jury-dev-network
35+
36+
rust-dev:
37+
depends_on:
38+
- 'mongo'
39+
- 'mongorssetup'
40+
container_name: jury-dev-backend
41+
environment:
42+
- MONGODB_URI=mongodb://${MONGODB_USER}:${MONGODB_PASS}@mongo:27017/
43+
- JURY_ADMIN_PASSWORD=${JURY_ADMIN_PASSWORD}
44+
- PORT=8000
45+
- CARGO_TARGET_DIR=/root/target
46+
build:
47+
context: './'
48+
dockerfile: dev.Dockerfile
49+
ports:
50+
- 8000:8000
51+
volumes:
52+
- .:/jury
53+
- ./.cargo/registry:/usr/local/cargo/registry
54+
- ./.target:/root/target
55+
networks:
56+
- jury-dev-network
57+
58+
node-dev:
59+
depends_on:
60+
- 'rust-dev'
61+
container_name: jury-dev-frontend
62+
environment:
63+
- REACT_APP_JURY_NAME=${JURY_NAME}
64+
- REACT_APP_JURY_URL=http://localhost:8000/api
65+
- REACT_APP_HUB=${HEHE:-}
66+
build:
67+
context: './'
68+
dockerfile: client/dev.Dockerfile
69+
ports:
70+
- 3000:3000
71+
volumes:
72+
- ./client:/client
73+
networks:
74+
- jury-dev-network
75+
76+
networks:
77+
jury-dev-network:
78+
driver: bridge

docker-compose-mongo.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: "3.9"
2+
services:
3+
mongo:
4+
build:
5+
context: './'
6+
dockerfile: mongo.Dockerfile
7+
restart: always
8+
environment:
9+
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER}
10+
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASS}
11+
- MONGO_INITDB_DATABASE=jury
12+
- MONGO_REPLICA_SET_NAME=rs0
13+
ports:
14+
- 127.0.0.1:27107:27017
15+
volumes:
16+
- './data:/data/db'
17+
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
18+
networks:
19+
- jury-network
20+
21+
mongorssetup:
22+
depends_on:
23+
- 'mongo'
24+
image: mongo:latest
25+
environment:
26+
- MONGODB_USER=${MONGODB_USER}
27+
- MONGODB_PASS=${MONGODB_PASS}
28+
volumes:
29+
- .:/scripts
30+
restart: "no"
31+
entrypoint: [ 'bash', '/scripts/init-mongo-rs.sh' ]
32+
networks:
33+
- jury-dev-network
34+
35+
rust:
36+
depends_on:
37+
- 'mongo'
38+
- 'mongorssetup'
39+
container_name: jury-main
40+
environment:
41+
- MONGODB_URI=mongodb://${MONGODB_USER}:${MONGODB_PASS}@mongo:27017/
42+
- JURY_ADMIN_PASSWORD=${JURY_ADMIN_PASSWORD}
43+
- PORT=8000
44+
build:
45+
context: './'
46+
dockerfile: Dockerfile
47+
args:
48+
- REACT_APP_JURY_NAME=${JURY_NAME}
49+
- REACT_APP_JURY_URL=/api
50+
- REACT_APP_HUB=${HEHE:-}
51+
ports:
52+
- 8000:8000
53+
networks:
54+
- jury-network
55+
56+
networks:
57+
jury-network:
58+
driver: bridge

docker-compose.dev.yml

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,9 @@
11
version: '3.9'
22
services:
3-
mongo:
4-
build:
5-
context: './'
6-
dockerfile: mongo.Dockerfile
7-
restart: always
8-
environment:
9-
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER}
10-
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASS}
11-
- MONGO_INITDB_DATABASE=jury
12-
- MONGO_REPLICA_SET_NAME=rs0
13-
ports:
14-
- 127.0.0.1:27107:27017
15-
volumes:
16-
- './data:/data/db'
17-
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
18-
- ./init-mongo-dummy.js:/docker-entrypoint-initdb.d/init-mongo-dummy.js
19-
networks:
20-
- jury-dev-network
21-
22-
mongorssetup:
23-
depends_on:
24-
- 'mongo'
25-
image: mongo:latest
26-
environment:
27-
- MONGODB_USER=${MONGODB_USER}
28-
- MONGODB_PASS=${MONGODB_PASS}
29-
volumes:
30-
- .:/scripts
31-
restart: "no"
32-
entrypoint: [ 'bash', '/scripts/init-mongo-rs.sh' ]
33-
networks:
34-
- jury-dev-network
35-
363
rust-dev:
37-
depends_on:
38-
- 'mongo'
39-
- 'mongorssetup'
404
container_name: jury-dev-backend
415
environment:
42-
- MONGODB_URI=mongodb://${MONGODB_USER}:${MONGODB_PASS}@mongo:27017/
6+
- MONGODB_URI=${MONGODB_URI}
437
- JURY_ADMIN_PASSWORD=${JURY_ADMIN_PASSWORD}
448
- PORT=8000
459
- CARGO_TARGET_DIR=/root/target
@@ -52,8 +16,6 @@ services:
5216
- .:/jury
5317
- ./.cargo/registry:/usr/local/cargo/registry
5418
- ./.target:/root/target
55-
networks:
56-
- jury-dev-network
5719

5820
node-dev:
5921
depends_on:
@@ -70,9 +32,3 @@ services:
7032
- 3000:3000
7133
volumes:
7234
- ./client:/client
73-
networks:
74-
- jury-dev-network
75-
76-
networks:
77-
jury-dev-network:
78-
driver: bridge

docker-compose.yml

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,9 @@
11
version: "3.9"
22
services:
3-
mongo:
4-
build:
5-
context: './'
6-
dockerfile: mongo.Dockerfile
7-
restart: always
8-
environment:
9-
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER}
10-
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASS}
11-
- MONGO_INITDB_DATABASE=jury
12-
- MONGO_REPLICA_SET_NAME=rs0
13-
ports:
14-
- 127.0.0.1:27107:27017
15-
volumes:
16-
- './data:/data/db'
17-
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
18-
networks:
19-
- jury-network
20-
21-
mongorssetup:
22-
depends_on:
23-
- 'mongo'
24-
image: mongo:latest
25-
environment:
26-
- MONGODB_USER=${MONGODB_USER}
27-
- MONGODB_PASS=${MONGODB_PASS}
28-
volumes:
29-
- .:/scripts
30-
restart: "no"
31-
entrypoint: [ 'bash', '/scripts/init-mongo-rs.sh' ]
32-
networks:
33-
- jury-dev-network
34-
353
rust:
36-
depends_on:
37-
- 'mongo'
38-
- 'mongorssetup'
394
container_name: jury-main
405
environment:
41-
- MONGODB_URI=mongodb://${MONGODB_USER}:${MONGODB_PASS}@mongo:27017/
6+
- MONGODB_URI=${MONGODB_URI}
427
- JURY_ADMIN_PASSWORD=${JURY_ADMIN_PASSWORD}
438
- PORT=8000
449
build:
@@ -50,9 +15,3 @@ services:
5015
- REACT_APP_HUB=${HEHE:-}
5116
ports:
5217
- 8000:8000
53-
networks:
54-
- jury-network
55-
56-
networks:
57-
jury-network:
58-
driver: bridge

0 commit comments

Comments
 (0)