This project is a full LEMP stack example that is dockerized. It consists of a basic bootstrap + jQUery front-end which communicates with the simple PHP endpoints via AJAX. The PHP endpoints then access a MySQL database which exists locally. The entire project is dockerized for both local development through local file mounting and for more robust vps deployment. The web-app can actually be somewhat useful: I utilize a personal deployment of this project to keep track of errands :)
Local testing is facilitated through file mounting, allowing for faster development:
- Make sure that docker and docker-compose are installed
make run
handles everything involved in installing, building and running the server in the background: access the server locally on: http://localhost:8080- Remember to stop the server when you're finished:
make stop
- You can reset the database with
make reset
; otherwise changes made to the website are persistent across uses
Deployment to DigitalOcean is quite simple with the following steps:
- Create a DigitalOcean account and a personal access token through their API tab
- Install docker-machine if necessary
- Create a new droplet configured for docker:
docker-machine create --driver digitalocean --digitalocean-access-token PERSONAL_ACCESS_TOKEN DROPLET_NAME
- Use the newly created machine:
eval $(docker-machine env temp)
- Build the containers on the remote droplet:
make deploy
- Stop the containers using
make stop
and reset the database usingmake reset
- Stop using the machine and return to the local environment:
eval $(docker-machine env -u)
- Destroy the droplet using
docker-machine rm DROPLET_NAME
(be careful) - Investigate the following article for more detailed deployment info: "https://www.digitalocean.com/community/tutorials/how-to-provision-and-manage-remote-docker-hosts-with-docker-machine-on-ubuntu-18-04"