Skip to content

periket2000/py_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py_docker

Image for running python based git projects.

python projects

Should have and structure like the following:

${PROJECT_DIR} +
               |
               +-> README.md
               +-> ...
               +-> ${SRC_DIR} + (will be added to the PYTHONPATH)
                              |
                              + app.py (main entry point, we call this in the end)

Should expose an endpoint that will be the one that we expose in docker.

Check https://github.com/periket2000/rest_api_demo.git, is a Flask app that exposes the api in 8888 port.

You can configure the app through the "env" property in the json file, in this case:

PROJECT_DIR: where everything will be installed inside the container.
GIT_REPO: the repo to download.
SRC_DIR: the source folder inside the project.
APP_FILE: entry point to python application.

sample mesos application json, let's say py-docker.json (see doc/mesos/)

        {
          "id": "py-docker",
          "instances": 1,
          "cpus": 1,
          "mem": 100,
          "constraints": [["hostname", "UNIQUE", ""]],
          "env": {
              "PROJECT_DIR": "/usr/local/pyenv",
              "GIT_REPO": "https://github.com/periket2000/rest_api_demo.git",
              "SRC_DIR": "rest_api_demo",
              "APP_FILE": "app.py"
          },
          "container": {
            "type": "DOCKER",
            "docker": {
              "image": "periket2000/py_docker",
              "network": "BRIDGE",
              "portMappings": [
                {
                  "containerPort": 8888,
                  "hostPort": 0,
                  "servicePort": 0,
                  "protocol": "tcp"
                }
              ]
            }
          },
          "healthChecks": [
              {
                "protocol": "HTTP",
                "portIndex": 0,
                "path": "/api",
                "gracePeriodSeconds": 5,
                "intervalSeconds": 20,
                "maxConsecutiveFailures": 3
              }
            ]
        }

Sample load on mesos

curl -X POST http://<marathon_host>:<marathon_port>/v2/apps -d @<file> -H "Content-type: application/json"
curl -X POST http://192.168.250.101:8080/v2/apps -d @app.json -H "Content-type: application/json"

How to run it in local (requires docker)

git clone https://github.com/periket2000/py_docker.git
cd py_docker
docker run -p 8888:8888 --env-file=env.sh periket2000/py_docker

and point your browser to "http://localhost:8888/api"

About

docker image for running python git based projects under docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages