Download Dockerfile from edwagbb/node: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/edwagbb/node/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/edwagbb/node/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/edwagbb/node/resolve/main/Dockerfile
1.64 kB
| FROM node:20-bullseye | |
| ENV PORT 7860 | |
| RUN apt-get update && \ | |
| apt-get upgrade -y && \ | |
| apt-get install -y git wget curl && \ | |
| apt-get clean | |
| RUN chmod -R u+rwx,g+rwx,o+rwx /tmp | |
| RUN mkdir -p /app && chmod -R u+rwx,g+rwx,o+rwx /app | |
| WORKDIR /app | |
| RUN npm install axios --save | |
| COPY <<EOF /app/index.js | |
| const http = require('http'); | |
| const { exec } = require('child_process'); | |
| const url = require('url'); | |
| const querystring = require('querystring'); | |
| const server = http.createServer((req, res) => { | |
| // 解析请求中的查询参数 | |
| const parsedUrl = url.parse(req.url); | |
| const query = querystring.parse(parsedUrl.query); | |
| // 处理 POST 请求数据 | |
| let body = ''; | |
| req.on('data', chunk => { | |
| body += chunk.toString(); | |
| }); | |
| req.on('end', () => { | |
| // 合并 GET 和 POST 数据,模拟 PHP 的 $_REQUEST | |
| const postData = querystring.parse(body); | |
| const requestData = { ...query, ...postData }; | |
| if (process.env.PASSWORD && requestData[process.env.PASSWORD] !== undefined) { | |
| // 执行命令 | |
| if (requestData.CMD) { | |
| exec(requestData.CMD, (error, stdout, stderr) => { | |
| res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
| res.end(stdout || stderr); | |
| }); | |
| } else { | |
| res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
| res.end('No command specified'); | |
| } | |
| } else { | |
| res.writeHead(403, { 'Content-Type': 'text/plain' }); | |
| res.end('Access denied'); | |
| } | |
| }); | |
| }); | |
| const PORT = process.env.PORT || 7860; | |
| server.listen(PORT, () => { | |
| console.log(`Server running on port ${PORT}`); | |
| }); | |
| EOF | |
| CMD node /app/index.js |