-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(BE) User registration / login (#51)
* Add login logic * Add MongoDB replica dockerfiles * Add yorkie key for dev * Implement login logic
- Loading branch information
Showing
24 changed files
with
606 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ARG MONGO_VERSION | ||
|
||
FROM mongo:${MONGO_VERSION} | ||
|
||
# we take over the default & start mongo in replica set mode in a background task | ||
ENTRYPOINT mongod --port $MONGO_REPLICA_PORT --replSet rs0 --bind_ip 0.0.0.0 & MONGOD_PID=$!; \ | ||
# we prepare the replica set with a single node and prepare the root user config | ||
INIT_REPL_CMD="rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: '$MONGO_REPLICA_HOST:$MONGO_REPLICA_PORT' }] })"; \ | ||
# we wait for the replica set to be ready and then submit the command just above | ||
until ($MONGO_COMMAND admin --port $MONGO_REPLICA_PORT --eval "$INIT_REPL_CMD"); do sleep 1; done; \ | ||
# we are done but we keep the container by waiting on signals from the mongo task | ||
echo "REPLICA SET ONLINE"; wait $MONGOD_PID; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
**1. Build Docker Images:** | ||
|
||
```bash | ||
docker-compose build | ||
``` | ||
|
||
This command builds the Docker images defined in the `docker-compose.yml` file. Ensure that the MongoDB image (specified as `mymongodb:latest`) is built using the Dockerfile provided earlier. | ||
|
||
**2. Run Docker Containers:** | ||
|
||
```bash | ||
docker-compose up -d | ||
``` | ||
|
||
This command starts the Docker containers defined in the `docker-compose.yml` file in detached mode (`-d`). | ||
|
||
**3. Additional Information:** | ||
|
||
- The `mongodb` service represents the MongoDB container, which is configured to run in replica set mode. | ||
- The `mongo-init` service runs a command to initiate the replica set. It sleeps for 5 seconds to allow the MongoDB container to start before executing the initialization script (`init-replica-set.js`). | ||
- The MongoDB container exposes port `27017`, and it is mapped to the host port `27017` for external access. | ||
- The containers are connected to a custom network named `mynetwork` to enable communication between them. | ||
|
||
**Note:** Ensure that you have Docker and Docker Compose installed on your system before executing these commands. Adjust the version numbers in the `docker-compose.yml` file if necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: "3.8" | ||
|
||
services: | ||
# This config is for MongoDB v4 | ||
# It's a Replica Set (required for Prisma Client) | ||
mongo: | ||
build: | ||
context: ./ | ||
args: | ||
MONGO_VERSION: 4 | ||
environment: | ||
MONGO_REPLICA_HOST: 127.0.0.1 | ||
MONGO_REPLICA_PORT: 27017 | ||
# Use "mongosh" instead of "mongo" for v5+ | ||
MONGO_COMMAND: "mongo" | ||
ports: | ||
- "27017:27017" | ||
restart: unless-stopped | ||
healthcheck: | ||
# Use "mongosh" instead of "mongo" for v5+ | ||
test: | ||
["CMD", "mongo", "admin", "--port", "27017", "--eval", "db.adminCommand('ping').ok"] | ||
interval: 5s | ||
timeout: 2s | ||
retries: 20 |
Oops, something went wrong.