Deploy Node.js application with Caddy, Docker & docker-compose on DigitalOcean

Tom Nagle
3 min readMay 9, 2021

In this article, you will learn how to do the easiest Node.js deployment you have ever seen. The application will be deployed with Docker, docker-compose & Caddy Server onto a DigitalOcean droplet.

This guide could be used to deploy a Node.js application onto any VPC, such as Amazon EC2, Linode, even a Raspberry Pi.

GitHub repository: https://github.com/TomDoesTech/caddy-nodejs-docker-tutorial

The diagram below visualizes what you will build as a result of following this guide. Requests will come into the VPC, in this case, a DigitalOcean droplet, they will hit the Docker application running Caddy. Caddy will reverse proxy the request to the Node.js application. The Node.js application will respond and Caddy will forward that request out through port 443.

What is Caddy server and why should I use it?

Caddy server is an open-source web server written in Go. It’s designed to be user-friendly, with the configuration being minimal, while still being scalable and suitable for enterprise-grade applications.

Caddy is an alternative to Nginx or Apache, with the transition to Caddy being as nice as the transition from Apache to Nginx was.

The most notable feature of Caddy is automatic TLC certificate generation and renewals. Couple that with the easy configuration and you have no reason to not be using Caddy Server.

Application configuration

In the root of your application, create a Dockerfile

touch Dockerfile 
Tom Nagle

I am a full stack JavaScript developer, living in Melbourne, Australia. My preferred stack is Mongoose, TypeScript, Node.js, React & GraphQL.