diff --git a/.drone.yml b/.drone.yml index 68a7b03..5e70f59 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 diff --git a/stable/Dockerfile b/stable/Dockerfile new file mode 100644 index 0000000..4a61356 --- /dev/null +++ b/stable/Dockerfile @@ -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"] diff --git a/stable/config.js b/stable/config.js new file mode 100644 index 0000000..7141ba1 --- /dev/null +++ b/stable/config.js @@ -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" + } +} diff --git a/stable/run.sh b/stable/run.sh new file mode 100644 index 0000000..d5b4567 --- /dev/null +++ b/stable/run.sh @@ -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