-
Notifications
You must be signed in to change notification settings - Fork 0
Add mongo service to Docker Compose #26
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
046ee18
feat(mongo): Add MongoDB service and environment variables to .env
ebouchut 46e7a5a
docs: Update Docker Compose usage
ebouchut 6986f8d
docs: Fix sections about how to start/stop a container
ebouchut fe31c91
chore(config): Rename environment variable
ebouchut a5f290c
Fix a typo in .env.example
ebouchut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,24 +1,52 @@ | ||
| services: | ||
|
|
||
| db: | ||
| postgres: | ||
| image: postgres:17 | ||
| container_name: learn-dev-postgres | ||
|
|
||
| # Inject database credentials and config (db name, db user, | ||
| # and host port mapping) into the container. | ||
| # Reads from the same .env file passed to `docker compose --env-file ...`. | ||
| # Inject into the container the database credentials and configuration variables defined in the .env file | ||
| # (database names , database user, host and port mappings) | ||
| # as environment variables. | ||
| # This is required for the docker init script in ./docker/init/. | ||
| env_file: | ||
| - .env | ||
|
|
||
| networks: | ||
| - net | ||
| volumes: | ||
| # Init scripts: run once on first container start (empty data dir). | ||
| - ./docker/init:/docker-entrypoint-initdb.d | ||
| # Named volume: preserves data across container stop/start cycles. | ||
| - pgdata:/var/lib/postgresql/data | ||
|
|
||
| - pg_data:/var/lib/postgresql/data | ||
| ports: | ||
| # See src/main/resources/.env.example for details | ||
| - "${POSTGRES_HOST}:${POSTGRES_PORT}:5432" | ||
|
|
||
|
ebouchut marked this conversation as resolved.
|
||
| mongo: | ||
| image: mongo:8.0 | ||
| restart: unless-stopped | ||
| ports: | ||
| - "${MONGO_HOST}:${MONGO_PORT}:27017" | ||
| environment: | ||
| MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USERNAME} | ||
| MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD} | ||
| MONGO_INITDB_DATABASE: ${LEARNDEV_MONGO_DB_NAME} | ||
| volumes: | ||
| - mongo_data:/data/db | ||
| - ./docker/mongo/init:/docker-entrypoint-initdb.d:ro | ||
| networks: | ||
| - net | ||
| healthcheck: | ||
| test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
| start_period: 20s | ||
|
|
||
| networks: | ||
| net: | ||
| # A bridge network connects your services together | ||
| # on an isolated Virtual LAN managed by Docker. | ||
| driver: bridge | ||
|
|
||
| # Named volumes used to preserve data across container stop/start cycles. | ||
| volumes: | ||
| pgdata: | ||
| pg_data: | ||
| mongo_data: | ||
Empty file.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.