├── .gitignore ├── .dockerignore ├── Caddyfile ├── Dockerfile ├── src └── server.js ├── package.json ├── docker-compose.yml └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .ssh/ 2 | node_modules/ -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .env 3 | .ssh/ 4 | .ssh/* 5 | -------------------------------------------------------------------------------- /Caddyfile: -------------------------------------------------------------------------------- 1 | express.webdevcody.com { 2 | reverse_proxy web:3000 3 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:22 2 | 3 | WORKDIR /app 4 | 5 | COPY package*.json ./ 6 | 7 | RUN npm install 8 | 9 | COPY . . 10 | 11 | EXPOSE 3000 12 | 13 | CMD ["npm", "start"] 14 | -------------------------------------------------------------------------------- /src/server.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const app = express(); 3 | 4 | app.get("/", (req, res) => { 5 | res.send("Hello World"); 6 | }); 7 | 8 | app.listen(3000, () => { 9 | console.log("Server is running on port 3000"); 10 | }); 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docker-stack-example", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "scripts": { 6 | "start": "node src/server.js" 7 | }, 8 | "keywords": [], 9 | "author": "", 10 | "license": "MIT", 11 | "description": "", 12 | "dependencies": { 13 | "express": "^4.21.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | web: 5 | image: webdevcody/express 6 | networks: 7 | - caddy_network 8 | 9 | caddy: 10 | image: caddy:2 11 | restart: unless-stopped 12 | ports: 13 | - "80:80" 14 | - "443:443" 15 | volumes: 16 | - /root/Caddyfile:/etc/caddy/Caddyfile 17 | - caddy_data:/data 18 | - caddy_config:/config 19 | networks: 20 | - caddy_network 21 | 22 | networks: 23 | caddy_network: 24 | driver: overlay 25 | 26 | volumes: 27 | caddy_data: 28 | caddy_config: 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Web Dev Cody 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------