summaryrefslogtreecommitdiffstats
path: root/Services/mongo
diff options
context:
space:
mode:
authorstartxfr <clarue@startx.fr>2014-12-06 02:51:42 +0100
committerstartxfr <clarue@startx.fr>2014-12-06 02:51:42 +0100
commita7f649b8f1f56a999073550d1b91b5d8d1cd7d81 (patch)
treec7739a5c22615c3d3ca5bb59821a598e40460f02 /Services/mongo
parent076db03abf9ac12a057b784a3e0999180ca53543 (diff)
downloadphpmyadmin-a7f649b8f1f56a999073550d1b91b5d8d1cd7d81.tar.gz
phpmyadmin-a7f649b8f1f56a999073550d1b91b5d8d1cd7d81.tar.bz2
phpmyadmin-a7f649b8f1f56a999073550d1b91b5d8d1cd7d81.tar.xz
phpmyadmin-a7f649b8f1f56a999073550d1b91b5d8d1cd7d81.zip
adding functionnal mongodb server
Diffstat (limited to 'Services/mongo')
-rw-r--r--Services/mongo/Dockerfile21
-rw-r--r--Services/mongo/README.md4
-rw-r--r--Services/mongo/mongo_run.sh2
-rw-r--r--Services/mongo/mongodb.conf27
-rw-r--r--Services/mongo/sx/mongod.sh48
-rw-r--r--Services/mongo/sx/mongod_run.sh7
6 files changed, 95 insertions, 14 deletions
diff --git a/Services/mongo/Dockerfile b/Services/mongo/Dockerfile
index aee3456..0199e76 100644
--- a/Services/mongo/Dockerfile
+++ b/Services/mongo/Dockerfile
@@ -1,7 +1,6 @@
FROM startx/fedora
MAINTAINER Christophe LARUE <dev@startx.fr>
-COPY mongo_run.sh /bin/
RUN yum -y install \
mongodb \
mongodb-server \
@@ -11,15 +10,15 @@ RUN yum -y install \
mongodb-mms-monitoring-agent \
&& yum clean all \
&& mkdir -p /var/lib/mongodb \
- && touch /var/lib/mongodb/.keep \
- && chown -R mongod:mongod /var/lib/mongodb \
- && chmod ug+rx /bin/mongo_*
-
-VOLUME ["/var/lib/mongodb"]
-USER mongod
-
+ && touch /var/lib/mongodb/.keep
+COPY sx/* /sx/
+COPY mongodb.conf /etc/mongodb.conf
+RUN chmod ug+rx /sx/mongod* \
+ && chown -R mongodb:mongodb /sx/mongod* /var/lib/mongodb /var/log/mongodb
EXPOSE 27017
-#CMD ["/usr/bin/mongod", "--config", "/etc/mongodb.conf"]
-CMD ["/bin/mongo_run.sh"]
-ONBUILD CMD ["/bin/mongo_run.sh"] \ No newline at end of file
+VOLUME ["/var/lib/mongodb", "/var/log/mongodb"]
+
+USER mongodb
+#ENDPOINT ["/sx/mongod_run.sh"]
+CMD ["/sx/mongod_run.sh"] \ No newline at end of file
diff --git a/Services/mongo/README.md b/Services/mongo/README.md
index 5c423e3..aa23252 100644
--- a/Services/mongo/README.md
+++ b/Services/mongo/README.md
@@ -16,6 +16,8 @@ Copy sources in your docker host
cd startx-docker-images;
git clone https://github.com/startxfr/docker-images.git .
+Change configuration and personalize your base image. See sx/mongod_run.sh to perform some usefull task against the database, especially importing sql script, adding users and changing passwords. See also mongodb.conf for configuring the mongo server running in the container.
+
Build the container
docker build -t sv-mongo Services/mongo/
@@ -31,7 +33,7 @@ access to the running database
access to the container itself
- docker exec -it mongo bash
+ docker exec -it mongo /bin/bash
## Related Resources
* [Sources files](https://github.com/startxfr/docker-images/tree/master/Services/mongo)
diff --git a/Services/mongo/mongo_run.sh b/Services/mongo/mongo_run.sh
deleted file mode 100644
index 09eba06..0000000
--- a/Services/mongo/mongo_run.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-/usr/bin/mongod --config /etc/mongodb.conf \ No newline at end of file
diff --git a/Services/mongo/mongodb.conf b/Services/mongo/mongodb.conf
new file mode 100644
index 0000000..89d19f2
--- /dev/null
+++ b/Services/mongo/mongodb.conf
@@ -0,0 +1,27 @@
+##
+### Config file copied into
+##
+bind_ip = 127.0.0.1
+port = 27017
+fork = true
+pidfilepath = /var/run/mongodb/mongodb.pid
+logpath = /var/log/mongodb/mongodb.log
+dbpath =/var/lib/mongodb
+journal = true
+
+# Turn on/off security. Off is currently the default
+#noauth = true
+#auth = true
+
+# Verbose logging output.
+#verbose = true
+
+# Disable the HTTP interface (Defaults to port+1000).
+nohttpinterface = true
+
+# Accout token for Mongo monitoring server.
+#mms-token = <token>
+#mms-name = container-sv-mongo
+#mms-interval = 2
+
+# Replication Options
diff --git a/Services/mongo/sx/mongod.sh b/Services/mongo/sx/mongod.sh
new file mode 100644
index 0000000..9bb6281
--- /dev/null
+++ b/Services/mongo/sx/mongod.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+export TERM=dumb
+export MONGO_CONF=/etc/mongodb.conf
+export MONGO_LOGDIR=/var/log/mongodb
+export MONGO_DATADIR=/var/lib/mongodb
+
+
+# Begin configuration before starting daemonized process
+# and start generating host keys
+function begin_config {
+ echo "=> Begin mongod configuration for host $HOSTNAME"
+ mkdir -p $MONGO_LOGDIR
+ mkdir -p $MONGO_DATADIR
+}
+
+# End configuration process just before starting daemon
+function end_config {
+ stop_server
+ echo "=> End mongod configuration ..."
+}
+
+# Start the mongod server in background. Used to perform config
+# against the database structure such as user creation
+function start_server {
+ echo "===> Starting mongod server ..."
+ /usr/bin/mongod --config $MONGO_CONF &
+ sleep 8
+}
+
+# Stop the mongod server running in background.
+function stop_server {
+ echo "===> Stopping mongod server ..."
+ /usr/bin/mongod --shutdown; sleep 2
+ killall mongod; sleep 6
+}
+
+# Start the mongod server as a deamon and execute it inside
+# the running shell
+function start_daemon {
+ echo "=> Starting mongod daemon ..."
+ exec /usr/bin/mongod --config $MONGO_CONF --quiet run
+}
+
+
+if [[ "$0" == *"mongod.sh" && ! $1 = "" ]];then
+ eval "$@";
+fi \ No newline at end of file
diff --git a/Services/mongo/sx/mongod_run.sh b/Services/mongo/sx/mongod_run.sh
new file mode 100644
index 0000000..6a0f018
--- /dev/null
+++ b/Services/mongo/sx/mongod_run.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+source /sx/mongod.sh
+
+begin_config
+end_config
+
+start_daemon \ No newline at end of file