Commit d330295d authored by Paul Colin Hennig's avatar Paul Colin Hennig
Browse files

upload and untar

parent 929f6701
Pipeline #169 failed with stage
in 40 seconds
image: node:latest
stages:
- docker-build
docker-build:
stage: docker-build
image: docker:latest
before_script:
- docker login -u "docker" -p "$CI_REGISTRY_PASSWORD" https://$CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY/$CI_PROJECT_NAME" .
- docker push "$CI_REGISTRY/$CI_PROJECT_NAME"
FROM node:latest
COPY . /doc-host/
WORKDIR /doc-host/
RUN yarn
CMD [ "node", "index.js" ]
"use strict";
\ No newline at end of file
"use strict";
const express = require('express');
const app = express();
const port = process.env.PORT ? process.env.PORT : 3000;
const multer = require('multer')
const tar = require('tar-fs');
const streamBuffers = require('stream-buffers');
const fs=require("fs")
//curl -F file=@index.tar "http://localhost:3000/?project-name=mailcow-api" ; echo
const u=multer({ storage:multer.memoryStorage()}).single('file');
app.post('/', u,(req, res) => {
if (process.env.TOKEN && req.query.token !== process.env.TOKEN) {
res.sendStatus(403);
return;
}
if(fs.existsSync(`./public/${req.query["project-name"]}`)){
fs.rmdirSync(`./public/${req.query["project-name"]}`, { recursive: true });
}
const stream = new streamBuffers.ReadableStreamBuffer();
stream.put(req.file.buffer);
stream.pipe(tar.extract(`./public/${req.query["project-name"]}`));
res.sendStatus(200);
});
app.use('/', express.static('./public/'));
app.listen(port, () => {
console.log(`Server started`);
});
\ No newline at end of file
......@@ -11,6 +11,12 @@
"author": "Paul Colin Hennig",
"license": "MIT",
"dependencies": {
"express": "^4.17.1",
"multer": "^1.4.2",
"stream-buffers": "^3.0.2",
"tar-fs": "^2.1.1"
},
"devDependencies": {
"dotenv": "^8.2.0",
"eslint": "^7.13.0"
}
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INDEX!</title>
</head>
<body>
test
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment