a simple app for experimental reasons
Building a simple web application at its root URL it displays a form that accepts three fields as input: "Nickname", "Favorite color" and "Cats or Dogs". This form saves the result in a relational database and ensure that "Nickname" is unique.
- React.js: to build user interface
- Node.js: to build server side
- PostgreSQL: to store data
- Docker: to package the application into containers
- Ansible: to deploy the application
- To run the application locally:
From the project directory, start up the application by running:
docker-compose up --build
Note: the built images of this web app (server and client) exist in the Docker Hub
sudo apt-get update
sudo apt-get install ansible
- Make sure that the Ansible server (your machine in that case) should reach the other remote servers via ssh.
- Rename the hosts file and create another one as below
sudo mv /etc/ansible/hosts /etc/ansible/hosts.orig
sudo vim /etc/ansible/hosts
- Add your remote servers so that your file appear as below
[webserver]
the remote server IP adress here
- copy the docker-playbook.yml to the
/etc/ansible/
directory - From the
/etc/ansible/
directory, start up the deployment by running:
ansible-playbook docker-playbook.yml
- You can confirm running containers by running:
ansible all -m shell -a 'sudo docker ps'
Now navigate to your browser, enter http://your-remote-host-ip:8080
. You should get the web application page from the remote server.
Ps: Make sure that the port 8080 on the remote nodes is opened.
Ps: If you don't possess an instance on the cloud you can also try testing deploying the web application locally by changing all
to localhost
and removing the preparation tasks in the docker-playbook.yml file.