diff --git a/Docker/01esoclimi/Dockerfile b/Docker/01esoclimi/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1cd85e8d58d92d5d8cfae024ad53c46d43402e40 --- /dev/null +++ b/Docker/01esoclimi/Dockerfile @@ -0,0 +1,35 @@ +# 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 + + diff --git "a/Docker/01esoclimi/Icon\r" "b/Docker/01esoclimi/Icon\r" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Docker/02App/Dockerfile b/Docker/02App/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2bf89e9370fc533fce40d0d32d6d6c472a74cca5 --- /dev/null +++ b/Docker/02App/Dockerfile @@ -0,0 +1,20 @@ +# 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"] diff --git "a/Docker/02App/Icon\r" "b/Docker/02App/Icon\r" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Docker/02App/main.py b/Docker/02App/main.py new file mode 100644 index 0000000000000000000000000000000000000000..7f6525252fb3f7065c54ba564fd0d766fb467ae2 --- /dev/null +++ b/Docker/02App/main.py @@ -0,0 +1,24 @@ +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 = "

Hello {name}!

" \ + "Hostname: {hostname}
" \ + "Visits: {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) diff --git a/Docker/02App/requirements.txt b/Docker/02App/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..2a2ca3dea8abd2c236dc3504d6af973280e8514e --- /dev/null +++ b/Docker/02App/requirements.txt @@ -0,0 +1,3 @@ +Flask +gunicorn +Redis diff --git "a/Docker/03services/Icon\r" "b/Docker/03services/Icon\r" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Docker/03services/docker-compose.yml b/Docker/03services/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..b31b9964ef69262235921d2fd35ed7b0f3590106 --- /dev/null +++ b/Docker/03services/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3" +services: + web: + image: hello_odmec + deploy: + replicas: 5 + resources: + limits: + cpus: "0.1" + memory: 50M + restart_policy: + condition: on-failure + ports: + - "4000:80" + networks: + - webnet +networks: + webnet: diff --git a/Docker/04Volumes/Dockerfile b/Docker/04Volumes/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..be691063334c41aee25a91c4f16f88d34507180b --- /dev/null +++ b/Docker/04Volumes/Dockerfile @@ -0,0 +1,17 @@ +# Use an official Python runtime as a parent image +FROM hello_odmec + +# Set the working directory to /app +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . /app + +# 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"] diff --git "a/Docker/04Volumes/Icon\r" "b/Docker/04Volumes/Icon\r" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Docker/04Volumes/main.py b/Docker/04Volumes/main.py new file mode 100644 index 0000000000000000000000000000000000000000..ef756ac747e144ae1ac04613def2dbf0e5dda988 --- /dev/null +++ b/Docker/04Volumes/main.py @@ -0,0 +1,24 @@ +from flask import Flask +import os +import socket + +visits = 0 +app = Flask(__name__) + +@app.route("/") +def hello(): + try: + with open( "/data/count.txt", "r" ) as f: + count = f.read() + except: + count = 0 + html = "

Hello {name}!

" \ + "Hostname: {hostname}
" \ + "Visits: {visits}" + count = int(count) + with open( "/data/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) diff --git a/Docker/04Volumes/requirements.txt b/Docker/04Volumes/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..2a2ca3dea8abd2c236dc3504d6af973280e8514e --- /dev/null +++ b/Docker/04Volumes/requirements.txt @@ -0,0 +1,3 @@ +Flask +gunicorn +Redis diff --git a/Docker/05compose/Dockerfile b/Docker/05compose/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eda942db2c79914d0755e041ee98fba6b258c508 --- /dev/null +++ b/Docker/05compose/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.4-alpine +ADD . /code +WORKDIR /code +RUN pip install -r requirements.txt +CMD ["python", "main.py"] diff --git "a/Docker/05compose/Icon\r" "b/Docker/05compose/Icon\r" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Docker/05compose/docker-compose.yml b/Docker/05compose/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..899cf44491155d63b6b9f040dec3025ef0b03058 --- /dev/null +++ b/Docker/05compose/docker-compose.yml @@ -0,0 +1,8 @@ +version: '3' +services: + web: + build: . + ports: + - "5000:5000" + redis: + image: "redis:alpine" diff --git a/Docker/05compose/main.py b/Docker/05compose/main.py new file mode 100644 index 0000000000000000000000000000000000000000..cce338fa8e950b1300c771ac7d3554dbf9a58133 --- /dev/null +++ b/Docker/05compose/main.py @@ -0,0 +1,30 @@ +import time + +import redis +from flask import Flask + + +app = Flask(__name__) +cache = redis.Redis(host='redis', port=6379) + + +def get_hit_count(): + retries = 5 + while True: + try: + return cache.incr('hits') + except redis.exceptions.ConnectionError as exc: + if retries == 0: + raise exc + retries -= 1 + time.sleep(0.5) + + +@app.route('/') +def hello(): + count = get_hit_count() + return 'Hello World! I have been seen {} times.\n'.format(count) + +if __name__ == "__main__": + app.run(host="0.0.0.0", debug=True) + diff --git a/Docker/05compose/requirements.txt b/Docker/05compose/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..1a5dc97b12cb591339699ea7dda28d9b32117a56 --- /dev/null +++ b/Docker/05compose/requirements.txt @@ -0,0 +1,2 @@ +flask +redis diff --git a/Docker/Examples b/Docker/Examples new file mode 100644 index 0000000000000000000000000000000000000000..74b1d35b19023bc25fc6b317c90e74421e9f0234 --- /dev/null +++ b/Docker/Examples @@ -0,0 +1,25 @@ +docker run --rm -ti ubuntu:latest bash + +docker run -ti ubuntu:latest bash +--mount type=bind,source="$(pwd)"/target,target=/app + +docker ps -a + +docker attach 9ef4536973c7 +docker start 9ef4536973c7 +docker ps -a +docker attach 9ef4536973c7 +docker rm 9ef4536973c7 +docker ps -a + +export ODMEC="ENV_DATA" +docker run --name ubuntu.test -ti -v $PWD:/data -e ODMEC ubuntu bash + + +docker run -ti -v /data2 ubuntu:latest bash +root@bbdf070861eb:/# cd /data2/ +root@bbdf070861eb:/data2# + + + + diff --git a/Docker/pythonApp/Dockerfile b/Docker/pythonApp/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2bf89e9370fc533fce40d0d32d6d6c472a74cca5 --- /dev/null +++ b/Docker/pythonApp/Dockerfile @@ -0,0 +1,20 @@ +# 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"] diff --git "a/Docker/pythonApp/Icon\r" "b/Docker/pythonApp/Icon\r" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Docker/pythonApp/main.py b/Docker/pythonApp/main.py new file mode 100644 index 0000000000000000000000000000000000000000..e4734fd1bcf198b858cb5545add57066f9cc97e1 --- /dev/null +++ b/Docker/pythonApp/main.py @@ -0,0 +1,30 @@ +# [START gae_flex_quickstart] +import logging + +from flask import Flask + + +app = Flask(__name__) + + +@app.route('/') +def hello(): + """Return a friendly HTTP greeting.""" + return 'Hello World!' + + +@app.errorhandler(500) +def server_error(e): + logging.exception('An error occurred during a request.') + return """ + An internal error occurred:
{}
+ See logs for full stacktrace. + """.format(e), 500 + + +if __name__ == '__main__': + # This is used when running locally. Gunicorn is used to run the + # application on Google App Engine. See entrypoint in app.yaml. + app.run(host='127.0.0.1', port=80, debug=True) +# [END gae_flex_quickstart] + diff --git a/Docker/pythonApp/requirements.txt b/Docker/pythonApp/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..a34d076bacf91a5a2e39f6c78561def407ec7e15 --- /dev/null +++ b/Docker/pythonApp/requirements.txt @@ -0,0 +1,2 @@ +Flask==1.0.2 +gunicorn==19.9.0