Commit 8d006354 authored by Giuliano Taffoni's avatar Giuliano Taffoni
Browse files

add Docker exercises

parent b0683c37
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
# I use CentOS latest
FROM centos:latest

# I set the work directory
WORKDIR /home/mpi4py

# I copy the content of the current dir into /home/mpi4py
COPY . /home/mpi4py

# Install some sw
RUN yum install -y  vim wget epel-release
RUN yum install -y gsl gsl-devel gcc gcc-gfortran make autoconf patch automake 
RUN yum install -y mpich-3.2 mpich-3.2-devel mpich-3.2-autoload environment-modules 
RUN yum install -y python-devel numpy python-matplotlib python2-pip

# I set some env virables
ENV MPI_INCLUDE=/usr/include/mpich-3.2-x86_64
ENV MPI_PYTHON_SITEARCH=/usr/lib64/python2.7/site-packages/mpich-3.2
ENV MPI_LIB=/usr/lib64/mpich-3.2/lib
ENV MPI_BIN=/usr/lib64/mpich-3.2/bin
ENV MPI_COMPILER=mpich-3.2-x86_64
ENV MPI_SYSCONFIG=/etc/mpich-3.2-x86_64
ENV MPI_SUFFIX=_mpich-3.2
ENV MPI_MAN=/usr/share/man/mpich-3.2
ENV MPI_HOME=/usr/lib64/mpich-3.2
ENV MPI_FORTRAN_MOD_DIR=/usr/lib64/gfortran/modules/mpich-3.2-x86_64
ENV PATH="/usr/lib64/mpich-3.2/bin:${PATH}"

# install some python modules
RUN pip install --upgrade pip
RUN pip install mpi4py
RUN pip install astropy
RUN pip install ipython

+0 −0

Empty file added.

+20 −0
Original line number Diff line number Diff line
# Use an official Python runtime as a parent image
FROM python:2.7-slim

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "main.py"]

Docker/02App/Icon

0 → 100644
+0 −0

Empty file added.

Docker/02App/main.py

0 → 100644
+24 −0
Original line number Diff line number Diff line
from flask import Flask
import os
import socket

visits = 0
app = Flask(__name__)

@app.route("/")
def hello():
    try:
        with open( "count.txt", "r" ) as f:
             count = f.read()
    except:
 	     count = 0  
    html = "<h3>Hello {name}!</h3>" \
           "<b>Hostname:</b> {hostname}<br/>" \
           "<b>Visits:</b> {visits}"
    count = int(count)
    with open( "count.txt", "w" ) as f:
         f.write( str(count+1) )
    return html.format(name=os.getenv("NAME", "world"), hostname=socket.gethostname(), visits=count)

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=80)
Loading