Commit b4518162 authored by Tit Petric's avatar Tit Petric

init mongodb from env variables, ignore db folder for data

parent ba50f486
/db
\ No newline at end of file
FROM mongo:3-stretch
ADD mongo-init.js /docker-entrypoint-initdb.d/
ADD mongo-init.sh /docker-entrypoint-initdb.d/
db = db.getSiblingDB('satosa')
db.createCollection('clients')
db.clients.insertOne(
{
"lookup_key": "405533",
"data": {
"application_type": "web",
"client_name": "didmos2 lui client",
"initiate_login_uri": "https://crust-docker.daasi.de",
"frontchannel_logout_uri": "https://crust-docker.daasi.de",
"redirect_uris": [
"https://crust-docker.daasi.de"
],
"response_types": [
"token id_token"
],
"client_id": "405533"
}
}
)
db.createUser(
{
user: "satosa",
pwd: "RG6gdsfbtRRDuXad",
roles: [
{ role: "readWrite", db: "satosa" }
]
}
)
#!/bin/bash
set -e
# provision mongodb from environment variables
SATOSA_DATABASE=${SATOSA_DATABASE:="satosa"}
SATOSA_USERNAME=${SATOSA_USERNAME:="satosa"}
SATOSA_PASSWORD=${SATOSA_PASSWORD:="satosa"}
SATOSA_FRONTEND=${SATOSA_FRONTEND:="https://crust-docker.daasi.de"}
# echo "DATABASE" $SATOSA_DATABASE
# echo "USERNAME" $SATOSA_USERNAME
# echo "PASSWORD" $SATOSA_PASSWORD
# echo "FRONTEND" $SATOSA_FRONTEND
# exit
mongo <<EOF
db = db.getSiblingDB('${SATOSA_DATABASE}')
db.createCollection('clients')
db.clients.insertOne(
{
'lookup_key': '405533',
'data': {
'application_type': 'web',
'client_name': 'didmos2 lui client',
'initiate_login_uri': '${SATOSA_FRONTEND}',
'frontchannel_logout_uri': '${SATOSA_FRONTEND}',
'redirect_uris': [
'${SATOSA_FRONTEND}'
],
'response_types': [
'token id_token'
],
'client_id': '405533'
}
}
)
db.createUser(
{
user: '${SATOSA_USERNAME}',
pwd: '${SATOSA_PASSWORD}',
roles: [
{ role: 'readWrite', db: '${SATOSA_DATABASE}' }
]
}
)
EOF
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment