From 878330916000e180b71f9e9206b55c4436de0654 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Wed, 12 Oct 2022 14:17:10 -0400 Subject: [PATCH 1/5] Add script for building & pushing image --- build-image.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 build-image.sh diff --git a/build-image.sh b/build-image.sh new file mode 100755 index 0000000..4b568a9 --- /dev/null +++ b/build-image.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +[ -z "$1" ] && exit 1 + +docker build $1 -t gitea.angry.im/petercxy/$1:latest +docker push gitea.angry.im/petercxy/$1:latest From 39c2cd3806977d14239d2e84bd8793c00533a93d Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Wed, 12 Oct 2022 14:31:18 -0400 Subject: [PATCH 2/5] Add standardnotes-web --- standardnotes-web/Dockerfile | 22 ++++++++++++++++++++++ standardnotes-web/start.sh | 7 +++++++ 2 files changed, 29 insertions(+) create mode 100644 standardnotes-web/Dockerfile create mode 100644 standardnotes-web/start.sh diff --git a/standardnotes-web/Dockerfile b/standardnotes-web/Dockerfile new file mode 100644 index 0000000..9d2e39e --- /dev/null +++ b/standardnotes-web/Dockerfile @@ -0,0 +1,22 @@ +FROM node:16-alpine AS builder + +ARG SN_TAG=@standardnotes/web@3.72.4 + +RUN apk add git + +RUN git clone --depth=1 https://github.com/standardnotes/app -b ${SN_TAG} + +RUN cd app && yarn install && yarn build:web + +FROM joseluisq/static-web-server:2-alpine + +ENV SN_WEB_PUBLIC_URL=https://app.standardnotes.com +ENV SN_WEB_DEFAULT_SYNC_SERVER=https://api.standardnotes.com +ENV SN_WEB_DEFAULT_FILES_HOST=https://files.standardnotes.com + +COPY --from=builder /app/packages/web/dist /public +COPY start.sh / + +RUN chmod +x /start.sh + +CMD [ "/start.sh" ] diff --git a/standardnotes-web/start.sh b/standardnotes-web/start.sh new file mode 100644 index 0000000..dbb894e --- /dev/null +++ b/standardnotes-web/start.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +sed -i "s@https://app.standardnotes.com@${SN_WEB_PUBLIC_URL}@g" /public/index.html +sed -i "s@https://api.standardnotes.com@${SN_WEB_DEFAULT_SYNC_SERVER}@g" /public/index.html +sed -i "s@https://files.standardnotes.com@${SN_WEB_DEFAULT_FILES_HOST}@g" /public/index.html + +exec static-web-server From 2a6cf5ad1efa9725e59d8ac965211b7f64186b71 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Wed, 12 Oct 2022 14:36:51 -0400 Subject: [PATCH 3/5] standardnotes-web: Disable cache-control headers from inside the container --- standardnotes-web/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/standardnotes-web/Dockerfile b/standardnotes-web/Dockerfile index 9d2e39e..1e245df 100644 --- a/standardnotes-web/Dockerfile +++ b/standardnotes-web/Dockerfile @@ -19,4 +19,7 @@ COPY start.sh / RUN chmod +x /start.sh +# Disable cache-control headers sent by the container +ENV SERVER_CACHE_CONTROL_HEADERS=false + CMD [ "/start.sh" ] From 4405048014c57c48ed52aae4c612ff9dc4f8fbbd Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Wed, 12 Oct 2022 14:37:50 -0400 Subject: [PATCH 4/5] standardnotes-web: Override metadata from static-web-server --- standardnotes-web/Dockerfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/standardnotes-web/Dockerfile b/standardnotes-web/Dockerfile index 1e245df..e703d39 100644 --- a/standardnotes-web/Dockerfile +++ b/standardnotes-web/Dockerfile @@ -23,3 +23,10 @@ RUN chmod +x /start.sh ENV SERVER_CACHE_CONTROL_HEADERS=false CMD [ "/start.sh" ] + +LABEL org.opencontainers.image.vendor="Standard Notes" \ + org.opencontainers.image.url="https://github.com/standardnotes" \ + org.opencontainers.image.title="Standard Notes Web App" \ + org.opencontainers.image.description="An encrypted note-taking app" \ + org.opencontainers.image.version="${SN_TAG}" \ + org.opencontainers.image.documentation="https://github.com/standardnotes" From f602e6741379aac3df5e31d2052f5b9fa0678408 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Wed, 12 Oct 2022 14:58:36 -0400 Subject: [PATCH 5/5] Add customized element-web build files --- element-web/Dockerfile | 19 +++++++++ element-web/custom_config.js | 82 ++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 element-web/Dockerfile create mode 100644 element-web/custom_config.js diff --git a/element-web/Dockerfile b/element-web/Dockerfile new file mode 100644 index 0000000..8ddbe30 --- /dev/null +++ b/element-web/Dockerfile @@ -0,0 +1,19 @@ +ARG ELEMENT_VER=v1.11.10 + +FROM debian:11 AS builder + +ARG ELEMENT_VER + +RUN apt-get update && apt-get install -y nodejs curl git + +ADD custom_config.js / + +RUN cd / && curl -k -L "https://raw.githubusercontent.com/vector-im/element-web/${ELEMENT_VER}/config.sample.json" > config.sample.json \ + && git clone --depth=1 https://github.com/aaronraimist/element-themes \ + && node custom_config.js | tee config.json + +FROM vectorim/element-web:${ELEMENT_VER} + +ARG ELEMENT_VER + +COPY --from=builder /config.json /app/config.json diff --git a/element-web/custom_config.js b/element-web/custom_config.js new file mode 100644 index 0000000..d9f9d76 --- /dev/null +++ b/element-web/custom_config.js @@ -0,0 +1,82 @@ +#!/usr/bin/node +const child_process = require('child_process'); +const fs = require('fs'); + +config = require("./config.sample.json"); +config["default_server_config"]["m.homeserver"] = { + "base_url": "https://neo.angry.im", + "server_name": "neo.angry.im" +}; +config["integrations_ui_url"] = "https://dimension.angry.im/element"; +config["integrations_rest_url"] = "https://dimension.angry.im/api/v1/scalar"; +config["integrations_widgets_urls"] = ["https://dimension.angry.im/widgets"]; +config["room_directory"]["servers"] = [ "matrix.org", "neo.angry.im", "mozilla.modular.im", "feneas.org", "chat.privacytools.io" ]; +config["enable_presence_by_hs_url"] = { + "https://matrix.org": false, + "https://matrix-client.matrix.org": false, + "https://neo.angry.im": false +}; +config["cross_origin_renderer_url"] = "https://riotcontent.angry.im/v1.html"; +config["features"]["feature_custom_themes"] = "labs"; +config["show_labs_settings"] = true; + +// Themes +config["setting_defaults"]["custom_themes"] = []; + +const theme_files = child_process.execSync("find element-themes -name '*.json'").toString().split("\n"); + +for (const file of theme_files) { + if (file === "") continue; + + try { + const data = JSON.parse(fs.readFileSync(file)); + config["setting_defaults"]["custom_themes"].push(data); + } catch (err) { + // Nothing + } +} + +// my custom themes +config["setting_defaults"]["custom_themes"].push( + { + "name": "Gruvbox Dark", + "is_dark": true, + "colors": { + "accent-color": "#ebdbb2", + "primary-color": "#ebdbb2", + "warning-color": "#fb4934", + "sidebar-color": "#3c3836", + "roomlist-background-color": "#282828", + "roomlist-text-color": "#ebdbb2", + "roomlist-text-secondary-color": "#d5c4a1", + "roomlist-highlights-color": "#665c54", + "roomlist-separator-color": "#504945", + "timeline-background-color": "#282828", + "timeline-text-color": "#ebdbb2", + "secondary-content": "#d5c4a1", + "tertiary-content": "#bdae93", + "timeline-text-secondary-color": "#d5c4a1", + "timeline-highlights-color": "#665c54", + "reaction-row-button-selected-bg-color": "#bdae93", + "username-colors": [ + "#fb4934", + "#b8bb26", + "#fabd2f", + "#83a598", + "#d3869b", + "#8ec07c", + "#fe8019", + "#ebdbb2" + ], + "avatar-background-colors": [ + "#d3869b", + "#8ec07c", + "#83a598" + ] + } + } +); + +delete config["piwik"] + +console.log(JSON.stringify(config, null, 4))