GithubHelp home page GithubHelp logo

composetest's Introduction

Demo project to deploy a basic python project with docker-compose

docker and docker-compose are extremely useful when -

  1. you have a single devlopment machine and you are working on multiple projects and these projects' environment needs to be isolated so that you don't keep on solving python package or system package dependencies

[Ref: https://docs.docker.com/compose/gettingstarted/]

Here we have a Simple python project with multiple library dependencies defined in the requirements.txt

Steps to build and deploy the project

Install docker and docker-compose for your host os.

Step 1

We create a DockerFile that help us build a docker image, that will have the required python environment and other dependencies.

Step 2

We create a docker-compose.yaml file as our project depends on other services as well.
Generally, if you need to perform multiple steps in order to process(build/compile) and start required services (e.g database, middleware etc) you can define them in a Compose file. In our example, docker-compose.yaml file defines two services:

  1. hitcount_webapp
  2. redis

The hitcount_webapp service uses an image that is built with the Dockerfile in the current directory. It then binds the container and the host machine to the exposed port, 8000. This example service uses the default port for the Flask web server, 5000.

The redis service uses a public Redis image pulled from the Docker Hub registry .

To build and deploy the app you can use following command

docker-compose up

If you face permission errors while running the docker or docker-compose, you need to create the user group docker with required permisions as following

sudo groupadd docker
sudo usermod -aG docker $USER

Now you can run docker-compose as

newgrp docker
docker-compose up

You can visit http://172.20.0.3:5000/ to see the hit count

composetest's People

Contributors

suvarnak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.