Flask
**************************************************************************************************
SET UP A PYTHON APPLICATION IN DOCKER COMPOSE
*************************************************
Steps :
1. cd composeTest/ --Create a Directory and get into that
2. Copy all your code [app.py, image, static etc ]
3. Create3 files
Dockerfile --- How to install OS and Dependency
requirements.txt --- Specific Installation
docker-compose.yml --- How to start Port Mapping
----------------------------------------------------
Sample of docker files
Dockerfile:
---
FROM python:3.4-alpine
#RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
#RUN apk --no-cache --update-cache add gcc gfortran python python-dev py-pip build-base wget freetype-dev libpng-dev openblas-dev
#RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
RUN pip install numpy scipy pandas matplotlib
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
=============
requirements.txt:
---
flask
matplotlib
pandas
pathlib
=============
docker-compose.yml:
---
version: '3'
services:
web:
build: .
ports:
- "4555:4555"
redis:
image: "redis:alpine"
=============
----------------------------------------------------
RUNNING DOCKER COMPOSE
*************************************************
docker-compose build --no-cache (to clean cache) [ Build the Image ]
docker-compose up [ RUN the Container ]
docker ps [ Check What is running ]
Run Browser e.g http://ec2-34-244-79-228.eu-west-1.compute.amazonaws.com:4555/fx
Additional Steps for docker running on Windows
docker-compose stop [ Stop Container ]
docker-machine ip [ Check IP address ]
Add the port forwarding
Run Browser http://192.168.99.100:4555/fx
**************************************************************************************************