Standard Notes Server Without Docker
YOU CAN DEPLOY StandardNotes SERVER WITHOUT ANY DOCKER NONSENSE!
On production use like SN public server, containerization is good, that sweet sweet horizontal scaling! -- but for selfhoster/monolithic system, in some circumstances, problem might be arise if you cannot use docker for some obvious reason: * using OpenVZ VPS * on limited resource SBCs like Raspberry Pi * you just in love/hate relationship with docker :| * or you want to install SN on shared hosting env like cPanel (Yes, you can! this is what I do)
...and its a bit problematic if your system is limited on storage - as working code base of all SN service + the respective node_modules use up to >800MB (we'll tackle this soon!)
Let's get started!
Intro : Standard Notes is open source (consider donate/buy their pro subs ;) ) so everything you need to selfhost is on their repos
"Dockerize" SN server instance is consist of 3 (three) important services: 1. auth server 2. syncing server 3. api gateway server 4. Plus, you need mysql and redis
these services are normally run on dockerize env. api-gateway as the name suggest, is the service that proxied auth and syncing request, also API call chore request from SN client.
Standard Notes is written in Typescript, It's just Javascript with turbocharger attached. So it's not a big deal as long your intended system can install node.
As I emphisize this before, I got an idea to install SN on my shared hosting with only 1 GB disk and 256 MB allocated RAM. I'm confident this is possible on limited compute resource as I assume notes saving/syncing server is not that resource and logic intensive. Also, nowadays shared hosting with cpanel can make use of javascript/node app instead of php -- this feature may vary depending on your host provider. For you that want to make use of these cheap SBCs can also achieve what I done here easily!
What I do
After identifying what is needed to run SN, I clone these repos
(auth,syncing, and api-gateway) to one folder for easily organize
things.
For each services, you want to checkout to latest version suggested by
devs or just checkout to branch main (see standalone/docker-compose.yml)
Before compiling, install each repo dependency with npm install
For starters, you cannot directly execute Typescript code with node, you must compile it first. For this, you need tsc to compile Typescript to JS. If you using official VS Code, tsc is provided out of the box, for others you need to install it first using either npm install --save-dev typescript or globally npm install -g typescript (recommended)
To compile, just run tsc -p tsconfig.json on each repo,
or again if you using VS Code, use CTRL+SHIFT+B and select relevant
build option. Every successive compile will result with no errors/some
warning is okay, and populated dist/* folder.
On this step, you actually can move every services dist folder with their node_modules and .env
file to another folder, ship it to any device you want, and call it a
day. But, if you see, these 3 services with their node_modules ate
almost >800 MB on disk. This is not okay in my case of very limited
disk space.
Bundler to the rescue
Yes, we playing with JS and so we can benefit from all goodness of JS. JS bundler is one of them. https://github.com/evanw/esbuild/
NODE_OPTIONS --max-old-space-size
Related