Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ https://entropychat.app
* The authorization callback URL should be set to:
* http://localhost:3030/oauth/github/callback
* Change the port if your feathers backend is running on a different port
* Note: for `MONGO_HOST`, if running on docker use the `container-name` of db service. Otherwise, the host/ip address of your mongodb instance.
* The oauth flow requires that the client is running at:
* http://localhost:8080
* If your client is running on a different port, you will need to update [server/public/index.html](server/public/index.html) to allow sending messages to the correct port / origin
Expand Down
5 changes: 4 additions & 1 deletion server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ version: '3.7'
services:
db:
image: mongo:4
container_name: server_db
restart: always
volumes:
- ./docker-data/db:/data/db
- ./mongo-init.sh:/docker-entrypoint-initdb.d/mongo-init.sh
ports:
- 27018:${MONGO_PORT}
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USER}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
MONGO_INITDB_DATABASE: ${MONGO_DB_NAME}

api:
# TODO: wait for mongodb to be available...
image: entropychat.api
container_name: server_api
build: .
restart: on-failure
depends_on:
Expand Down
9 changes: 9 additions & 0 deletions server/mongo-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
echo '========================================================================='
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required and happens by default... I removed all containers / images and db-data and was able to start up everything without this script.

The main fix that is needed is this:

  • An init script on the API container that waits to see the message waiting for connections on port 27017 before starting itself.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the waiting connections I made a PR #39

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main fix that is needed is this:

  • An init script on the API container that waits to see the message waiting for connections on port 27017 before starting itself.

See my last comment below.

echo "> use $MONGO_INITDB_DATABASE;"
echo "> db.createCollection('users');"
mongo <<EOF
use $MONGO_INITDB_DATABASE;
db.createCollection('users');
EOF
echo '========================================================================='