commit 7b103462961a3c88d8b65082df1c86398793f590 Author: Dev Date: Wed Nov 4 12:28:44 2026 +0800 v1: hello world node app diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c0a4a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +npm-debug.log* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7439a70 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:22-alpine + +WORKDIR /app + +COPY package.json ./ +COPY index.js ./ + +ENV NODE_ENV=production +ENV PORT=3000 +EXPOSE 3000 + +CMD ["node", "index.js"] diff --git a/index.js b/index.js new file mode 100644 index 0000000..db5506a --- /dev/null +++ b/index.js @@ -0,0 +1,30 @@ +const http = require('http'); +const os = require('os'); + +const PORT = Number(process.env.PORT || 3000); +const VERSION = process.env.APP_VERSION || 'v1'; +const startedAt = new Date().toISOString(); + +const server = http.createServer((req, res) => { + if (req.url === '/healthz') { + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end('ok'); + return; + } + + res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' }); + res.end(JSON.stringify({ + message: 'Hello World from Gitea + Coolify!', + version: VERSION, + hostname: os.hostname(), + startedAt, + now: new Date().toISOString(), + path: req.url + }, null, 2)); +}); + +server.listen(PORT, '0.0.0.0', () => { + console.log(`hello-coolify ${VERSION} listening on 0.0.0.0:${PORT}`); +}); + +process.on('SIGTERM', () => server.close(() => process.exit(0))); diff --git a/package.json b/package.json new file mode 100644 index 0000000..f3641ea --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "hello-coolify", + "version": "1.0.0", + "private": true, + "description": "Node.js hello world for Gitea + Coolify demo", + "main": "index.js", + "scripts": { + "start": "node index.js" + }, + "engines": { + "node": ">=20" + } +}