From 3571638d124299ed832b7fa896ebbcb14a1e8fa5 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Sat, 2 Nov 2019 11:32:49 +0100 Subject: [PATCH] initial commit --- .editorconfig | 9 ++ .gitignore | 2 + .gitlab-ci.yml | 13 +++ Dockerfile | 35 +++++++ README.md | 56 ++++++++++ rootfs/etc/confd/conf.d/config.yml.toml | 3 + rootfs/etc/confd/templates/config.yml.tmpl | 114 +++++++++++++++++++++ rootfs/etc/fix-attrs.d/01-wikijs | 1 + rootfs/etc/services.d/wikijs/run | 4 + 9 files changed, 237 insertions(+) create mode 100644 .editorconfig create mode 100755 .gitignore create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 rootfs/etc/confd/conf.d/config.yml.toml create mode 100644 rootfs/etc/confd/templates/config.yml.tmpl create mode 100644 rootfs/etc/fix-attrs.d/01-wikijs create mode 100644 rootfs/etc/services.d/wikijs/run diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d741e40 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..93bfd12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +.DS_Store diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..392e0c1 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,13 @@ +variables: + IMAGE_NAME: thallian/wikijs + +build: + stage: build + script: + - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD $DOCKER_REGISTRY + - docker build -t $IMAGE_NAME:$CI_COMMIT_SHA . + - docker build -t $IMAGE_NAME:$CI_COMMIT_REF_NAME . + - docker build -t $IMAGE_NAME:latest . + - docker push $IMAGE_NAME:$CI_COMMIT_SHA + - docker push $IMAGE_NAME:$CI_COMMIT_REF_NAME + - docker push $IMAGE_NAME:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7bd9b22 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM alpine:3.10 as builder + +RUN apk add --no-cache \ + git \ + npm \ + make \ + bash + +RUN npm install -g webpack webpack-cli + +RUN git clone https://code.vanwa.ch/sebastian/wikijs.git -b nextcloud-auth /build + +WORKDIR /build +RUN npm install +RUN make build + +FROM thallian/confd-env:latest + +RUN addgroup -g 2222 wikijs +RUN adduser -h /home/wikijs -S -D -u 2222 -G wikijs wikijs + +COPY --from=builder --chown=wikijs:wikijs /build/assets /home/wikijs/assets +COPY --from=builder --chown=wikijs:wikijs /build/node_modules /home/wikijs/node_modules +COPY --from=builder --chown=wikijs:wikijs /build/server /home/wikijs/server +COPY --from=builder --chown=wikijs:wikijs /build/LICENSE /home/wikijs/LICENSE +COPY --from=builder --chown=wikijs:wikijs /build/config.sample.yml /home/wikijs/config.sample.yml +COPY --from=builder --chown=wikijs:wikijs /build/package.json /home/wikijs/package.json + +RUN apk add --no-cache \ + nodejs + +ADD /rootfs / + +VOLUME [ "/home/wikijs/data" ] +EXPOSE 3000 diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a08e83 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +[Wiki.js](https://github.com/Requarks/wiki] with a postgres backend. + +# Volumes +- `/home/wikijs/data` + +# Environment Variables +## DB_TYPE +- default: postgres + +One of: +- postgres +- mysql +- mariadb +- mssql +- sqlite + +In case of `sqlite`, non of the other database options are of concern. + +## DB_HOST +Database host. + +## DB_PORT +- default: 5432 + +Database port. + +## DB_NAME +- default: wikijs + +Database name. + +## DB_USER +- default: wikijs + +Database user. + +## DB_PASSWORD +Password for the database user. + +## DB_SSL +- default: false + +Whether to use ssl for the database connection. + +## MAX_FILE_SIZE +- default: 5242880 + +Maximum upload size in bytes per file. + +## MAX_FILES_PER_REQUEST +- default: 20 + +Maximum file uploads per request. + +# Ports +- 3000 diff --git a/rootfs/etc/confd/conf.d/config.yml.toml b/rootfs/etc/confd/conf.d/config.yml.toml new file mode 100644 index 0000000..e7d83ad --- /dev/null +++ b/rootfs/etc/confd/conf.d/config.yml.toml @@ -0,0 +1,3 @@ +[template] +src = "config.yml.tmpl" +dest = "/home/wikijs/config.yml" diff --git a/rootfs/etc/confd/templates/config.yml.tmpl b/rootfs/etc/confd/templates/config.yml.tmpl new file mode 100644 index 0000000..e19d568 --- /dev/null +++ b/rootfs/etc/confd/templates/config.yml.tmpl @@ -0,0 +1,114 @@ +start @user 2 +####################################################################### +# Wiki.js - CONFIGURATION # +####################################################################### +# Full documentation + examples: +# https://docs.requarks.io/install + +# --------------------------------------------------------------------- +# Port the server should listen to +# --------------------------------------------------------------------- + +port: 3000 + +# --------------------------------------------------------------------- +# Database +# --------------------------------------------------------------------- +# Supported Database Engines: +# - postgres = PostgreSQL 9.5 or later +# - mysql = MySQL 8.0 or later (5.7.8 partially supported, refer to docs) +# - mariadb = MariaDB 10.2.7 or later +# - mssql = MS SQL Server 2012 or later +# - sqlite = SQLite 3.9 or later + +db: + type: {{ getenv "DB_TYPE" "postgres" }} + # PostgreSQL / MySQL / MariaDB / MS SQL Server only: + host: {{ getenv "DB_HOST" }} + port: {{ getenv "DB_PORT" "5432" }} + user: {{ getenv "DB_USER" "wikijs" }} + pass: {{ getenv "DB_PASSWORD }} + db: {{ getenv "DB_NAME" "wikijs" }} + ssl: {{ getenv "DB_SSL" "false" }} + # SQLite only: + storage: /home/wikijs/data/db.sqlite + +####################################################################### +# ADVANCED OPTIONS # +####################################################################### +# Do not change unless you know what you are doing! + +# --------------------------------------------------------------------- +# SSL/TLS Settings +# --------------------------------------------------------------------- +# Consider using a reverse proxy (e.g. nginx) if you require more +# advanced options than those provided below. + +ssl: + enabled: false + + # Certificate format, either 'pem' or 'pfx': + format: pem + # Using PEM format: + key: path/to/key.pem + cert: path/to/cert.pem + # Using PFX format: + pfx: path/to/cert.pfx + # Passphrase when using encrypted PEM / PFX keys (default: null): + passphrase: null + # Diffie Hellman parameters, with key length being greater or equal + # to 1024 bits (default: null): + dhparam: null + + # Listen on this HTTP port and redirect all requests to HTTPS. + # Set to false to disable (default: 80): + redirectNonSSLPort: 80 + +# --------------------------------------------------------------------- +# Database Pool Options +# --------------------------------------------------------------------- +# Refer to https://github.com/vincit/tarn.js for all possible options + +pool: + # min: 2 + # max: 10 + +# --------------------------------------------------------------------- +# IP address the server should listen to +# --------------------------------------------------------------------- +# Leave 0.0.0.0 for all interfaces + +bindIP: 0.0.0.0 + +# --------------------------------------------------------------------- +# Log Level +# --------------------------------------------------------------------- +# Possible values: error, warn, info (default), verbose, debug, silly + +logLevel: info + +# --------------------------------------------------------------------- +# Upload Limits +# --------------------------------------------------------------------- +# If you're using a reverse-proxy in front of Wiki.js, you must also +# change your proxy upload limits! + +uploads: + # Maximum upload size in bytes per file (default: 5242880 (5 MB)) + maxFileSize: {{ getenv "MAX_FILE_SIZE" "5242880" }} + # Maximum file uploads per request (default: 20) + maxFiles: {{ getenv "MAX_FILES_PER_REQUEST" "20" }} + +# --------------------------------------------------------------------- +# Offline Mode +# --------------------------------------------------------------------- +# If your server cannot access the internet. Set to true and manually +# download the offline files for sideloading. + +offline: false + +# --------------------------------------------------------------------- +# Data Path +# --------------------------------------------------------------------- +# Writeable data path for Wiki.js, mainly for cache and user uploads. +dataPath: /home/wikijs/data diff --git a/rootfs/etc/fix-attrs.d/01-wikijs b/rootfs/etc/fix-attrs.d/01-wikijs new file mode 100644 index 0000000..c0cd45d --- /dev/null +++ b/rootfs/etc/fix-attrs.d/01-wikijs @@ -0,0 +1 @@ +/home/wikijs/data true wikijs 0640 0750 diff --git a/rootfs/etc/services.d/wikijs/run b/rootfs/etc/services.d/wikijs/run new file mode 100644 index 0000000..af624d1 --- /dev/null +++ b/rootfs/etc/services.d/wikijs/run @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv sh + +cd /home/wikijs || exit +exec s6-setuidgid wikijs node server