-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add mongo-express command #19
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Documentation links | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
markdown-test-links: | ||
name: Markdown test links | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone sources | ||
uses: actions/checkout@v4 | ||
with: | ||
path: sources | ||
|
||
- name: Lauch localhost server | ||
run: | | ||
sudo npm install --global http-server | ||
http-server ./sources & | ||
|
||
- name: Set up Ruby 2.6 | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6 | ||
|
||
- name: Check links in Markdown files | ||
run: | | ||
gem install awesome_bot | ||
cd sources | ||
awesome_bot README.md --skip-save-results --allow-dupe --base-url http://localhost:8080/ --white-list ddev.site |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,38 +2,58 @@ | |
|
||
## What is ddev-mongo? | ||
|
||
This repository provides Mongo and Mongo Express add-on to [DDEV](https://ddev.readthedocs.io). | ||
This repository provides Mongo and Mongo Express add-on to [DDEV](https://ddev.readthedocs.io/en/stable/). | ||
|
||
It's based on [MongoDb from Docker Hub](https://hub.docker.com/_/mongo?tab=description#-via-docker-stack-deploy-or-docker-compose), [DDEV custom compose files](https://ddev.readthedocs.io/en/stable/users/extend/custom-compose-files/) and [API Platform tutorial](https://api-platform.com/docs/core/mongodb/#enabling-mongodb-support). | ||
|
||
## Installation | ||
|
||
For DDEV v1.23.5 or above run | ||
|
||
```bash | ||
ddev add-on get ddev/ddev-mongo | ||
``` | ||
|
||
For earlier versions of DDEV run | ||
|
||
```bash | ||
ddev get ddev/ddev-mongo | ||
``` | ||
|
||
Then restart your project | ||
|
||
```bash | ||
ddev restart | ||
``` | ||
|
||
## Configuration | ||
|
||
1. Your project will likely require the [Doctrine MongoDB ODM bundle](https://github.com/doctrine/DoctrineMongoDBBundle) | ||
`ddev composer require doctrine/mongodb-odm-bundle:^4.0.0@beta doctrine/mongodb-odm:^2.0.0@beta` | ||
|
||
2. In your application `.env` or other client, set the connection string: | ||
|
||
``` | ||
MONGODB_URL=mongodb://db:db@mongo:27017 | ||
MONGODB_DB=api | ||
``` | ||
|
||
Mongo Express will now be accessible from `http://<project>.ddev.site:9091` | ||
``` | ||
MONGODB_URL=mongodb://db:db@mongo:27017 | ||
``` | ||
|
||
Mongo Express will now be accessible by running `ddev mongo-express` command. | ||
|
||
## Features | ||
|
||
### `ddev mongosh` command | ||
|
||
This command will run the `mongosh` (mongoDB Shell) command in the `mongo` container. Please [read the documentation](https://www.mongodb.com/docs/mongodb-shell/) for more information. | ||
|
||
### `ddev mongo-express` command | ||
|
||
## Caveats: | ||
This command opens your browser to the Mongo Express page. | ||
|
||
* The php extension (phpX.X-mongodb) is set up in `.ddev/config.mongo.yaml` using `webimage_extra_packages`. If you have an earlier `webimage_extra_packages` in your config.yaml, this will override it. You may want to edit your config.yaml to do what you want and remove the config.mongo.yaml. | ||
* You can't define custom MongoDB configuration with this current setup. | ||
* You can't use `ddev import-db` to import to mongo. | ||
## Caveats: | ||
|
||
- The php extension (phpX.X-mongodb) is set up in `.ddev/config.mongo.yaml` using `webimage_extra_packages`. If you have an earlier `webimage_extra_packages` in your config.yaml, this will override it. You may want to edit your config.yaml to do what you want and remove the config.mongo.yaml. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is not true, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I will remove this. |
||
- You can't define custom MongoDB configuration with this current setup. | ||
- You can't use `ddev import-db` to import to mongo. | ||
|
||
**Based on the original [ddev-contrib recipe](https://github.com/ddev/ddev-contrib/tree/master/docker-compose-services/mongodb)** | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
## #ddev-generated: If you want to edit and own this file, remove this line. | ||
## Description: Launch a browser with Mongo Express | ||
## Usage: mongo-express | ||
## Example: "ddev mongo-express" | ||
|
||
# Determine whether to use HTTP or HTTPS based on environment | ||
PROTOCOL="HTTP" | ||
if [ "${DDEV_PRIMARY_URL%://*}" != "http" ] && [ -z "${GITPOD_WORKSPACE_ID:-}" ] && [ "${CODESPACES:-}" != "true" ]; then | ||
PROTOCOL="HTTPS" | ||
fi | ||
|
||
# Fetch the appropriate port within the mongo-express container | ||
DDEV_MONGO_EXPRESS_PORT=$(ddev exec -s mongo-express sh -c "printenv | grep -w ${PROTOCOL}_EXPOSE | cut -d '=' -f 2 | cut -d ':' -f 1") | ||
|
||
if [ -z "$DDEV_MONGO_EXPRESS_PORT" ]; then | ||
echo "Error: Could not retrieve Mongo Express port." | ||
exit 1 | ||
fi | ||
|
||
ddev launch :"$DDEV_MONGO_EXPRESS_PORT" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#ddev-generated | ||
# If omit_containers[ddev-router] then this file will be replaced | ||
# with another with a `ports` statement to directly expose port 9091 to 8081 | ||
services: {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
name: mongo | ||
|
||
pre_install_actions: | ||
- | | ||
#ddev-description:Create config.mongo.yaml with webimage_extra_packages in it | ||
printf '#ddev-generated\nwebimage_extra_packages: ["php${DDEV_PHP_VERSION}-mongodb"]\n' >.ddev/config.mongo.yaml | ||
- | | ||
#ddev-description:Create config.mongo.yaml with webimage_extra_packages in it | ||
printf '#ddev-generated\nwebimage_extra_packages: ["php${DDEV_PHP_VERSION}-mongodb"]\n' >.ddev/config.mongo.yaml | ||
# Ensure we're on DDEV 1.23+. It's required for the `redis-commander` command (launch by port). | ||
- | | ||
#ddev-nodisplay | ||
#ddev-description:Checking DDEV version | ||
(ddev debug capabilities | grep corepack >/dev/null) || (echo "Please upgrade DDEV to v1.23+ to enable launching." && false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than this approach, it's easier now to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I should have said |
||
|
||
post_install_actions: | ||
- | | ||
#ddev-description:If router disabled, directly expose port | ||
# | ||
if ( {{ contains "ddev-router" (list .DdevGlobalConfig.omit_containers | toString) }} ); then | ||
printf "#ddev-generated\nservices:\n mongo-express:\n ports:\n - 9091:8081\n" > docker-compose.mongo_norouter.yaml | ||
fi | ||
- | | ||
echo "You can now use 'ddev mongo-express' to launch Mongo Express UI" | ||
|
||
# list of files and directories listed that are copied into project .ddev directory | ||
project_files: | ||
- commands/mongo/mongosh | ||
- docker-compose.mongo.yaml | ||
- commands/mongo/mongosh | ||
- commands/host/mongo-express | ||
- docker-compose.mongo.yaml | ||
- docker-compose.mongo_norouter.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.