Saltcorn is an extensible open source no-code database application builder. Use it to build web applications based on relational data with flexible views, datatypes and layouts.
This repository contains the core codebase, including the code necessary to self-host an instance and to host a multitenant instance.
A multitenant instance of Saltcorn is running at saltcorn.com, and you can create a new application under a subdomain at https://saltcorn.com/tenant/create. This service is free but there are no guarantees about the security or availability of your application or the information you are storing. This service should only be used to explore the capabilities of saltcorn.
For self-hosting, a 1 GB virtual private server is sufficient to run Saltcorn unless you expect high traffic volumes. Installation instructions are given below. If hosting on DigitalOcean, which offers a 1GB virtual machine for $5 per month, please consider using my referral code which will give you $100 credit over 60 days.
Saltcorn is using PostgreSQL, node.js, node-postgres, express, live-plugin-manager, craft.js, jQuery-Menu-Editor, Blockly, CodeMirror and other awesome free and open source projects.
You can run a local instance for quick testing by running the following command:
cd ./deploy/examples/test && docker-compose up -d
and then go to http://localhost:3000 in your web browser.
NOTE: The dependencies to build mobile apps are quite large, they are not installed in the standard docker image (saltcorn/saltcorn). To use an image that includes the mobile dependencies as well, either use 'saltcorn/saltcorn-with-mobile' directly or replace 'saltcorn/saltcorn' with 'saltcorn/saltcorn-with-mobile' in the docker-compose file.
This has been tested on Debian 10, 11 and 12, Ubuntu 18.04, 20.04 and 22.04, OpenSuSE, AlmaLinux, and Fedora. All you need is to run these three lines on the command line shell, as root or as a user with sudo access:
wget -qO - https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt-get install -qqy nodejs
npx saltcorn-install -y
The first two lines will install Node.js 16 (you can also use 18 or 20). The last line will call the Saltcorn install script accepting all the defaults, which installs PostgreSQL and sets up Saltcorn as a service listening on port 80.
If you want a different port, different database backend, or to not install as a service, you
can omit the final -y
to get an interactive installation:
wget -qO - https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt-get install -qqy nodejs
npx saltcorn-install
Instructions have been tested on Ubuntu 20.04 on a 1GB VM.
TL;DR: npm install -g @saltcorn/cli && saltcorn setup
For a recent version (v16) of Node.js:
wget -qO - https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs libpq-dev build-essential python-is-python3
You can also use Node 18 or 20.
npm install -g @saltcorn/cli
If this fails, you may need to tell npm to disregard file permissions during compilation:
npm install -g @saltcorn/cli --unsafe
Sometimes, the above commands fail to install the library sd-notify
(which is useful for
integrating with systemd) even though it is installable. You can rectify that by installing
it subsequently:
npm install -g sd-notify
if you are root
, create a user with sudo and switch to that user:
adduser saltcorn
adduser saltcorn sudo
su saltcorn
cd
mkdir -p ~/.config/
then run
saltcorn setup
and follow the instructions given.
NOTE: this is somewhat out of date; see instead https://wiki.saltcorn.com/view/ShowPage?title=Install%20on%20Ubuntu, in paticular the last section.
Skip this section if you ran saltcorn setup
or npx saltcorn-install
-
Install PostgreSQL:
sudo apt install postgresql postgresql-client
-
Either,
-
Create a JSON file
.saltcorn
in your XDG config directory (on Ubuntu this is normally $HOME/.config) with these values:host
: address of PostgreSQL serverport
: port of PostgreSQL serverdatabase
: PostgreSQL databaseuser
: PostgreSQL user namepassword
: PostgreSQL user passwordsslmode
: PostgreSQL SSL Modesslcert
: PostgreSQL SSL Certificatesslkey
: PostgreSQL SSL Keysslrootcert
: PostgreSQL SSL Root Certificatesession_secret
: Saltcorn session secretmulti_tenant
: run as multi-tenant (true/false)
For example:
{ "host":"localhost", "port":5432, "database":"saltcorn", "user":"tomn", "password":"dgg2342vfB", "session_secret":"hrh64b45b3", "multi_tenant":true }
Or,
-
Set environment variables.
SALTCORN_SESSION_SECRET
,SALTCORN_MULTI_TENANT
(defaults tofalse
), and eitherDATABASE_URL
orPGHOST
,PGPORT
,PGUSER
,PGDATABASE
,PGPASSWORD
. You can also setPGSSLMODE
,PGSSLCERT
,PGSSLKEY
,PGSSLROOTCERT
(see Postgres Documentation)
-
saltcorn serve
Installing saltcorn as a service will mean it runs in the background and restarts automatically if the system reboots.
create a file /lib/systemd/system/saltcorn.service
with these contents:
[Unit]
Description=saltcorn
Documentation=https://saltcorn.com
After=network.target
[Service]
Type=notify
WatchdogSec=5
User=saltcorn
WorkingDirectory=/home/saltcorn
ExecStart=/home/saltcorn/.local/bin/saltcorn serve -p 80
Restart=always
Environment="NODE_ENV=production"
[Install]
WantedBy=multi-user.target
run:
sudo systemctl daemon-reload
sudo systemctl start saltcorn
sudo systemctl enable saltcorn
This may be in a different location in non-Debian systems, e.g. in /etc/systemd/system
instead.
In order to allow the saltcorn
user to open port 80, you need to permission node.js to allow
this by running:
sudo setcap 'cap_net_bind_service=+ep' `which node`
Use Let's Encrypt or Cloudflare to get a free SSL certificate (for https).
sudo apt install nodejs npm libpq-dev
will give you a usable version. For a more recent version (v16) of Node.js:
wget -qO - https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs libpq-dev
assuming you have cloned this repository to $HOME/saltcorn (otherwise adjust PATH)
npm config set prefix ~/.local
echo 'export PATH=$HOME/saltcorn/packages/saltcorn-cli/bin:$HOME/.local/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
run
npm install --legacy-peer-deps
npm run tsc
to install everything. If successful, you should now be able to run saltcorn
in your shell.
NOTE: the installation builds the 'saltcorn/cordova-builder' docker image, and the first build takes several minutes. You can set the environment variable SKIP_DOCKER_IMAGE_INSTALL to 'true' (or disable docker) if you don't want to build it.
- @saltcorn-cli: command-line interface
we use prettier:
npm install -g prettier
to format code:
git ls-files | grep -v builder_bundle | xargs prettier --write
Run this before every pull request.
nodemon packages/saltcorn-cli/bin/saltcorn serve
to also watch a local module
nodemon --watch ../saltcorn-kanban/ packages/saltcorn-cli/bin/saltcorn serve
cd packages/saltcorn-builder
npm install
npm install styled-components@4.4.1
npm run build
in saltcorn/packages/saltcorn-builder/
run:
git ls-files | entr npm run builddev
but this is not a production build, so run
npm run build
when done.
If you get this error: Error: error:0308010C:digital envelope routines::unsupported
,
run this and try again: export NODE_OPTIONS=--openssl-legacy-provider
.
npm install --legacy-peer-deps
npm run tsc
then
npm run docs
TSDocs will then be available in docs/
.
To deploy these to https://saltcorn.github.io/tsdocs/:
cp -R docs/* /path/to/tsdocs
cd /path/to/tsdocs
git add .
git commit -am 'version number or other message...'