Dockerize Haste with Alpine Linux

This commit is contained in:
Óscar García Amor 2017-07-22 18:03:39 +02:00
commit 40d58f95d7
5 changed files with 270 additions and 0 deletions

13
Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM alpine:3.6
COPY . /srv/haste
RUN /srv/haste/docker/build.sh
EXPOSE 7777
VOLUME [ "/srv/haste/data" ]
WORKDIR /srv/haste
ENTRYPOINT [ "/usr/bin/node", "server.js" ]

View file

@ -26,6 +26,20 @@ STDOUT. Check the README there for more details and usages.
* Chrome 17
* Safari 5.3
## Fast run in Docker
To test or run current build of hastebin you can use Docker, simply do.
```
docker pull connectical/haste
docker run -d --name haste -v /srv/haste/data:/srv/haste/data \
-p 127.0.0.1:7777:7777 connectical/haste
```
This starts node server in http://localhost:7777 and stores data in
`/srv/haste/data` volume.
## Installation
1. Download the package, and expand it

171
docker/application.css Normal file
View file

@ -0,0 +1,171 @@
body {
background: #002B36;
padding: 20px 50px;
margin: 0px;
}
/* textarea */
textarea {
background: transparent;
border: 0px;
color: #fff;
padding: 0px;
width: 100%;
height: 100%;
font-family: monospace;
outline: none;
resize: none;
font-size: 13px;
}
/* the line numbers */
#linenos {
color: #7d7d7d;
z-index: -1000;
position: absolute;
top: 20px;
left: 0px;
width: 30px; /* 30 to get 20 away from box */
font-size: 13px;
font-family: monospace;
text-align: right;
}
/* code box when locked */
#box {
padding: 0px;
margin: 0px;
border: 0px;
outline: none;
font-size: 13px;
padding-right: 360px;
overflow: inherit;
}
#box code {
padding: 0px;
background: transparent !important; /* don't hide hastebox */
}
/* key */
#key {
position: fixed;
top: 0px;
right: 0px;
z-index: +1000; /* watch out */
}
#box1 {
padding: 5px;
text-align: center;
background: #00222b;
}
#box2 {
background: #08323c;
font-size: 0px;
padding: 0px 5px;
}
#box1 a.logo, #box1 a.logo:visited {
display: inline-block;
background: url(logo.png);
width: 126px;
height: 42px;
}
#box1 a.logo:hover {
background-position: 0 bottom;
}
#box2 .function {
background: url(function-icons.png);
width: 32px;
height: 37px;
display: inline-block;
position: relative;
}
#box2 .link embed {
vertical-align: bottom; /* fix for zeroClipboard style */
}
#box2 .function.enabled:hover {
cursor: hand;
cursor: pointer;
}
#pointer {
display: block;
height: 5px;
width: 10px;
background: url(hover-dropdown-tip.png);
bottom: 0px;
position: absolute;
margin: auto;
left: 0px;
right: 0px;
}
#box3, #messages li {
background: #173e48;
font-family: Helvetica, sans-serif;
font-size: 12px;
line-height: 14px;
padding: 10px 15px;
}
#box3 .label, #messages li {
color: #fff;
font-weight: bold;
}
#box3 .shortcut {
color: #c4dce3;
font-weight: normal;
}
#box2 .function.save { background-position: -5px top; }
#box2 .function.enabled.save { background-position: -5px center; }
#box2 .function.enabled.save:hover { background-position: -5px bottom; }
#box2 .function.new { background-position: -42px top; }
#box2 .function.enabled.new { background-position: -42px center; }
#box2 .function.enabled.new:hover { background-position: -42px bottom; }
#box2 .function.duplicate { background-position: -79px top; }
#box2 .function.enabled.duplicate { background-position: -79px center; }
#box2 .function.enabled.duplicate:hover { background-position: -79px bottom; }
#box2 .function.raw { background-position: -116px top; }
#box2 .function.enabled.raw { background-position: -116px center; }
#box2 .function.enabled.raw:hover { background-position: -116px bottom; }
#box2 .function.twitter { background-position: -153px top; }
#box2 .function.enabled.twitter { background-position: -153px center; }
#box2 .function.enabled.twitter:hover { background-position: -153px bottom; }
#box2 .button-picture{ border-width: 0; font-size: inherit; }
#messages {
position:fixed;
top:0px;
right:138px;
margin:0;
padding:0;
width:400px;
}
#messages li {
background:rgba(23,62,72,0.8);
margin:0 auto;
list-style:none;
}
#messages li.error {
background:rgba(102,8,0,0.8);
}

28
docker/build.sh Executable file
View file

@ -0,0 +1,28 @@
#! /bin/sh
#
# build.sh
# Copyright (C) 2017 Óscar García Amor <ogarcia@connectical.com>
#
# Distributed under terms of the GNU GPLv3 license.
#
# upgrade
apk -U --no-progress upgrade
# install deps
apk --no-progress add nodejs nodejs-npm
# fix horizontal scroll bar that appears in locked haste
cd /srv/haste
cp docker/application.css static/application.css
# config and install
cp docker/config.js .
npm install --production
# clean
apk --no-progress del nodejs-npm
rm -rf /root/.ash_history /root/.npm /srv/haste/package-lock.json \
/srv/haste/package.json /srv/haste/Dockerfile /srv/haste/Procfile \
/srv/haste/README.md /srv/haste/.git* /srv/haste/.eslint* \
/srv/haste/docker

44
docker/config.js Normal file
View file

@ -0,0 +1,44 @@
{
"host": "0.0.0.0",
"port": 7777,
"keyLength": 10,
"maxLength": 400000,
"staticMaxAge": 86400,
"recompressStaticAssets": true,
"logging": [
{
"level": "verbose",
"type": "Console",
"colorize": true
}
],
"keyGenerator": {
"type": "phonetic"
},
"rateLimits": {
"categories": {
"normal": {
"totalRequests": 500,
"every": 60000
}
}
},
"storage": {
"type": "file",
"path": "./data"
},
"documents": {
"about": "./about.md"
}
}