Add stable build

This commit is contained in:
Armin Friedl 2020-06-07 21:51:15 +02:00
parent 6b8bc86a75
commit 9cf8965a04
4 changed files with 94 additions and 0 deletions

View file

@ -23,3 +23,31 @@ trigger:
- cron
cron:
- hastebin_latest
---
kind: pipeline
type: docker
name: stable
steps:
- name: publish
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
dockerfile: stable/Dockerfile
context: stable/
build-args:
- HASTEBIN_VERSION=master
purge: true
repo: arminfriedl/hastebin
tags: stable
trigger:
event:
- cron
cron:
- hastebin_stable

27
stable/Dockerfile Normal file
View file

@ -0,0 +1,27 @@
FROM node:current-alpine
ARG HASTEBIN_VERSION
ENV UID=1005 GID=1005
COPY run.sh /usr/local/bin/run.sh
RUN apk -U upgrade \
&& apk --no-cache add git su-exec \
&& git clone https://github.com/seejohnrun/haste-server.git /app \
&& cd app \
&& git checkout ${HASTEBIN_VERSION} \
&& npm install \
&& npm cache clean --force \
&& apk del git \
&& rm -rf /var/lib/apk/* /var/cache/apk/* \
&& chmod +x /usr/local/bin/run.sh
# we cannot copy this before the RUN because
# git clone will fail if app/ is not empty
COPY config.js /app/config.js
WORKDIR /app
VOLUME /app/data
EXPOSE 7777
ENTRYPOINT ["run.sh"]

31
stable/config.js Normal file
View file

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

8
stable/run.sh Normal file
View file

@ -0,0 +1,8 @@
#!/bin/sh
set -xe
# we have to run the chown here since the VOLUME is mounted
# after the build with root:root
chown -R ${UID}:${GID} /app
su-exec ${UID}:${GID} npm start