https://github.com/supertokens/supertokens-docker-mongodb
Docker image for SuperTokens Community and MongoDB
https://github.com/supertokens/supertokens-docker-mongodb
Last synced: 3 months ago
JSON representation
Docker image for SuperTokens Community and MongoDB
- Host: GitHub
- URL: https://github.com/supertokens/supertokens-docker-mongodb
- Owner: supertokens
- Created: 2020-04-08T09:03:27.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-03T07:53:14.000Z (3 months ago)
- Last Synced: 2025-04-03T08:33:41.657Z (3 months ago)
- Language: Shell
- Size: 64.5 KB
- Stars: 10
- Watchers: 8
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Quickstart
```bash
# This will start with an in memory database.$ docker run -p 3567:3567 -d registry.supertokens.io/supertokens/supertokens-mongodb
```## Configuration
You can use your own `config.yaml` file as a shared volume or pass the key-values as environment variables.If you do both, only the shared `config.yaml` file will be considered.
#### Using environment variable
Available environment variables
- **Core**
- API\_KEYS
- SUPERTOKENS\_HOST
- SUPERTOKENS\_PORT
- ACCESS\_TOKEN\_VALIDITY
- ACCESS\_TOKEN\_BLACKLISTING
- ACCESS\_TOKEN\_SIGNING\_KEY\_DYNAMIC
- ACCESS\_TOKEN\_DYNAMIC\_SIGNING\_KEY\_UPDATE\_INTERVAL
- REFRESH\_TOKEN\_VALIDITY
- INFO\_LOG\_PATH
- ERROR\_LOG\_PATH
- MAX\_SERVER\_POOL\_SIZE
- DISABLE\_TELEMETRY
- BASE\_PATH
- LOG\_LEVEL
- IP\_ALLOW\_REGEX
- IP\_DENY\_REGEX
- **MongoDB:**
- MONGODB\_CONNECTION\_URI
- MONGODB\_DATABASE\_NAME
- MONGODB\_COLLECTION\_NAMES\_PREFIX
```bash
docker run \
-p 3567:3567 \
-e MONGODB_CONNECTION_URI="mongodb://root:[email protected]:27017" \
-d registry.supertokens.io/supertokens/supertokens-mongodb
```#### Using custom config file
- In your `config.yaml` file, please make sure you store the following key / values:
- `core_config_version: 0`
- `host: "0.0.0.0"`
- `mongodb_config_version: 0`
- `info_log_path: null` (to log in docker logs)
- `error_log_path: null` (to log in docker logs)
- The path for the `config.yaml` file in the container is `/usr/lib/supertokens/config.yaml````bash
docker run \
-p 3567:3567 \
-v /path/to/config.yaml:/usr/lib/supertokens/config.yaml \
-d registry.supertokens.io/supertokens/supertokens-mongodb
```## Logging
- By default, all the logs will be available via the `docker logs ` command.
- You can setup logging to a shared volume by:
- Setting the `info_log_path` and `error_log_path` variables in your `config.yaml` file (or passing the values asn env variables).
- Mounting the shared volume for the logging directory.```bash
docker run \
-p 3567:3567 \
-v /path/to/logsFolder:/home/logsFolder \
-e INFO_LOG_PATH=/home/logsFolder/info.log \
-e ERROR_LOG_PATH=/home/logsFolder/error.log \
-e MONGODB_CONNECTION_URI="mongodb://root:root@localhost:27017" \
-d registry.supertokens.io/supertokens/supertokens-mongodb
```## Database setup
- You do not need to ensure that the MongoDB database has started before this container is started. During bootup, SuperTokens will wait for ~1 hour for a MongoDB instance to be available.
- If ```MONGODB_CONNECTION_URI``` is not provided, then SuperTokens will use an in memory database.## Read-only root fs
- If you wish to run this container with a read-only root filesystem, you can do so.
- The container still needs a temp area, where it can write its stuff, and also needs to be able to execute from there.
- You will have to create a mount for `/lib/supertokens/temp/````bash
docker run \
-p 3567:3567 \
--mount source=/path/on/host/machine,destination=/lib/supertokens/temp/,type=bind \
--read-only \
-d registry.supertokens.io/supertokens/supertokens-mongodb
``````bash
docker run \
-p 3567:3567 \
--tmpfs=/lib/supertokens/temp/:exec \
--read-only \
-d registry.supertokens.io/supertokens/supertokens-mongodb
```