1.1 KiB
1.1 KiB
Node.js app
A small Node.js app with no dependencies (a home page, /api/time and /health), built into a container and served by Caddy with HTTPS.
Files
server.js: the app. Add Express, Fastify or any other framework when you need one.test/: a test with the Node.js test runner (npm test).Dockerfile: Node.js 22 on Alpine, runs as thenodeuser, with a health check.Caddyfile: HTTPS forDOMAIN, passes requests to the app on port 3000.docker-compose.yml: the app and Caddy..env.example: copy it to.env. Your app settings go there too, and it never goes to git.
Try it on your computer
npm test
node server.js # http://localhost:3000
Or with Docker: cp .env.example .env, set DOMAIN=localhost and run docker compose up -d --build.
Publish on your VPS
From the templates folder: sh deploy.sh node-app root@<server ip>. See the main README for the IP and the DNS records.
Each run rebuilds the image and restarts the app. See the logs with docker compose logs -f app on the server.