A number counting application made with GO, running on port 8080, using Redis a database and Nginx as reverse proxy. This Project is about creating an image of the Application and Running that with Docker Compose on Vagrant Machine configured with Ansible. I have configured Nginx as reverse proxy and passing the config file on docker compose, pulling the Redis Image and connecting all together to run the whole Application Stack. Vagrant is used to create the Virtual Machine where our application is deployed using Ansible playbook.
- Go
- Redis
- Nginx
- Docker
- Ansible
- Vagrant
- Pulling the Golang image and exposing the port.
- In the Dockerfile passing two Environment variables input
DEMO_APP_ADDR = <APPLICATION-IP>:<APPLICATION-PORT>
andDEMO_REDIS_ADDR = <REDIS-CONTAINER-NAME>:<REDIS-PORT>
- Specifying the working directory where application code will be copied and executed.
- Copying the Application code.
- Building the Application.
- Running the Application.
- Creating the services as
demoapp
,database
andserver
. - Giving the build context or the dockerfile location
- Giving
image-name
,container-name
and specifying theports
of database and server services. - Creating a Volume to store Redis data
- Adding that volume to redis container
- Passing the Nginx Configfile
- Get the Config file on nginx containers
/etc/nginx/conf.d
directory. - Copy that file and configure it on the proxy pass section.
- Give the port and ip of your application.
- After Installing Vagrant writing the command
vagrant init <YOUR-MACHINE-NAME>
and
vagrant up
to start the machine.
- The IP of that machine is needed so execute
vagrant ssh
to ssh into system and get the ip
- Creating a ssh pair and connect with the Vagrant machine.
- Creating
ansible.cfg
file to configure ansible for this project. - Creating a
inventory
file and stored the Vagrant machine IP - Writting the Ansible playbook and,
- Adding user demo
- Setingup firewall to open only ports- 22,80,6379,8080
- Configuring sysctl to increase open file limits
- Setting systems time zone to asia/kolkata
- Installing docker
- Deploying docker-compose
- Running the services
- Finnaly executing the playbook by running...
ansible-playbook playbook.yaml