Skip to content

repodevs/flask-microservices-main

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FLASK MICROSERVICES

Build Status

This project is based on testdriven.io Microservices with Docker, Flask and React

Structure

  1. flask-microservices-main Docker Compose files, Nginx, admin scripts
  2. flask-microservices-users Flask App
  3. flask-microservices-client client-side based on ReactJS

How To Run


Build for Local

  1. create docker-machine for local (with virtualbox driver)
$ docker-machine create --driver virtualbox dev
  1. activate docker-machine
$ eval $(docker-machine env dev)
  1. add environment
$ export REACT_APP_USERS_SERVICE_URL=http://DOCKER_MACHINE_IP
  1. Build the images and spin up the containers
$ docker-compose up -d --build
  1. create and seed the db then run the tests
$ docker-compose run users-service python manage.py recreate_db
$ docker-compose run users-service python manage.py seed_db
$ docker-compose run users-service python manage.py test

Test it by opening your browser http://0.0.0.0:80 or http://0.0.0.0:80/users


Build for Production

  1. create docker-machine for production (with driver digitalocean based on ubuntu 14.04)
$ docker-machine create --driver digitalocean --digitalocean-access-token=DO_TOKEN --digitalocean-image ubuntu-14-04-x64 prod
  1. activate docker-machine
$ eval "$(docker-machine env prod)"
  1. add environment
$ export REACT_APP_USERS_SERVICE_URL=http://DOCKER_MACHINE_IP
$ export SECRET_KEY=MyS3cr3tK3y
  1. Build the images and spin up the containers
$ docker-compose -f docker-compose-prod.yml up -d --build
  1. create and seed the db then run the tests
$ docker-compose -f docker-compose-prod.yml run users-service python manage.py recreate_db
$ docker-compose -f docker-compose-prod.yml run users-service python manage.py seed_db
$ docker-compose -f docker-compose-prod.yml run users-service python manage.py test
  1. watch the logs
$ docker-compose logs -f users-service
  1. grab ip
$ docker-machine ip prod

Test it by opening your browser http://YOUR_PROD_IP:80 or http://YOUR_PROD_IP:80/users


Other Commands

To stop Docker container:

$ docker-compose stop

To bring down the container:

$ docker-compose down

Force build:

$ docker-compose build --no-cache

Remove image:

$ docker rmi $(docker images -q)

Export local environment:

$ export REACT_APP_USERS_SERVICE_URL=HTTP://IP_DOCKER_APP_USER

Access database via psql:

$ docker exec -ti users-db psql -U postgres -W