diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 4f1982b..d5a9917 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -3,8 +3,10 @@ services: image: nginx/unit:1.22.0-minimal restart: unless-stopped volumes: - - ../.unit/config.json:/docker-entrypoint.d/config.json:ro + - ../.unit/config-app.json:/docker-entrypoint.d/config.json:ro - ../public/:/var/www/public/:ro + - ../src/app.js:/var/www/app.js + #command: ["chmod", "+x", "/var/www/app.js"] ports: - 80:80 - 443:443 diff --git a/.unit/config-app.json b/.unit/config-app.json new file mode 100644 index 0000000..19992ab --- /dev/null +++ b/.unit/config-app.json @@ -0,0 +1,24 @@ +{ + "listeners": { + "*:80": { + "pass": "routes" + } + }, + "routes": [ + { + "action": { + "share": "/www/public/", + "fallback": { + "pass": "applications/node" + } + } + } + ], + "applications": { + "node": { + "type": "external", + "working_directory": "/www/", + "executable": "app.js" + } + } +} \ No newline at end of file diff --git a/public/images/banner.png b/public/images/banner.png new file mode 100644 index 0000000..24b6954 Binary files /dev/null and b/public/images/banner.png differ diff --git a/src/app.js b/src/app.js new file mode 100755 index 0000000..9545f9d --- /dev/null +++ b/src/app.js @@ -0,0 +1,9 @@ +#!/usr/bin/env node + +import http from "unit-http"; + +http.createServer(async function (request, response) { + response.writeHead(200, { "Content-Type": "text/html" }); + const {x} = await import('./modules/dynamic.js'); + response.end("Hello, Node.js on Unit!" + x) +}).listen();