To deploy docker-compose application using Ansible.
The container image is build using GitHub Actions and pushed to DockerHub.
Make sure you updated the secrets before running the pipeline. Follow the below steps:
- Go to Settings
- then Secrets and Variables
- Select Actions
- Under repository Secrets, add the DockerHub credentials as secrets (DOCKER_USERNAME and DOCKER_PASSWORD).
Before deployment update the inventory file. In my example I am deploying to the same server.
Use the below command to deploy the Ansible playbook.
ansible-playbook --inventory inventory deployer.yml
Add sh -vv
flag to the above command to get more detailed log.
Once deployment has been completed, ssh to the remote system and check the container status.
docker ps