Created
November 27, 2016 18:24
-
-
Save dharmjit/a48ce2b6684b5a3f69a2056abca0b70b to your computer and use it in GitHub Desktop.
mongodb dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################ | |
# Dockerfile to build MongoDB container image | |
# Based on Ubuntu 16.04 | |
############################################################ | |
# Set the base image to Ubuntu | |
FROM dharmjit/base | |
MAINTAINER dharmjit "dharmjit.bti@gmail.com" | |
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added | |
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends python python-pip\ | |
numactl \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN pip install pymongo | |
# Import the public key used by the package management system | |
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 | |
# Create a list file for MongoDB | |
RUN echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list | |
# install mongodb | |
RUN apt update \ | |
&& apt install -y mongodb-org \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/lib/mongodb \ | |
&& mv /etc/mongod.conf /etc/mongod.conf.orig | |
# create mongo dirs | |
RUN mkdir -p /data/db /data/configdb \ | |
&& chown -R mongodb:mongodb /data/db /data/configdb | |
# create root user, database and database user | |
COPY setup.sh /setup.sh | |
COPY ./datafiles/* / | |
RUN /bin/bash /setup.sh | |
#CMD ["/bin/sh", "-c", "python import_testdata.py > server.log 2>&1"] | |
#CMD [ "python", "./import_testdata.py" ] | |
RUN mkdir -p /data/db /data/configdb \ | |
&& chown -R mongodb:mongodb /data/db /data/configdb | |
VOLUME /data/db /data/configdb | |
COPY mongod.conf /mongod.conf | |
COPY docker-entrypoint.sh /entrypoint.sh | |
RUN chmod +x /entrypoint.sh | |
ENTRYPOINT ["/entrypoint.sh"] | |
EXPOSE 27017 | |
CMD ["/usr/bin/mongod","--config","/mongod.conf"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment