This project is based on testdriven.io Microservices with Docker, Flask and React
- flask-microservices-main Docker Compose files, Nginx, admin scripts
- flask-microservices-users Flask App
- flask-microservices-client client-side based on ReactJS
- create docker-machine for local (with virtualbox driver)
$ docker-machine create --driver virtualbox dev- activate docker-machine
$ eval $(docker-machine env dev)- add environment
$ export REACT_APP_USERS_SERVICE_URL=http://DOCKER_MACHINE_IP- Build the images and spin up the containers
$ docker-compose up -d --build- 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 testTest it by opening your browser http://0.0.0.0:80 or http://0.0.0.0:80/users
- 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- activate docker-machine
$ eval "$(docker-machine env prod)"- add environment
$ export REACT_APP_USERS_SERVICE_URL=http://DOCKER_MACHINE_IP
$ export SECRET_KEY=MyS3cr3tK3y- Build the images and spin up the containers
$ docker-compose -f docker-compose-prod.yml up -d --build- 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- watch the logs
$ docker-compose logs -f users-service- grab ip
$ docker-machine ip prodTest it by opening your browser http://YOUR_PROD_IP:80 or http://YOUR_PROD_IP:80/users
To stop Docker container:
$ docker-compose stopTo bring down the container:
$ docker-compose downForce build:
$ docker-compose build --no-cacheRemove image:
$ docker rmi $(docker images -q)Export local environment:
$ export REACT_APP_USERS_SERVICE_URL=HTTP://IP_DOCKER_APP_USERAccess database via psql:
$ docker exec -ti users-db psql -U postgres -W