├── .gitattributes ├── .gitignore ├── 1.0 ├── 18-alpine3.18 │ ├── Dockerfile │ └── docker-entrypoint.sh ├── 18-alpine3.19 │ ├── Dockerfile │ └── docker-entrypoint.sh ├── 20-alpine3.18 │ ├── Dockerfile │ └── docker-entrypoint.sh └── 20-alpine3.19 │ ├── Dockerfile │ └── docker-entrypoint.sh ├── CONTRIBUTING.md ├── Dockerfile.template ├── LICENSE.md ├── README.md ├── apply-templates.sh ├── docker-compose.yml ├── docker-entrypoint.sh ├── generate-stackbrew-library.sh ├── logo.png ├── pull-request.md ├── update.sh ├── versions.json └── versions.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | /*/**/Dockerfile linguist-generated 2 | /*/**/docker-entrypoint.sh linguist-generated 3 | /Dockerfile.template linguist-language=Dockerfile 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .jq-template.awk -------------------------------------------------------------------------------- /1.0/18-alpine3.18/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | # https://nodejs.org/en/about/releases/ 8 | # https://github.com/nodejs/Release#readme 9 | FROM node:18-alpine3.18 10 | 11 | RUN set -eux; \ 12 | apk add --no-cache \ 13 | bash \ 14 | # grab tini for signal processing and zombie killing 15 | tini 16 | 17 | WORKDIR /app 18 | 19 | ARG MONGO_EXPRESS_REPOSITORY=mongo-express/mongo-express 20 | ARG MONGO_EXPRESS_VERSION=release/v1.0.2 21 | 22 | RUN set -eux; \ 23 | apk add --no-cache --virtual .me-fetch-deps git; \ 24 | git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/$MONGO_EXPRESS_REPOSITORY.git .; \ 25 | export DISABLE_V8_COMPILE_CACHE=1; \ 26 | yarn install; \ 27 | yarn build; \ 28 | yarn remove --all; \ 29 | yarn workspaces focus --production; \ 30 | yarn cache clean; \ 31 | apk del --no-network .me-fetch-deps; \ 32 | rm -rf .git* ~/.cache ~/.yarn 33 | 34 | # override some config defaults with values that will work better for docker 35 | ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \ 36 | ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \ 37 | ME_CONFIG_SITE_SESSIONSECRET="secret" \ 38 | ME_CONFIG_BASICAUTH=true \ 39 | VCAP_APP_HOST="0.0.0.0" 40 | 41 | EXPOSE 8081 42 | COPY docker-entrypoint.sh / 43 | ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"] 44 | CMD ["mongo-express"] 45 | -------------------------------------------------------------------------------- /1.0/18-alpine3.18/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is auto-generated. Do not edit directly! 3 | set -eo pipefail 4 | 5 | # if command does not start with mongo-express, run the command instead of the entrypoint 6 | if [ "${1}" != "mongo-express" ]; then 7 | exec "$@" 8 | fi 9 | 10 | function wait_tcp_port { 11 | local host="$1" port="$2" 12 | local max_tries="$3" tries=1 13 | 14 | # see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax. 15 | while ! exec 6<>/dev/tcp/$host/$port && [[ $tries -lt $max_tries ]]; do 16 | sleep 1s 17 | tries=$(( tries + 1 )) 18 | echo "$(date) retrying to connect to $host:$port ($tries/$max_tries)" 19 | done 20 | exec 6>&- 21 | } 22 | 23 | # if ME_CONFIG_MONGODB_URL has a comma in it, we're pointing to a replica set (https://github.com/mongo-express/mongo-express-docker/issues/21) 24 | if [[ "$ME_CONFIG_MONGODB_URL" != *,* ]]; then 25 | work=$ME_CONFIG_MONGODB_URL 26 | # Remove the scheme (should be "mongodb://" or "mongodb+srv://"). 27 | work=${work#*://} 28 | # Remove the path component of the URL (should just be a "/"). 29 | work=${work%%/*} 30 | # Remove the userinfo. 31 | work=${work#*@} 32 | if [[ "$work" = *:* ]]; then 33 | # Match the host. 34 | host=${work%:*} 35 | # Match the port. 36 | port=${work#*:} 37 | else 38 | host=$work 39 | port=27017 40 | fi 41 | 42 | # wait for the mongo server to be available 43 | echo "Waiting for $host:$port..." 44 | wait_tcp_port "$host" "$port" "${ME_CONFIG_CONNECT_RETRIES:-10}" 45 | fi 46 | 47 | # run mongo-express 48 | exec node app 49 | -------------------------------------------------------------------------------- /1.0/18-alpine3.19/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | # https://nodejs.org/en/about/releases/ 8 | # https://github.com/nodejs/Release#readme 9 | FROM node:18-alpine3.19 10 | 11 | RUN set -eux; \ 12 | apk add --no-cache \ 13 | bash \ 14 | # grab tini for signal processing and zombie killing 15 | tini 16 | 17 | WORKDIR /app 18 | 19 | ARG MONGO_EXPRESS_REPOSITORY=mongo-express/mongo-express 20 | ARG MONGO_EXPRESS_VERSION=release/v1.0.2 21 | 22 | RUN set -eux; \ 23 | apk add --no-cache --virtual .me-fetch-deps git; \ 24 | git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/$MONGO_EXPRESS_REPOSITORY.git .; \ 25 | export DISABLE_V8_COMPILE_CACHE=1; \ 26 | yarn install; \ 27 | yarn build; \ 28 | yarn remove --all; \ 29 | yarn workspaces focus --production; \ 30 | yarn cache clean; \ 31 | apk del --no-network .me-fetch-deps; \ 32 | rm -rf .git* ~/.cache ~/.yarn 33 | 34 | # override some config defaults with values that will work better for docker 35 | ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \ 36 | ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \ 37 | ME_CONFIG_SITE_SESSIONSECRET="secret" \ 38 | ME_CONFIG_BASICAUTH=true \ 39 | VCAP_APP_HOST="0.0.0.0" 40 | 41 | EXPOSE 8081 42 | COPY docker-entrypoint.sh / 43 | ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"] 44 | CMD ["mongo-express"] 45 | -------------------------------------------------------------------------------- /1.0/18-alpine3.19/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is auto-generated. Do not edit directly! 3 | set -eo pipefail 4 | 5 | # if command does not start with mongo-express, run the command instead of the entrypoint 6 | if [ "${1}" != "mongo-express" ]; then 7 | exec "$@" 8 | fi 9 | 10 | function wait_tcp_port { 11 | local host="$1" port="$2" 12 | local max_tries="$3" tries=1 13 | 14 | # see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax. 15 | while ! exec 6<>/dev/tcp/$host/$port && [[ $tries -lt $max_tries ]]; do 16 | sleep 1s 17 | tries=$(( tries + 1 )) 18 | echo "$(date) retrying to connect to $host:$port ($tries/$max_tries)" 19 | done 20 | exec 6>&- 21 | } 22 | 23 | # if ME_CONFIG_MONGODB_URL has a comma in it, we're pointing to a replica set (https://github.com/mongo-express/mongo-express-docker/issues/21) 24 | if [[ "$ME_CONFIG_MONGODB_URL" != *,* ]]; then 25 | work=$ME_CONFIG_MONGODB_URL 26 | # Remove the scheme (should be "mongodb://" or "mongodb+srv://"). 27 | work=${work#*://} 28 | # Remove the path component of the URL (should just be a "/"). 29 | work=${work%%/*} 30 | # Remove the userinfo. 31 | work=${work#*@} 32 | if [[ "$work" = *:* ]]; then 33 | # Match the host. 34 | host=${work%:*} 35 | # Match the port. 36 | port=${work#*:} 37 | else 38 | host=$work 39 | port=27017 40 | fi 41 | 42 | # wait for the mongo server to be available 43 | echo "Waiting for $host:$port..." 44 | wait_tcp_port "$host" "$port" "${ME_CONFIG_CONNECT_RETRIES:-10}" 45 | fi 46 | 47 | # run mongo-express 48 | exec node app 49 | -------------------------------------------------------------------------------- /1.0/20-alpine3.18/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | # https://nodejs.org/en/about/releases/ 8 | # https://github.com/nodejs/Release#readme 9 | FROM node:20-alpine3.18 10 | 11 | RUN set -eux; \ 12 | apk add --no-cache \ 13 | bash \ 14 | # grab tini for signal processing and zombie killing 15 | tini 16 | 17 | WORKDIR /app 18 | 19 | ARG MONGO_EXPRESS_REPOSITORY=mongo-express/mongo-express 20 | ARG MONGO_EXPRESS_VERSION=release/v1.0.2 21 | 22 | RUN set -eux; \ 23 | apk add --no-cache --virtual .me-fetch-deps git; \ 24 | git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/$MONGO_EXPRESS_REPOSITORY.git .; \ 25 | export DISABLE_V8_COMPILE_CACHE=1; \ 26 | yarn install; \ 27 | yarn build; \ 28 | yarn remove --all; \ 29 | yarn workspaces focus --production; \ 30 | yarn cache clean; \ 31 | apk del --no-network .me-fetch-deps; \ 32 | rm -rf .git* ~/.cache ~/.yarn 33 | 34 | # override some config defaults with values that will work better for docker 35 | ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \ 36 | ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \ 37 | ME_CONFIG_SITE_SESSIONSECRET="secret" \ 38 | ME_CONFIG_BASICAUTH=true \ 39 | VCAP_APP_HOST="0.0.0.0" 40 | 41 | EXPOSE 8081 42 | COPY docker-entrypoint.sh / 43 | ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"] 44 | CMD ["mongo-express"] 45 | -------------------------------------------------------------------------------- /1.0/20-alpine3.18/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is auto-generated. Do not edit directly! 3 | set -eo pipefail 4 | 5 | # if command does not start with mongo-express, run the command instead of the entrypoint 6 | if [ "${1}" != "mongo-express" ]; then 7 | exec "$@" 8 | fi 9 | 10 | function wait_tcp_port { 11 | local host="$1" port="$2" 12 | local max_tries="$3" tries=1 13 | 14 | # see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax. 15 | while ! exec 6<>/dev/tcp/$host/$port && [[ $tries -lt $max_tries ]]; do 16 | sleep 1s 17 | tries=$(( tries + 1 )) 18 | echo "$(date) retrying to connect to $host:$port ($tries/$max_tries)" 19 | done 20 | exec 6>&- 21 | } 22 | 23 | # if ME_CONFIG_MONGODB_URL has a comma in it, we're pointing to a replica set (https://github.com/mongo-express/mongo-express-docker/issues/21) 24 | if [[ "$ME_CONFIG_MONGODB_URL" != *,* ]]; then 25 | work=$ME_CONFIG_MONGODB_URL 26 | # Remove the scheme (should be "mongodb://" or "mongodb+srv://"). 27 | work=${work#*://} 28 | # Remove the path component of the URL (should just be a "/"). 29 | work=${work%%/*} 30 | # Remove the userinfo. 31 | work=${work#*@} 32 | if [[ "$work" = *:* ]]; then 33 | # Match the host. 34 | host=${work%:*} 35 | # Match the port. 36 | port=${work#*:} 37 | else 38 | host=$work 39 | port=27017 40 | fi 41 | 42 | # wait for the mongo server to be available 43 | echo "Waiting for $host:$port..." 44 | wait_tcp_port "$host" "$port" "${ME_CONFIG_CONNECT_RETRIES:-10}" 45 | fi 46 | 47 | # run mongo-express 48 | exec node app 49 | -------------------------------------------------------------------------------- /1.0/20-alpine3.19/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | # https://nodejs.org/en/about/releases/ 8 | # https://github.com/nodejs/Release#readme 9 | FROM node:20-alpine3.19 10 | 11 | RUN set -eux; \ 12 | apk add --no-cache \ 13 | bash \ 14 | # grab tini for signal processing and zombie killing 15 | tini 16 | 17 | WORKDIR /app 18 | 19 | ARG MONGO_EXPRESS_REPOSITORY=mongo-express/mongo-express 20 | ARG MONGO_EXPRESS_VERSION=release/v1.0.2 21 | 22 | RUN set -eux; \ 23 | apk add --no-cache --virtual .me-fetch-deps git; \ 24 | git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/$MONGO_EXPRESS_REPOSITORY.git .; \ 25 | export DISABLE_V8_COMPILE_CACHE=1; \ 26 | yarn install; \ 27 | yarn build; \ 28 | yarn remove --all; \ 29 | yarn workspaces focus --production; \ 30 | yarn cache clean; \ 31 | apk del --no-network .me-fetch-deps; \ 32 | rm -rf .git* ~/.cache ~/.yarn 33 | 34 | # override some config defaults with values that will work better for docker 35 | ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \ 36 | ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \ 37 | ME_CONFIG_SITE_SESSIONSECRET="secret" \ 38 | ME_CONFIG_BASICAUTH=true \ 39 | VCAP_APP_HOST="0.0.0.0" 40 | 41 | EXPOSE 8081 42 | COPY docker-entrypoint.sh / 43 | ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"] 44 | CMD ["mongo-express"] 45 | -------------------------------------------------------------------------------- /1.0/20-alpine3.19/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is auto-generated. Do not edit directly! 3 | set -eo pipefail 4 | 5 | # if command does not start with mongo-express, run the command instead of the entrypoint 6 | if [ "${1}" != "mongo-express" ]; then 7 | exec "$@" 8 | fi 9 | 10 | function wait_tcp_port { 11 | local host="$1" port="$2" 12 | local max_tries="$3" tries=1 13 | 14 | # see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax. 15 | while ! exec 6<>/dev/tcp/$host/$port && [[ $tries -lt $max_tries ]]; do 16 | sleep 1s 17 | tries=$(( tries + 1 )) 18 | echo "$(date) retrying to connect to $host:$port ($tries/$max_tries)" 19 | done 20 | exec 6>&- 21 | } 22 | 23 | # if ME_CONFIG_MONGODB_URL has a comma in it, we're pointing to a replica set (https://github.com/mongo-express/mongo-express-docker/issues/21) 24 | if [[ "$ME_CONFIG_MONGODB_URL" != *,* ]]; then 25 | work=$ME_CONFIG_MONGODB_URL 26 | # Remove the scheme (should be "mongodb://" or "mongodb+srv://"). 27 | work=${work#*://} 28 | # Remove the path component of the URL (should just be a "/"). 29 | work=${work%%/*} 30 | # Remove the userinfo. 31 | work=${work#*@} 32 | if [[ "$work" = *:* ]]; then 33 | # Match the host. 34 | host=${work%:*} 35 | # Match the port. 36 | port=${work#*:} 37 | else 38 | host=$work 39 | port=27017 40 | fi 41 | 42 | # wait for the mongo server to be available 43 | echo "Waiting for $host:$port..." 44 | wait_tcp_port "$host" "$port" "${ME_CONFIG_CONNECT_RETRIES:-10}" 45 | fi 46 | 47 | # run mongo-express 48 | exec node app 49 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to mongo-express-docker 2 | 3 | Thank you for your contribution. Here are a set of guidelines for contributing to the dmongo-express docker project. 4 | 5 | ## Version Updates 6 | 7 | The folders represent the list of supported major, minor and prerelease version (e.g. `1.0`, `2.1` or `1.1.0-alpha`). To update these versions, run `./update.sh`. You can also run the script with a specific version e.g. `update 1.0`. 8 | 9 | ### Submitting a PR for a version update 10 | 11 | If you'd like to help us by submitting a PR for a version update, please do the following: 12 | 13 | 1. [Fork this project.](https://docs.github.com/en/get-started/quickstart/fork-a-repo) 14 | 1. [Clone the forked repository.](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) 15 | 1. Create a branch for the update PR. For example, `git checkout main; git checkout -b version-update`. 16 | 1. Run `./update.sh`. 17 | 1. Commit the modified files to the `version-update` branch and push the branch to your fork. 18 | 1. [Create a PR to merge the branch from your fork into this project's default branch.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork). -------------------------------------------------------------------------------- /Dockerfile.template: -------------------------------------------------------------------------------- 1 | # https://nodejs.org/en/about/releases/ 2 | # https://github.com/nodejs/Release#readme 3 | FROM node:{{ env.variant }} 4 | 5 | RUN set -eux; \ 6 | apk add --no-cache \ 7 | bash \ 8 | # grab tini for signal processing and zombie killing 9 | tini 10 | 11 | WORKDIR /app 12 | 13 | ARG MONGO_EXPRESS_REPOSITORY=mongo-express/mongo-express 14 | ARG MONGO_EXPRESS_VERSION=release/v{{ .version }} 15 | 16 | RUN set -eux; \ 17 | apk add --no-cache --virtual .me-fetch-deps git; \ 18 | git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/$MONGO_EXPRESS_REPOSITORY.git .; \ 19 | export DISABLE_V8_COMPILE_CACHE=1; \ 20 | yarn install; \ 21 | yarn build; \ 22 | yarn remove --all; \ 23 | yarn workspaces focus --production; \ 24 | yarn cache clean; \ 25 | apk del --no-network .me-fetch-deps; \ 26 | rm -rf .git* ~/.cache ~/.yarn 27 | 28 | # override some config defaults with values that will work better for docker 29 | ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \ 30 | ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \ 31 | ME_CONFIG_SITE_SESSIONSECRET="secret" \ 32 | ME_CONFIG_BASICAUTH=true \ 33 | VCAP_APP_HOST="0.0.0.0" 34 | 35 | EXPOSE 8081 36 | COPY docker-entrypoint.sh / 37 | ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"] 38 | CMD ["mongo-express"] 39 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Nick Cox 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # What is mongo-express? 2 | 3 | mongo-express is a web-based MongoDB admin interface written in Node.js, Express.js, and Bootstrap3. 4 | 5 | > [github.com/mongo-express/mongo-express](https://github.com/mongo-express/mongo-express) 6 | 7 | ![logo](https://raw.githubusercontent.com/mongo-express/mongo-express-docker/master/logo.png) 8 | 9 | # How to use this image 10 | 11 | [![Try in PWD](https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png)](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/mongo-express/mongo-express-docker/master/docker-compose.yml) 12 | 13 | ```console 14 | $ docker run --link some_mongo_container:mongo -p 8081:8081 -e ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" mongo-express 15 | ``` 16 | 17 | Then you can hit `http://localhost:8081` or `http://host-ip:8081` in your browser. 18 | 19 | Some alternatives for the `ME_CONFIG_MONGODB_URL` environment variable: 20 | - `mongodb://host.docker.internal:27017` 21 | - `mongodb://host.containers.internal:27017` 22 | 23 | ## Security Notice 24 | 25 | JSON documents are parsed through a javascript virtual machine, so the web interface can be used to execute malicious javascript on a server. 26 | 27 | **mongo-express should only be used privately for development purposes.** 28 | 29 | # Build 30 | Build the mongo-express image using `Dockerfile` and `docker-entrypoint.sh` files. 31 | 32 | In below commands go to the folder (e.g. `cd 1.0/20-alpine3.18`) or replace final `.` with folder path (e.g. `1.0/20-alpine3.18`). 33 | 34 | #### Build the mongo-express image: 35 | ```console 36 | docker build --tag mongo-express . 37 | ``` 38 | 39 | #### Build with a specific version of mongo-express: 40 | ```console 41 | docker build --build-arg MONGO_EXPRESS_VERSION=release/v1.0.2 --tag mongo-express . 42 | ``` 43 | 44 | #### Build with a specific (forked) repository of mongo-express: 45 | ```console 46 | docker build --build-arg MONGO_EXPRESS_REPOSITORY=OtherUser/mongo_express --tag mongo-express . 47 | ``` 48 | 49 | # Configuration 50 | 51 | Environment variables are passed to the `run` command for configuring a mongo-express container. 52 | 53 | Name | Default | Description 54 | | - | - | - 55 | `ME_CONFIG_MONGODB_URL` | `mongodb://mongo:27017` | MongoDB connection string 56 | `ME_CONFIG_BASICAUTH_USERNAME` | | mongo-express web username 57 | `ME_CONFIG_BASICAUTH_PASSWORD` | | mongo-express web password 58 | `ME_CONFIG_CONNECT_RETRIES` | `10` | Number of startup connection retry attempts to be made 59 | `ME_CONFIG_MONGODB_ENABLE_ADMIN` | `true` | Enable admin access to all databases. Send strings: `"true"` or `"false"` 60 | `ME_CONFIG_OPTIONS_EDITORTHEME` | `default` | mongo-express editor color theme, [more here](http://codemirror.net/demo/theme.html) 61 | `ME_CONFIG_REQUEST_SIZE` | `100kb` | Maximum payload size. CRUD operations above this size will fail in [body-parser](https://www.npmjs.com/package/body-parser). 62 | `ME_CONFIG_SITE_BASEURL` | `/` | Set the baseUrl to ease mounting at a subdirectory. Remember to include a leading and trailing slash. 63 | `ME_CONFIG_SITE_COOKIESECRET` | `cookiesecret` | String used by [cookie-parser middleware](https://www.npmjs.com/package/cookie-parser) to sign cookies. 64 | `ME_CONFIG_SITE_SESSIONSECRET` | `sessionsecret` | String used to sign the session ID cookie by [express-session middleware](https://www.npmjs.com/package/express-session). 65 | `ME_CONFIG_SITE_SSL_ENABLED` | `false` | Enable SSL. 66 | `ME_CONFIG_SITE_SSL_CRT_PATH` | | SSL certificate file. 67 | `ME_CONFIG_SITE_SSL_KEY_PATH` | | SSL key file. 68 | 69 | 70 | The following are only needed if `ME_CONFIG_MONGODB_ENABLE_ADMIN` is **"false"** 71 | 72 | Name | Default | Description 73 | | - | - | - 74 | `ME_CONFIG_MONGODB_AUTH_DATABASE` | `db` | Database name 75 | `ME_CONFIG_MONGODB_AUTH_USERNAME` | `admin` | Database username 76 | `ME_CONFIG_MONGODB_AUTH_PASSWORD` | `pass` | Database password 77 | 78 | ## Example 79 | 80 | docker run -it --rm \ 81 | --name mongo-express \ 82 | --link web_db_1:mongo \ 83 | -p 8081:8081 \ 84 | -e ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \ 85 | -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" \ 86 | -e ME_CONFIG_BASICAUTH_USERNAME="user" \ 87 | -e ME_CONFIG_BASICAUTH_PASSWORD="fairly long password" \ 88 | mongo-express 89 | 90 | This example links to a container name typical of `docker-compose`, changes the editor's color theme, and enables basic authentication. -------------------------------------------------------------------------------- /apply-templates.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | [ -f versions.json ] # run "versions.sh" first 5 | 6 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 7 | 8 | jqt='.jq-template.awk' 9 | if [ -n "${BASHBREW_SCRIPTS:-}" ]; then 10 | jqt="$BASHBREW_SCRIPTS/jq-template.awk" 11 | elif [ "$BASH_SOURCE" -nt "$jqt" ]; then 12 | # https://github.com/docker-library/bashbrew/blob/master/scripts/jq-template.awk 13 | wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk' 14 | fi 15 | 16 | if [ "$#" -eq 0 ]; then 17 | versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" 18 | eval "set -- $versions" 19 | fi 20 | 21 | generated_warning() { 22 | cat <<-EOH 23 | # 24 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 25 | # 26 | # PLEASE DO NOT EDIT IT DIRECTLY. 27 | # 28 | 29 | EOH 30 | } 31 | 32 | for version; do 33 | export version 34 | 35 | major="$(jq -r '.[env.version].major' versions.json)" 36 | 37 | variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)" 38 | eval "variants=( $variants )" 39 | 40 | rm -rf "$version" 41 | 42 | for variant in "${variants[@]}"; do 43 | export variant 44 | 45 | dir="$version/$variant" 46 | mkdir -p "$dir" 47 | 48 | echo "processing $dir ..." 49 | 50 | cp -a docker-entrypoint.sh "$dir/" 51 | sed -i "2s|^|# This file is auto-generated. Do not edit directly!\n|" "$dir/docker-entrypoint.sh" 52 | 53 | template='Dockerfile.template' 54 | 55 | { 56 | generated_warning 57 | gawk -f "$jqt" "$template" 58 | } > "$dir/Dockerfile" 59 | done 60 | done 61 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | 3 | services: 4 | mongo: 5 | image: mongo:4 6 | restart: always 7 | 8 | mongoexpress: 9 | image: mongo-express 10 | ports: 11 | - "8081:8081" 12 | environment: 13 | - ME_CONFIG_MONGODB_URL=mongodb://mongo:27017 14 | depends_on: 15 | - mongo 16 | restart: always -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eo pipefail 3 | 4 | # if command does not start with mongo-express, run the command instead of the entrypoint 5 | if [ "${1}" != "mongo-express" ]; then 6 | exec "$@" 7 | fi 8 | 9 | function wait_tcp_port { 10 | local host="$1" port="$2" 11 | local max_tries="$3" tries=1 12 | 13 | # see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax. 14 | while ! exec 6<>/dev/tcp/$host/$port && [[ $tries -lt $max_tries ]]; do 15 | sleep 1s 16 | tries=$(( tries + 1 )) 17 | echo "$(date) retrying to connect to $host:$port ($tries/$max_tries)" 18 | done 19 | exec 6>&- 20 | } 21 | 22 | # if ME_CONFIG_MONGODB_URL has a comma in it, we're pointing to a replica set (https://github.com/mongo-express/mongo-express-docker/issues/21) 23 | if [[ "$ME_CONFIG_MONGODB_URL" != *,* ]]; then 24 | work=$ME_CONFIG_MONGODB_URL 25 | # Remove the scheme (should be "mongodb://" or "mongodb+srv://"). 26 | work=${work#*://} 27 | # Remove the path component of the URL (should just be a "/"). 28 | work=${work%%/*} 29 | # Remove the userinfo. 30 | work=${work#*@} 31 | if [[ "$work" = *:* ]]; then 32 | # Match the host. 33 | host=${work%:*} 34 | # Match the port. 35 | port=${work#*:} 36 | else 37 | host=$work 38 | port=27017 39 | fi 40 | 41 | # wait for the mongo server to be available 42 | echo "Waiting for $host:$port..." 43 | wait_tcp_port "$host" "$port" "${ME_CONFIG_CONNECT_RETRIES:-10}" 44 | fi 45 | 46 | # run mongo-express 47 | exec node app 48 | -------------------------------------------------------------------------------- /generate-stackbrew-library.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | declare -A aliases=( 5 | [1.0]='1 latest' 6 | ) 7 | 8 | self="$(basename "$BASH_SOURCE")" 9 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 10 | 11 | if [ "$#" -eq 0 ]; then 12 | versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" 13 | eval "set -- $versions" 14 | fi 15 | 16 | # sort version numbers with highest first 17 | IFS=$'\n'; set -- $(sort -rV <<<"$*"); unset IFS 18 | 19 | # get the most recent commit which modified any of "$@" 20 | fileCommit() { 21 | git log -1 --format='format:%H' HEAD -- "$@" 22 | } 23 | 24 | # get the most recent commit which modified "$1/Dockerfile" or any file COPY'd from "$1/Dockerfile" 25 | dirCommit() { 26 | local dir="$1"; shift 27 | ( 28 | cd "$dir" 29 | files="$( 30 | git show HEAD:./Dockerfile | awk ' 31 | toupper($1) == "COPY" { 32 | for (i = 2; i < NF; i++) { 33 | if ($i ~ /^--from=/) { 34 | next 35 | } 36 | print $i 37 | } 38 | } 39 | ' 40 | )" 41 | fileCommit Dockerfile $files 42 | ) 43 | } 44 | 45 | commit="$(git log -1 --format='format:%H')" 46 | cat <<-EOH 47 | # this file is generated via https://github.com/mongo-express/mongo-express-docker/blob/$commit/$self 48 | 49 | Maintainers: Nick Cox (@knickers), 50 | John Steel (@BlackthornYugen) 51 | GitRepo: https://github.com/mongo-express/mongo-express-docker.git 52 | GitCommit: $commit 53 | 54 | EOH 55 | 56 | # prints "$2$1$3$1...$N" 57 | join() { 58 | local sep="$1"; shift 59 | local out; printf -v out "${sep//%/%%}%s" "$@" 60 | echo "${out#"$sep"}" 61 | } 62 | 63 | for version; do 64 | export version 65 | 66 | variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)" 67 | eval "variants=( $variants )" 68 | 69 | defaultAlpine="$(jq -r '.[env.version].alpine' versions.json)" 70 | defaultNode="$(jq -r '.[env.version].node' versions.json)" 71 | 72 | fullVersion="$(jq -r '.[env.version].version' versions.json)" 73 | 74 | # ex: 9.6.22, 13.3, or 14beta2 75 | versionAliases=( 76 | $fullVersion 77 | ) 78 | # skip unadorned "version" on prereleases 79 | # ex: 9.6, 13, or 14 80 | case "$fullVersion" in 81 | *alpha* | *beta* | *rc*) ;; 82 | *) versionAliases+=( $version ) ;; 83 | esac 84 | # ex: 9 or latest 85 | # shellcheck disable=SC2206 86 | versionAliases+=( 87 | ${aliases[$version]:-} 88 | ) 89 | 90 | for variant in "${variants[@]}"; do 91 | versionAliasesCopy=( "${versionAliases[@]}" ) 92 | dir="$version/$variant" 93 | commit="$(dirCommit "$dir")" 94 | 95 | IFS='-' read -ra PARTS <<< "$variant" 96 | node="${PARTS[0]}" 97 | alpine="${PARTS[1]}" 98 | 99 | latest=false 100 | if [ "${versionAliasesCopy[${#versionAliasesCopy[@]}-1]}" = "latest" ]; then 101 | unset "versionAliasesCopy[${#versionAliasesCopy[@]}-1]" 102 | latest=true 103 | fi 104 | 105 | if [ "${node}" = "${defaultNode}" ] && [ "${alpine}" = "alpine${defaultAlpine}" ]; then 106 | variantAliases=( "${versionAliasesCopy[@]}" "${versionAliasesCopy[@]/%/-$defaultNode}" "${versionAliasesCopy[@]/%/-$variant}" ) 107 | if [ "${latest}" ]; then 108 | variantAliases+=( 'latest' ) 109 | fi 110 | else 111 | if [ "${alpine}" = "alpine${defaultAlpine}" ]; then 112 | variantAliases=( "${versionAliasesCopy[@]/%/-$node}" "${versionAliasesCopy[@]/%/-$variant}" ) 113 | else 114 | variantAliases=( "${versionAliasesCopy[@]/%/-$variant}" ) 115 | fi 116 | fi 117 | 118 | cat <<-EOE 119 | 120 | Tags: $(join ', ' "${variantAliases[@]}") 121 | Architectures: amd64, arm64v8 122 | GitCommit: $commit 123 | Directory: $dir 124 | 125 | EOE 126 | done 127 | done 128 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongo-express/mongo-express-docker/075234363b3c008c7c2e97de8a3639e23a75cfcd/logo.png -------------------------------------------------------------------------------- /pull-request.md: -------------------------------------------------------------------------------- 1 | # How to make multiple pull requests to a forked repository. 2 | 3 | ## One-time preparation 4 | 5 | From inside the forked repository, add a new `remote` pointing to the upstream repo: 6 | 7 | ```shell 8 | $ git remote add upstream git://github.com/upstream/repo.git 9 | ``` 10 | 11 | Then change the master branch to track `upstream/master`. 12 | 13 | ```shell 14 | $ git checkout -b anything 15 | $ git branch -D master 16 | $ git checkout --track upstream/master 17 | $ git branch -D anything 18 | ``` 19 | 20 | ## Make a pull request 21 | 22 | ```shell 23 | $ git pull 24 | $ git checkout -b new-changes 25 | $ # make bump changes 26 | $ git commit 27 | $ git push --set-upstream origin new-changes 28 | $ # make PR from browser 29 | $ # wait for PR to be merged 30 | $ git checkout master 31 | $ git branch -D new-changes 32 | ``` 33 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 5 | 6 | ./versions.sh "$@" 7 | ./apply-templates.sh "$@" 8 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.0": { 3 | "alpine": "3.18", 4 | "node": "18", 5 | "variants": [ 6 | "20-alpine3.19", 7 | "20-alpine3.18", 8 | "18-alpine3.19", 9 | "18-alpine3.18" 10 | ], 11 | "version": "1.0.2" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /versions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | supportedNodeVersions=( 5 | 20 6 | 18 7 | ) 8 | supportedAlpineVersions=( 9 | 3.19 10 | 3.18 11 | ) 12 | defaultNodeVersion="${supportedNodeVersions[0]}" 13 | defaultAlpineVersion="${supportedAlpineVersions[0]}" 14 | 15 | versions=( "$@" ) 16 | if [ ${#versions[@]} -eq 0 ]; then 17 | versions=( */ ) 18 | json='{}' 19 | else 20 | json="$(< versions.json)" 21 | fi 22 | versions=( "${versions[@]%/}" ) 23 | 24 | upstreamVersions=$(wget -qO- 'https://registry.npmjs.org/mongo-express' | jq -r '.versions | keys | .[]') 25 | 26 | for version in "${versions[@]}"; do 27 | export version 28 | 29 | versionPattern="^${version/\./\\.}\.[0-9]*$" 30 | filteredVersions=($(printf "%s\n" ${upstreamVersions[*]} | grep -E "${versionPattern}")) 31 | fullVersion="${filteredVersions[${#filteredVersions[@]}-1]}" 32 | 33 | echo "$version: $fullVersion" 34 | 35 | export fullVersion="$fullVersion" 36 | export nodeVersion="${supportedNodeVersions[${#supportedNodeVersions[@]}-1]}" 37 | export alpineVersion="${supportedAlpineVersions[${#supportedAlpineVersions[@]}-1]}" 38 | 39 | for node in "${supportedNodeVersions[@]}"; do 40 | variants+=( "${supportedAlpineVersions[@]/#/$node-alpine}" ) 41 | done 42 | 43 | doc='{}' 44 | for variant in "${variants[@]}"; do 45 | doc="$(jq <<<"$doc" -c --arg v "$variant" ' 46 | .variants += [ $v ] 47 | ')" 48 | done 49 | unset variants 50 | 51 | # TODO: Add way to pin default Node and Alpine for specific versions 52 | json="$(jq <<<"$json" -c --argjson doc "$doc" ' 53 | .[env.version] = ({ 54 | version: env.fullVersion, 55 | node: env.nodeVersion, 56 | alpine: env.alpineVersion, 57 | variants: $doc.variants 58 | }) 59 | ')" 60 | done 61 | 62 | jq <<<"$json" -S . > versions.json 63 | --------------------------------------------------------------------------------