From d5c90af8094bb79c630628083329a3efc05f87a3 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 8 Oct 2020 10:20:14 +0200 Subject: [PATCH 1/5] Allow nodejs build process to use a lower RAM value Signed-off-by: Thomas Citharel --- docs/administration/index.md | 4 ++-- docs/administration/upgrading.md | 5 +++++ js/vue.config.js | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/administration/index.md b/docs/administration/index.md index b8325599..f30ce63c 100644 --- a/docs/administration/index.md +++ b/docs/administration/index.md @@ -77,9 +77,9 @@ yarn install Finally, we can build the front-end (this can take a few seconds). !!! warning - Building front-end can consume up to 512MB of RAM by default. If it's too much or not sufficient for your setup, you can adjust the maximum memory used by prefixing the command with the following option: + Building front-end can consume up to 2048MB of RAM by default. If it's too much or not sufficient for your setup, you can adjust the maximum memory used by prefixing the command with the following option: ``` - NODE_OPTIONS=--max_old_space_size=4096 + NODE_BUILD_MEMORY=1024 ``` ```bash yarn run build diff --git a/docs/administration/upgrading.md b/docs/administration/upgrading.md index 7a0d06ec..2d03cb29 100644 --- a/docs/administration/upgrading.md +++ b/docs/administration/upgrading.md @@ -50,6 +50,11 @@ yarn install ``` ### Rebuild Mobilizon's front-end +!!! warning + Building front-end can consume up to 2048MB of RAM by default. If it's too much or not sufficient for your setup, you can adjust the maximum memory used by prefixing the command with the following option: + ``` + NODE_BUILD_MEMORY=1024 + ``` ```bash yarn run build cd ../ diff --git a/js/vue.config.js b/js/vue.config.js index e1ddbb83..7ed74eb1 100644 --- a/js/vue.config.js +++ b/js/vue.config.js @@ -1,10 +1,30 @@ const path = require("path"); +const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); module.exports = { runtimeCompiler: true, lintOnSave: true, filenameHashing: true, outputDir: path.resolve(__dirname, "../priv/static"), + configureWebpack: (config) => { + // Limit the used memory when building + // SourceĀ : https://stackoverflow.com/a/55810460/10204399 + // get a reference to the existing ForkTsCheckerWebpackPlugin + const existingForkTsChecker = config.plugins.filter( + (p) => p instanceof ForkTsCheckerWebpackPlugin + )[0]; + + // remove the existing ForkTsCheckerWebpackPlugin + // so that we can replace it with our modified version + config.plugins = config.plugins.filter((p) => !(p instanceof ForkTsCheckerWebpackPlugin)); + + // copy the options from the original ForkTsCheckerWebpackPlugin + // instance and add the memoryLimit property + const forkTsCheckerOptions = existingForkTsChecker.options; + forkTsCheckerOptions.memoryLimit = process.env.NODE_BUILD_MEMORY || 2048; + + config.plugins.push(new ForkTsCheckerWebpackPlugin(forkTsCheckerOptions)); + }, // configureWebpack: { // optimization: { // splitChunks: { From ca79f4dba0ae1f9afd0bc94168e5e67e8d8b8dfa Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 8 Oct 2020 10:20:46 +0200 Subject: [PATCH 2/5] Add FAQ for server requirements Signed-off-by: Thomas Citharel --- docs/administration/faq.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/administration/faq.md diff --git a/docs/administration/faq.md b/docs/administration/faq.md new file mode 100644 index 00000000..8fb2716d --- /dev/null +++ b/docs/administration/faq.md @@ -0,0 +1,34 @@ +--- +title: FAQ +--- + +# FAQ + +## Should I have a big server to run Mobilizon? + + +Not really. Being written in Elixir, Mobilizon doesn't need much resources once it's running. If you plan to open your instance to the public, plan in advance higher values for the following given requirements. + +!!! note + If you plan to self-host a address/geocoding server as well, [the requirements are quite on another level](./configure/geocoders.md). + +
+
CPU
+
One should be enough +

Depending on your number of users and instances you federate with, extra CPUs will be helpful.

+
+ +
RAM
+
+ 512MB should be enough for Mobilizon, Nginx and PostgreSQL +

Mobilizon will use at least around ~256MB and PostgreSQL and nginx can use ~20MB. Extra memory can improve tasks like compiling and building dependencies.

+
+ +
Storage
+
Depends how many users and events you have +

A little space will be needed for Mobilizon and it's dependencies (damn you node_modules) themselves. Otherwise, storage usage will grow mostly with user's profile pics and pictures associated to events. Also the PostgreSQL database can start to weigh a bit after a while, depending on how many events you create and how many other instances you follow.

+
+ +
Bandwidth
+
Any bandwidth will do, but higher numbers will improve the experience for users and will help federation.
+
\ No newline at end of file From 2d4431072b4c1ae198c92e8ebb2aa12c5177f069 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 8 Oct 2020 10:22:30 +0200 Subject: [PATCH 3/5] Change France to Europe in geocoders.md Signed-off-by: Thomas Citharel --- docs/administration/configure/geocoders.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/administration/configure/geocoders.md b/docs/administration/configure/geocoders.md index 13915aaf..f4ba9916 100644 --- a/docs/administration/configure/geocoders.md +++ b/docs/administration/configure/geocoders.md @@ -8,7 +8,10 @@ This is needed to set correct address for events, and more easily find events wi However, providing a geocoding service is quite expensive, especially if you want to cover the whole Earth. !!! note "Hardware setup" - To give an idea of what hardware is required to self-host a geocoding service, we successfully installed and used [Addok](#addok), [Pelias](#pelias) and [Mimirsbrunn](#mimirsbrunn) on a 8 cores/16GB RAM machine without any issues **importing only French addresses and data**. + To give an idea of what hardware is required to self-host a geocoding service, we successfully installed and used [Addok](#addok), [Pelias](#pelias) and [Mimirsbrunn](#mimirsbrunn) on a 8 cores/16GB RAM machine without any issues **importing only European addresses and data**. + +!!! tip "Advised provider" + We had best results using the [Pelias](#pelias) geocoding provider. ## Change geocoder From ed4042ed1e8c0825eaf7c53df49db765784d303d Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 8 Oct 2020 10:41:30 +0200 Subject: [PATCH 4/5] Fix injecting metadata into HTML pages Signed-off-by: Thomas Citharel --- lib/web/views/utils.ex | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/web/views/utils.ex b/lib/web/views/utils.ex index 5fd5417d..950efcd5 100644 --- a/lib/web/views/utils.ex +++ b/lib/web/views/utils.ex @@ -18,11 +18,8 @@ defmodule Mobilizon.Web.Views.Utils do end @spec replace_meta(String.t(), String.t()) :: String.t() - # TODO: Find why it's different in dev/prod and during tests defp replace_meta(index_content, tags) do - index_content - |> String.replace("", tags) - |> String.replace("", tags) + String.replace(index_content, "", tags) end @spec do_replacements(String.t(), String.t(), String.t()) :: {:safe, String.t()} @@ -30,7 +27,6 @@ defmodule Mobilizon.Web.Views.Utils do index_content |> replace_meta(tags) |> String.replace("", "") - |> String.replace("", "") |> (&{:safe, &1}).() end From ed6964de31e49fe45059bfcf9e162885c2b5c0a6 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 8 Oct 2020 11:40:13 +0200 Subject: [PATCH 5/5] Rollback to ex_vcr 11.2 https://github.com/parroty/exvcr/issues/159 causes issues with other Mocks Signed-off-by: Thomas Citharel --- mix.exs | 2 +- mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index e2c66239..59742d3f 100644 --- a/mix.exs +++ b/mix.exs @@ -144,7 +144,7 @@ defmodule Mobilizon.Mixfile do {:mix_test_watch, "~> 1.0", only: :dev, runtime: false}, {:ex_unit_notifier, "~> 0.1", only: :test}, {:dialyxir, "~> 1.0.0", only: [:dev], runtime: false}, - {:exvcr, "~> 0.10", only: :test}, + {:exvcr, "0.11.2", only: :test}, {:credo, "~> 1.4.0", only: [:dev, :test], runtime: false}, {:mock, "~> 0.3.4", only: :test}, {:elixir_feed_parser, "~> 2.1.0", only: :test}, diff --git a/mix.lock b/mix.lock index bc234d54..4ebbdb12 100644 --- a/mix.lock +++ b/mix.lock @@ -51,7 +51,7 @@ "excoveralls": {:hex, :excoveralls, "0.13.2", "5ca05099750c086f144fcf75842c363fc15d7d9c6faa7ad323d010294ced685e", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1e7ed75c158808a5a8f019d3ad63a5efe482994f2f8336c0a8c77d2f0ab152ce"}, "exgravatar": {:hex, :exgravatar, "2.0.2", "638412896170409da114f98947d3f8d4f38e851b0e329c1cc4cd324d5e2ea081", [:mix], [], "hexpm", "f3deb5baa6fcf354a965d794ee73a956d95f1f79f41bddf69800c713cfb014a1"}, "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "32e95820a97cffea67830e91514a2ad53b888850442d6d395f53a1ac60c82e07"}, - "exvcr": {:hex, :exvcr, "0.12.0", "0a0b93b09590c0885bf798ef9959118a2c35ccd472e0a817398af8dfee1fd654", [:mix], [{:exactor, "~> 2.2", [hex: :exactor, repo: "hexpm", optional: false]}, {:exjsx, "~> 4.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:httpoison, "~> 1.0", [hex: :httpoison, repo: "hexpm", optional: true]}, {:httpotion, "~> 3.1", [hex: :httpotion, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:meck, "~> 0.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "72189ff6d64151987ea548f7efd953bf383379c7ff7cfca7ddbd4832238d53cc"}, + "exvcr": {:hex, :exvcr, "0.11.2", "24aec6ad13a659f10591911089c01f8d2691e2fff75710c924b64437cc1b36a1", [:mix], [{:exactor, "~> 2.2", [hex: :exactor, repo: "hexpm", optional: false]}, {:exjsx, "~> 4.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:httpoison, "~> 1.0", [hex: :httpoison, repo: "hexpm", optional: true]}, {:httpotion, "~> 3.1", [hex: :httpotion, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.4", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:meck, "~> 0.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "0dad8a3065af4040933bc3ec296f28654b04e993a81054199c832fa86329e80f"}, "fast_html": {:hex, :fast_html, "2.0.4", "4910ee49f2f6b19692e3bf30bf97f1b6b7dac489cd6b0f34cd0fe3042c56ba30", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}], "hexpm", "3bb49d541dfc02ad5e425904f53376d758c09f89e521afc7d2b174b3227761ea"}, "fast_sanitize": {:hex, :fast_sanitize, "0.2.2", "3cbbaebaea6043865dfb5b4ecb0f1af066ad410a51470e353714b10c42007b81", [:mix], [{:fast_html, "~> 2.0", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "69f204db9250afa94a0d559d9110139850f57de2b081719fbafa1e9a89e94466"}, "file_info": {:hex, :file_info, "0.0.4", "2e0e77f211e833f38ead22cb29ce53761d457d80b3ffe0ffe0eb93880b0963b2", [:mix], [{:mimetype_parser, "~> 0.1.2", [hex: :mimetype_parser, repo: "hexpm", optional: false]}], "hexpm", "50e7ad01c2c8b9339010675fe4dc4a113b8d6ca7eddce24d1d74fd0e762781a5"},