Write a Dockerfile (CentOS 6) to install the following in a Docker continer: Python 2.7 MongoDB - any version Apache tomcat 7 - running on port 8080


#The base image to use in the build FROM centos:centos6
MAINTAINER The Sagar Pimparkar <sagar.pimparkar27@gmail.com>
###Installing MongoDB server using epel release Repo
RUN yum -y update; yum clean all
RUN yum -y install epel-release; yum clean all
RUN yum -y install mongodb-server; yum clean all
RUN mkdir -p /data/db
#Opens a port for linked containers
EXPOSE 27017
ENTRYPOINT ["/usr/bin/mongod"]
###Installing python
# Install yum dependencies
RUN yum -y update && \
yum groupinstall -y development && \
yum install -y \
bzip2-devel \
git \
hostname \
openssl \
openssl-devel \
sqlite-devel \
sudo \
tar \
wget \
zlib-dev
# Install python2.7
RUN cd /tmp && \
wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz && \
tar xvfz Python-2.7.8.tgz && \
cd Python-2.7.8 && \
./configure --prefix=/usr/local && \
make && \
make altinstall
# Install setuptools + pip
RUN cd /tmp && \
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz && \
tar -xvf setuptools-1.4.2.tar.gz && \
cd setuptools-1.4.2 && \
python2.7 setup.py install && \
curl https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | python2.7 - && \
pip install virtualenv
###To install Apache Tomcat 7
#Install WGET
RUN yum install -y wget
#Install tar
RUN yum install -y tar
#Install Openjdk7
RUN yum update -y && \
yum install -y wget && \
yum install -y java-1.7.0-openjdk java-1.7.0-openjdk-devel && \
yum clean all
# Download Apache Tomcat 7
RUN cd /tmp;wget http://redrockdigimark.com/apachemirror/tomcat/tomcat-7/v7.0.73/bin/apache-tomcat-7.0.73.tar.gz
# untar and move to proper location
RUN cd /tmp;gunzip apache-tomcat-7.0.73.tar.gz
RUN cd /tmp;tar xvf apache-tomcat-7.0.73.tar
RUN cd /tmp;mv apache-tomcat-7.0.73 /opt/tomcat7
RUN chmod -R 755 /opt/tomcat7
#Sets an environment variable in the new container
ENV JAVA_HOME /opt/jdk1.7.0_79
#Opens a port for linked containers
EXPOSE 8080
#The command that runs when the container starts
CMD ["catalina.sh", "run"]

Comments

Popular posts from this blog

how to upgrade Jenkins if you don't have internet connectivity on VM?

Consider a monolithic java application stack. Apache Web Server, Apache Tomcat application server with Active MQ and Oracle and MongoDB backend. Propose a solution to migrate this application stack to AWS. Mention all the AWS services you would use and how you would maintain HA and Load Balancing (consider app to be stateless). Mention rationale for each design decision.