Mongo Source Code Files

Note: For a detailed annotation of Dockerfile and source code, refer to the files in the preceding folders: MVP_App and MVP_Docker

Dockerfile

############################################################
# Dockerfile to build Mongodb container images
# Based on Ubuntu
############################################################

# Set the base image to Ubuntu
FROM ubuntu:latest

# File Author / Maintainer
MAINTAINER  Mike Pate

# Update the repository sources list
RUN apt-get update

################## BEGIN INSTALLATION ######################
# Install Model; apps
# Ref: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps
#install curl
RUN apt-get install curl -y
#########create directory structure########
#
RUN mkdir /ContClBase
#
############ intsall Mongodb  Prerequisites #########################
# import they key for the official MongoDB repository
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
# add the MongoDB repository details 
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
RUN apt-get update -y
###########  Install Mongo db  #####################
RUN apt-get install -y mongodb-org
# Update the repository sources list once more
RUN apt-get update -y
#
# expose mongodb default port
##############
EXPOSE 27017
#############
# copy cmd wrapper  script containing copying of host file info plus  python script
COPY mongod.conf mongod.conf
COPY wrapper.sh wrapper.sh
RUN chmod +x wrapper.sh
RUN apt-get upgrade -y
CMD ./wrapper.sh


Mongod.conf


# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
#  bindIp: 127.0.0.1


#processManagement:

security:
# authorization: 'enabled'
#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:



wrapper.sh

#!bin/bash
cp mongod.conf /etc/mongod.conf
useradd -ms /bin/bash dbuser
echo 'dbuser:mypass' | chpasswd
mkdir data
mkdir data/db
mongod