DEV Community

Discussion on: DEPLOY YOUR WEB APPLICATIONS IN A MINUTE - MADE WITH 💖 FOR DOCKERISTS

Collapse
 
aimerib profile image
Aimeri Baddouh

I love this! Will certainly adopt it, and might even turn this into an ansible recipe. My only two pieces of suggestion:

If you want to keep only one nginx per host, but have multiple applications running in container, perhaps you could look into using swarm. Have one stack for your proxy, and deploy other apps in their own stack, but have them communicate via a dedicated nginx network. You already have all the tools necessary, and deploying it becomes a matter of having the right docker-compose.yml files, which you can keep in a repo. It reduces the amount of dependencies on the host, and makes it a little faster to upgrade versions, or replacing proxy/load balancers down the road.

in your script you have the latest version of docker-compose hardcoded, but if you wanted to always get the latest version you could replace the line:

curl -L "https://github.com/docker/compose/releases/download/1.27.0/docker-compose-$(uname -s)-$(uname -m)" -o docker-compose

with:

curl -s https://api.github.com/repos/docker/compose/releases/latest \
| grep -v ".sha256" \
| grep browser_download_url \
| grep "docker-compose-$(uname -s)-$(uname -m)" \
| cut -d '"' -f 4 \
| xargs curl -L -o docker-compose

The above is going to query the github api to get a list of the most recent release, ignore the .sha256 file, filter out any fields that aren't download urls, find the right download for your distro, get only the actual url, and curl download it. Everything else in the script remains the same.

Collapse
 
crazyoptimist profile image
crazyoptimist

Updated according to your advice, thanks!

Collapse
 
crazyoptimist profile image
crazyoptimist

Great!