GithubHelp home page GithubHelp logo

expero's Introduction

Solution:

A docker-compose file that will bring up 5 services: frontend, backend, postgresql, frontend-lb, backend-lb. The only exported port will be 80 which leads to frontend load balancer. The solution could be deployed on any machine with docker installed on it.

Steps to deploy:

  • Since we don't have a Docker registry the local images should be built for the FE and BE apps.
   cd expero/devops-deployment-test/frontend
   docker build --no-cache -t frontend .
   cd expero/devops-deployment-test/backend
   docker build --no-cache -t backend .
  • Now that we do have the images locally we can bring up the services
    cd expero/devops-deployment-test
    docker-compose up -d
  • After the services are up, we can scale FE and BE apps.
    docker-compose scale backend=2
    docker-compose scale frontend=2

The output for docker ps should be something like:

CONTAINER ID        IMAGE                 COMMAND                  CREATED              STATUS              PORTS                                      NAMES
1818a26f623f        backend               "python3 -m flask ru…"   3 seconds ago        Up 2 seconds        0.0.0.0:32776->5001/tcp                    devops-deployment-test_backend_2
d253f2443eaf        frontend              "python3 -m flask ru…"   10 seconds ago       Up 9 seconds        0.0.0.0:32775->5000/tcp                    devops-deployment-test_frontend_2
8173df7f58e0        dockercloud/haproxy   "/sbin/tini -- docke…"   About a minute ago   Up About a minute   443/tcp, 0.0.0.0:80->80/tcp, 1936/tcp      devops-deployment-test_frontend-lb_1
005749e78d83        dockercloud/haproxy   "/sbin/tini -- docke…"   About a minute ago   Up About a minute   443/tcp, 1936/tcp, 0.0.0.0:32774->80/tcp   devops-deployment-test_backend-lb_1
4f5b32490732        postgres              "docker-entrypoint.s…"   About a minute ago   Up About a minute   5432/tcp                                   devops-deployment-test_postgresql_1
ff2586274844        frontend              "python3 -m flask ru…"   About a minute ago   Up About a minute   0.0.0.0:32773->5000/tcp                    devops-deployment-test_frontend_1
5a7020d88efe        backend               "python3 -m flask ru…"   About a minute ago   Up About a minute   0.0.0.0:32772->5001/tcp                    devops-deployment-test_backend_1

It can be killed any frontend/backend container and the apps will still function.

Swarm mode

Note: Because it is already developed a docker-compose file for the previous deployment, something different could be, deploy the stack using just commands (that could be easily wrapped up in a script).

Create docker network

Note: This would be for restricting services (e.g. only BE could access the DB)

docker network create --driver overlay frontend
docker network create --driver overlay backend

Create services

docker service create --network backend --mount type=bind,source=/swarm/volumes,target=/var/lib/postgresql/data -p 5432 --name postgresql -e "POSTGRES_PASSWORD=sammypw" -e "POSTGRES_USER=sammy" -e "POSTGRES_DB=backend" postgres
docker service create --network backend --network frontend --mode global -p 5001 --name backend backend
docker service create --network backend --network frontend --mode global -p 80:5000 --name frontend frontend

expero's People

Contributors

luciantuce 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.