Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Paul Colin Hennig
doc-host
Commits
d330295d
Commit
d330295d
authored
Nov 13, 2020
by
Paul Colin Hennig
Browse files
upload and untar
parent
929f6701
Pipeline
#169
failed with stage
in 40 seconds
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
d330295d
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"
Dockerfile
View file @
d330295d
FROM
node:latest
COPY
. /doc-host/
WORKDIR
/doc-host/
RUN
yarn
CMD
[ "node", "index.js" ]
index.js
View file @
d330295d
"
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
package.json
View file @
d330295d
...
...
@@ -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
"
}
...
...
public/mailcow-api/index.html
0 → 100644
View file @
d330295d
<!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
yarn.lock
View file @
d330295d
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment