Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added default support for MongoDB Atlas #28

Merged
merged 2 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
JURY_NAME=
JURY_ADMIN_PASSWORD=

MONGODB_URI=
MONGODB_USER=
MONGODB_PASS=
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,28 @@ A project designed to create a new pairwise judging system using modern technolo

# Deployment

## Setup

Copy `.env.template` into `.env` and fill in the environmental variables

Environmental Variables:

```
JURY_NAME="Name of the jury app [Displays on the app!]"
JURY_ADMIN_PASSWORD="Password used to log into the admin dashboard"

MONGODB_URI="MongoDB connection URI string [ONLY for MongoDB Atlas]"
MONGODB_USER="Username for local mongo container [ONLY use if running local mongo instance]"
MONGODB_PASS="Password for local mongo container [ONLY use if running local mongo instance]"
```

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.

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.

## With Docker

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

# Developing

Expand All @@ -16,9 +35,11 @@ Requirements:

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

Copy `.env.template` into `.env` and fill in the environmental variables
Copy `.env.template` into `.env` and fill in the environmental variables (see above).

Simply run `docker compose -f docker-compose.dev.yml up` and open the page at `localhost:3000`.

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

## Manual Installation

Expand Down
78 changes: 78 additions & 0 deletions docker-compose-mongo.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version: '3.9'
services:
mongo:
build:
context: './'
dockerfile: mongo.Dockerfile
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER}
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASS}
- MONGO_INITDB_DATABASE=jury
- MONGO_REPLICA_SET_NAME=rs0
ports:
- 127.0.0.1:27107:27017
volumes:
- './data:/data/db'
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
- ./init-mongo-dummy.js:/docker-entrypoint-initdb.d/init-mongo-dummy.js
networks:
- jury-dev-network

mongorssetup:
depends_on:
- 'mongo'
image: mongo:latest
environment:
- MONGODB_USER=${MONGODB_USER}
- MONGODB_PASS=${MONGODB_PASS}
volumes:
- .:/scripts
restart: "no"
entrypoint: [ 'bash', '/scripts/init-mongo-rs.sh' ]
networks:
- jury-dev-network

rust-dev:
depends_on:
- 'mongo'
- 'mongorssetup'
container_name: jury-dev-backend
environment:
- MONGODB_URI=mongodb://${MONGODB_USER}:${MONGODB_PASS}@mongo:27017/
- JURY_ADMIN_PASSWORD=${JURY_ADMIN_PASSWORD}
- PORT=8000
- CARGO_TARGET_DIR=/root/target
build:
context: './'
dockerfile: dev.Dockerfile
ports:
- 8000:8000
volumes:
- .:/jury
- ./.cargo/registry:/usr/local/cargo/registry
- ./.target:/root/target
networks:
- jury-dev-network

node-dev:
depends_on:
- 'rust-dev'
container_name: jury-dev-frontend
environment:
- REACT_APP_JURY_NAME=${JURY_NAME}
- REACT_APP_JURY_URL=http://localhost:8000/api
- REACT_APP_HUB=${HEHE:-}
build:
context: './'
dockerfile: client/dev.Dockerfile
ports:
- 3000:3000
volumes:
- ./client:/client
networks:
- jury-dev-network

networks:
jury-dev-network:
driver: bridge
58 changes: 58 additions & 0 deletions docker-compose-mongo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: "3.9"
services:
mongo:
build:
context: './'
dockerfile: mongo.Dockerfile
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER}
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASS}
- MONGO_INITDB_DATABASE=jury
- MONGO_REPLICA_SET_NAME=rs0
ports:
- 127.0.0.1:27107:27017
volumes:
- './data:/data/db'
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
networks:
- jury-network

mongorssetup:
depends_on:
- 'mongo'
image: mongo:latest
environment:
- MONGODB_USER=${MONGODB_USER}
- MONGODB_PASS=${MONGODB_PASS}
volumes:
- .:/scripts
restart: "no"
entrypoint: [ 'bash', '/scripts/init-mongo-rs.sh' ]
networks:
- jury-dev-network

rust:
depends_on:
- 'mongo'
- 'mongorssetup'
container_name: jury-main
environment:
- MONGODB_URI=mongodb://${MONGODB_USER}:${MONGODB_PASS}@mongo:27017/
- JURY_ADMIN_PASSWORD=${JURY_ADMIN_PASSWORD}
- PORT=8000
build:
context: './'
dockerfile: Dockerfile
args:
- REACT_APP_JURY_NAME=${JURY_NAME}
- REACT_APP_JURY_URL=/api
- REACT_APP_HUB=${HEHE:-}
ports:
- 8000:8000
networks:
- jury-network

networks:
jury-network:
driver: bridge
46 changes: 1 addition & 45 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,9 @@
version: '3.9'
services:
mongo:
build:
context: './'
dockerfile: mongo.Dockerfile
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER}
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASS}
- MONGO_INITDB_DATABASE=jury
- MONGO_REPLICA_SET_NAME=rs0
ports:
- 127.0.0.1:27107:27017
volumes:
- './data:/data/db'
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
- ./init-mongo-dummy.js:/docker-entrypoint-initdb.d/init-mongo-dummy.js
networks:
- jury-dev-network

mongorssetup:
depends_on:
- 'mongo'
image: mongo:latest
environment:
- MONGODB_USER=${MONGODB_USER}
- MONGODB_PASS=${MONGODB_PASS}
volumes:
- .:/scripts
restart: "no"
entrypoint: [ 'bash', '/scripts/init-mongo-rs.sh' ]
networks:
- jury-dev-network

rust-dev:
depends_on:
- 'mongo'
- 'mongorssetup'
container_name: jury-dev-backend
environment:
- MONGODB_URI=mongodb://${MONGODB_USER}:${MONGODB_PASS}@mongo:27017/
- MONGODB_URI=${MONGODB_URI}
- JURY_ADMIN_PASSWORD=${JURY_ADMIN_PASSWORD}
- PORT=8000
- CARGO_TARGET_DIR=/root/target
Expand All @@ -52,8 +16,6 @@ services:
- .:/jury
- ./.cargo/registry:/usr/local/cargo/registry
- ./.target:/root/target
networks:
- jury-dev-network

node-dev:
depends_on:
Expand All @@ -70,9 +32,3 @@ services:
- 3000:3000
volumes:
- ./client:/client
networks:
- jury-dev-network

networks:
jury-dev-network:
driver: bridge
43 changes: 1 addition & 42 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,9 @@
version: "3.9"
services:
mongo:
build:
context: './'
dockerfile: mongo.Dockerfile
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGODB_USER}
- MONGO_INITDB_ROOT_PASSWORD=${MONGODB_PASS}
- MONGO_INITDB_DATABASE=jury
- MONGO_REPLICA_SET_NAME=rs0
ports:
- 127.0.0.1:27107:27017
volumes:
- './data:/data/db'
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
networks:
- jury-network

mongorssetup:
depends_on:
- 'mongo'
image: mongo:latest
environment:
- MONGODB_USER=${MONGODB_USER}
- MONGODB_PASS=${MONGODB_PASS}
volumes:
- .:/scripts
restart: "no"
entrypoint: [ 'bash', '/scripts/init-mongo-rs.sh' ]
networks:
- jury-dev-network

rust:
depends_on:
- 'mongo'
- 'mongorssetup'
container_name: jury-main
environment:
- MONGODB_URI=mongodb://${MONGODB_USER}:${MONGODB_PASS}@mongo:27017/
- MONGODB_URI=${MONGODB_URI}
- JURY_ADMIN_PASSWORD=${JURY_ADMIN_PASSWORD}
- PORT=8000
build:
Expand All @@ -50,9 +15,3 @@ services:
- REACT_APP_HUB=${HEHE:-}
ports:
- 8000:8000
networks:
- jury-network

networks:
jury-network:
driver: bridge