Dockerized environment for 'python-api' repo to improve my ansible skills.
-
Clone repo.
git clone https://github.com/JaviSabalete/python-api-environment.git
-
Generate key in order to use ansible.
ssh-keygen -f ansible -q -P "" -
Generate git deploy key.
ssh-keygen -f git -q -P "" -
Fork python-api repo.
-
Edit
init-apireplacing repo by your forked repo. You should only replace GitHub username. -
Add
git.pubas github read-only deploy key.
-
Start containers in the background. This command creates containers if don't exist or recreates them if
docker-compose.ymlhas been modified.docker-compose up -d
-
Access your app via http://localhost/.
-
Try to ping.
ansible -i hosts/all -m ping python-api
-
Try to deploy.
ansible-playbook -i hosts/all playbook/git.yml --tag=pull
-
Try to stop nginx.
ansible-playbook -i hosts/all playbook/nginx.yml --tag=stop
# List containers docker-compose ps # View logs docker-compose logs # Restart containers docker-compose restart # Stop containers docker-compose stop # Stop and remove containers. docker-compose down # Start a terminal session for python container docker exec -ti pythonapi_python_1 bash # Rebuild docker-compose build or docker-compose up --build