mirror of
https://github.com/bitnami/containers.git
synced 2026-03-14 06:48:11 +08:00
configure mongodb as a s6 service
This commit is contained in:
@@ -17,4 +17,3 @@ COPY rootfs/ /
|
||||
EXPOSE 27017
|
||||
VOLUME ["$BITNAMI_APP_VOL_PREFIX/data", "$BITNAMI_APP_VOL_PREFIX/conf", "$BITNAMI_APP_VOL_PREFIX/logs"]
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["mongod"]
|
||||
|
||||
@@ -1,42 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
source $BITNAMI_PREFIX/bitnami-utils.sh
|
||||
|
||||
print_welcome_page
|
||||
|
||||
# We allow the user to pass extra options
|
||||
if [ "${1:0:1}" = '-' ]; then
|
||||
EXTRA_OPTIONS="$@"
|
||||
set -- mongod
|
||||
export EXTRA_OPTIONS="$@"
|
||||
set --
|
||||
elif [ "${1}" == "mongod" -o "${1}" == "$(which mongod)" ]; then
|
||||
export EXTRA_OPTIONS="${@:2}"
|
||||
set --
|
||||
fi
|
||||
|
||||
if [ ! "$(ls -A $BITNAMI_APP_VOL_PREFIX/conf)" ]; then
|
||||
generate_conf_files
|
||||
fi
|
||||
|
||||
# The user can run its own version or mongod and we still
|
||||
# will want to log it and run it using the BITNAMI_APP_USER
|
||||
if [[ "$1" = 'mongod' ]]; then
|
||||
if [ ! -f $BITNAMI_APP_VOL_PREFIX/data/storage.bson ]; then
|
||||
create_mongodb_user
|
||||
print_app_credentials $BITNAMI_APP_NAME `print_mongo_user` `print_mongo_password` `print_mongo_database`
|
||||
else
|
||||
print_container_already_initialized $BITNAMI_APP_NAME
|
||||
fi
|
||||
|
||||
rm -rf $BITNAMI_APP_VOL_PREFIX/data/mongod.lock
|
||||
chown -R $BITNAMI_APP_USER:$BITNAMI_APP_USER $BITNAMI_APP_VOL_PREFIX/data/ \
|
||||
$BITNAMI_APP_VOL_PREFIX/logs/ \
|
||||
$BITNAMI_APP_VOL_PREFIX/conf/ || true
|
||||
|
||||
wait_and_tail_logs &
|
||||
|
||||
# Add default configuration
|
||||
if [[ "$@" = 'mongod' ]]; then
|
||||
exec gosu $BITNAMI_APP_USER "$@" $PROGRAM_OPTIONS ${MONGODB_PASSWORD:+--auth} $EXTRA_OPTIONS
|
||||
else
|
||||
exec gosu $BITNAMI_APP_USER "$@"
|
||||
fi
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
||||
exec /init "$@"
|
||||
|
||||
20
bitnami/mongodb/rootfs/etc/cont-init.d/01-bitnami-mongodb
Executable file
20
bitnami/mongodb/rootfs/etc/cont-init.d/01-bitnami-mongodb
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
set -e
|
||||
source $BITNAMI_PREFIX/bitnami-utils.sh
|
||||
|
||||
print_welcome_page
|
||||
|
||||
if [ ! "$(ls -A $BITNAMI_APP_VOL_PREFIX/conf)" ]; then
|
||||
generate_conf_files
|
||||
fi
|
||||
|
||||
if [ ! -f $BITNAMI_APP_VOL_PREFIX/data/storage.bson ]; then
|
||||
create_mongodb_user
|
||||
print_app_credentials $BITNAMI_APP_NAME `print_mongo_user` `print_mongo_password` `print_mongo_database`
|
||||
else
|
||||
print_container_already_initialized $BITNAMI_APP_NAME
|
||||
fi
|
||||
|
||||
chown -R $BITNAMI_APP_USER:$BITNAMI_APP_USER $BITNAMI_APP_VOL_PREFIX/data/ \
|
||||
$BITNAMI_APP_VOL_PREFIX/logs/ \
|
||||
$BITNAMI_APP_VOL_PREFIX/conf/ || true
|
||||
1
bitnami/mongodb/rootfs/etc/services.d/mongodb-logs/finish
Symbolic link
1
bitnami/mongodb/rootfs/etc/services.d/mongodb-logs/finish
Symbolic link
@@ -0,0 +1 @@
|
||||
/bin/true
|
||||
5
bitnami/mongodb/rootfs/etc/services.d/mongodb-logs/run
Executable file
5
bitnami/mongodb/rootfs/etc/services.d/mongodb-logs/run
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
set -e
|
||||
source $BITNAMI_PREFIX/bitnami-utils.sh
|
||||
|
||||
exec s6-setuidgid $BITNAMI_APP_USER tail -f -n 1000 $BITNAMI_APP_VOL_PREFIX/logs/*.log 2>/dev/null
|
||||
1
bitnami/mongodb/rootfs/etc/services.d/mongodb/finish
Symbolic link
1
bitnami/mongodb/rootfs/etc/services.d/mongodb/finish
Symbolic link
@@ -0,0 +1 @@
|
||||
/bin/true
|
||||
6
bitnami/mongodb/rootfs/etc/services.d/mongodb/run
Executable file
6
bitnami/mongodb/rootfs/etc/services.d/mongodb/run
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
set -e
|
||||
source $BITNAMI_PREFIX/bitnami-utils.sh
|
||||
|
||||
rm -rf $BITNAMI_APP_VOL_PREFIX/data/mongod.lock
|
||||
exec s6-setuidgid $BITNAMI_APP_USER mongod $PROGRAM_OPTIONS ${MONGODB_PASSWORD:+--auth} ${EXTRA_OPTIONS:+"$EXTRA_OPTIONS"}
|
||||
Reference in New Issue
Block a user