1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-15 01:28:30 +00:00

Resolve "Add MJML installation instructions in the Ubuntu Installation tutorial."

This commit is contained in:
Nigel Gott 2021-08-06 11:52:05 +00:00
parent 2c3645cf93
commit b7b2039c83
7 changed files with 162 additions and 21 deletions

2
.gitignore vendored
View file

@ -100,3 +100,5 @@ venv/
web-frontend/plugins/
backend/plugins/
.vagrant/

View file

@ -18,6 +18,8 @@
* Hide view types that can't be exported in the export modal.
* Relaxed the URL field validator and made it consistent between the backend and
web-frontend.
* Fixed nuxt not restarting correctly using the provided Baserow supervisor config file.
* Added steps on how to configure Baserow to send emails in the install-on-ubuntu guide.
## Released (2021-07-16)

35
deploy/vagrant/README.md Normal file
View file

@ -0,0 +1,35 @@
# Vagrant Baserow Ubuntu Install Test
This folder contains a vagrant file and bootstrap.sh which together will start up a
local Ubuntu 18.04 virtual machine with Baserow installed and working. To do this it
extracts the bash from the install-on-ubuntu.md guide and runs it in a fresh new VM.
> WARNING: Using this vagrant setup is currently intended only for local testing and
> development.
## How to run
1. Install virtualbox - https://www.virtualbox.org/wiki/Downloads
1. Install vagrant - https://www.vagrantup.com/downloads
1. `cd tests/vagrant_ubuntu_install`
1. Install required vagrant plugins:
1. `vagrant plugin install landrush`
1. Used to setup a local dns server so you can visit Baserow using a domain
1. `vagrant plugin install vagrant-vbguest`
1. So we can mount in your local baserow repo and use that to install Baserow
1. `vagrant vbguest`
1. On Ubuntu I had to follow the instructions
in https://github.com/vagrant-landrush/landrush/blob/master/doc/Usage.adoc#visibility-on-the-host
1. Also see https://gist.github.com/neuroticnerd/30b12648a933677ad2c4 for more
landrush dns tips.
1. Change the branch found at the end of line 6 in the Vagrantfile to be the branch you
want to test.
1. `vagrant up`
1. You might need to interactively enter your password for the landrush dns plugin
to successfully add local dns entries on your host for Baserow running inside the
vm.
1. Wait a long time for everything to be provisioned
1. Once done visit [http://baserow.vagrant.test](http://baserow.vagrant.test) on your
host machine to see the Baserow running inside the vm.
1. Run `vagrant ssh` to ssh into the VM and make changes, inspect the logs, restart
services etc.

15
deploy/vagrant/Vagrantfile vendored Normal file
View file

@ -0,0 +1,15 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provision :shell, path: "bootstrap.sh"
config.vm.network "private_network", ip: "192.168.68.10"
config.landrush.enabled = true
config.vm.hostname = "baserow.vagrant.test"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
config.vm.synced_folder "../../", "/local_baserow_repo"
end

View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euox pipefail
apt-get update
apt-get install git -y
cd ~
cp /local_baserow_repo/docs/guides/installation/install-on-ubuntu.md install-on-ubuntu.md
# Process the guide to only extract the bash we want
sed -n '/## HTTPS \/ SSL Support/q;p' install-on-ubuntu.md | # We don't want to setup https or do any upgrade scripts which follow
sed -n '/^```bash$/,/^```$/p' | # Extract bash code from markdown code blocks
sed '/^```/ d' | # Get rid of the backticks left in by the previous sed
sed 's/^\$ //' | # Get rid of the bash command $ prefixes
sed 's/^sudo passwd baserow/echo -e "yourpassword\nyourpassword" | sudo passwd baserow/' | # Enter a password non interactively
sed "s/git clone --branch master.*/cp -r \/local_baserow_repo baserow/" | # Copy your local repo over instead of checking out master
sed 's/https:\\\/\\\/api.domain.com/http:\\\/\\\/api.baserow.vagrant.test/g' | # Fixup the sed commands for the URL env vars
sed 's/https:\\\/\\\/baserow.domain.com/http:\\\/\\\/baserow.vagrant.test/g' |
sed 's/https:\\\/\\\/media.domain.com/http:\\\/\\\/media.baserow.vagrant.test/g' |
sed 's/api.domain.com/api.baserow.vagrant.test/g' | # Fixup the sed commands for the ngnix config
sed 's/baserow.domain.com/baserow.vagrant.test/g' |
sed 's/media.domain.com/media.baserow.vagrant.test/g' > install-on-ubuntu.sh
# Prepend with some bash settings so we can see the output and it will fail if something
# crashes.
# We dont set -u here due to problems with it using an old virtualenv and PS1 not being
# set. See https://stackoverflow.com/questions/42997258/virtualenv-activate-script-wont-run-in-bash-script-with-set-euo
echo -e "set -eox pipefail\n$(cat install-on-ubuntu.sh)" > install-on-ubuntu.sh
# TODO Figure out the right sudo su incantation to run this as a normal user with sudo
bash install-on-ubuntu.sh

View file

@ -6,11 +6,12 @@ environment =
DATABASE_PASSWORD='yourpassword',
SECRET_KEY='SOMETHING_SECRET',
PRIVATE_BACKEND_URL='http://localhost:8000',
PUBLIC_WEB_FRONTEND_URL='https://FRONTEND_DOMAIN',
PUBLIC_BACKEND_URL='https://BACKEND_DOMAIN',
PUBLIC_WEB_FRONTEND_URL='*YOUR_WEB_FRONTEND_DOMAIN*',
PUBLIC_BACKEND_URL='*YOUR_BACKEND_DOMAIN*',
MEDIA_ROOT='/baserow/media',
MEDIA_URL='https://MEDIA_DOMAIN',
REDIS_HOST='localhost'
MEDIA_URL='*YOUR_MEDIA_DOMAIN*',
REDIS_HOST='localhost',
MJML_SERVER_HOST='localhost'
[program:gunicorn]
command = /baserow/env/bin/gunicorn -w 5 -b 127.0.0.1:8000 -k uvicorn.workers.UvicornWorker baserow.config.asgi:application --log-level=debug --chdir=/baserow
@ -35,7 +36,7 @@ stderr_logfile=/var/log/baserow/exportworker.error
[program:nuxt]
directory=/baserow/baserow/web-frontend
command=sh -c './node_modules/.bin/nuxt start --hostname 127.0.0.1 --config-file ./config/nuxt.config.local.js'
command=node ./node_modules/.bin/nuxt start --hostname 127.0.0.1 --config-file ./config/nuxt.config.local.js
stdout_logfile=/var/log/baserow/frontend.log
stderr_logfile=/var/log/baserow/frontend.error
@ -46,3 +47,16 @@ stderr_logfile=/var/log/baserow/nginx.error
autostart=true
autorestart=true
numprocs=1
[program:mjmltcpserver]
user=root
environment=NODE_PATH=/baserow/mjml_install/node_modules/
command=node
/baserow/env/lib/python3.7/site-packages/mjml/node/tcpserver.js
--port=28101 --host=127.0.0.1 --touchstop=/tmp/mjmltcpserver.stop --mjml.minify=true --mjml.validationLevel=strict
stdout_logfile=/var/log/baserow/mjml.log
autostart=true
autorestart=true
redirect_stderr=true
stopwaitsecs=10
stopsignal=INT

View file

@ -31,16 +31,15 @@ are new to firewalls.
Baserow uses PostgreSQL in order to store its user data. You can install PostgreSQL
with the following commands:
```
```bash
$ sudo apt install postgresql postgresql-contrib -y
$ sudo -u postgres psql
postgres=# create database baserow;
CREATE DATABASE
postgres=# create user baserow with encrypted password 'yourpassword';
CREATE ROLE
postgres=# grant all privileges on database baserow to baserow;
GRANT
postgres=# \q
# Make sure you replace 'yourpassword' below with a secure password for your database
# user.
$ sudo -u postgres psql << EOF
create database baserow;
create user baserow with encrypted password 'yourpassword';
grant all privileges on database baserow to baserow;
EOF
```
Make sure that you use a secure password instead of `yourpassword`! Also take care that
@ -52,7 +51,7 @@ baserow user password.
Baserow uses Redis for asynchronous tasks and the real time collaboration. You can
install Redis with the following commands.
```
```bash
$ sudo add-apt-repository ppa:chris-lea/redis-server
$ sudo apt update
$ sudo apt install redis-server -y
@ -69,7 +68,7 @@ Git is required to download the source code of Baserow so you can install it in
following section. Curl will be required later in the guide to install nodejs.
Install them both using the following command:
```
```bash
$ sudo apt install git curl -y
```
@ -82,8 +81,8 @@ In this section, we will install Baserow itself. We will need a new user called
# Create baserow user
$ sudo useradd baserow
$ sudo passwd baserow
Enter new UNIX password: yourpassword
Retype new UNIX password: yourpassword
# Enter new UNIX password: yourpassword
# Retype new UNIX password: yourpassword
# Change to root user
$ sudo -i
@ -220,6 +219,23 @@ $ baserow sync_templates
$ deactivate
```
## Install MJML used to generate email bodies
Baserow sends invite and password reset emails to users. To do this it uses a technology
called MJML which generates the email bodies from a template. For email sending to work
in Baserow you will need to install and set up an MJML server by following the steps
below:
```bash
$ mkdir mjml_install
$ cd mjml_install
$ npm init -y && npm install mjml
$ cd /baserow
```
You will then later on need to set the environment variables discussed in the
Email SMTP configuration section to get Baserow sending emails.
## Install & Configure Supervisor
Supervisor is an application that starts and keeps track of processes and will restart
@ -242,7 +258,8 @@ $ cp baserow/docs/guides/installation/configuration-files/supervisor.conf /etc/s
You will need to edit the `baserow.conf` file (located now at
`/etc/supervisor/conf.d/`) in order to set the necessary environment
variables. You will need to change at least the following variables which can be found
in the `environment=` section.
in the `environment=` section. Ensure these URL variables start with http:// or https://
.
- `PUBLIC_WEB_FRONTEND_URL`: The URL under which your frontend can be reached from the
internet.
@ -250,6 +267,13 @@ in the `environment=` section.
internet.
- `MEDIA_URL`: The URL under which your media files can be reached from the internet.
You can make the modifications using sed like so:
```bash
$ sed -i 's/\*YOUR_BACKEND_DOMAIN\*/https:\/\/api.domain.com/g' /etc/supervisor/conf.d/baserow.conf
$ sed -i 's/\*YOUR_WEB_FRONTEND_DOMAIN\*/https:\/\/baserow.domain.com/g' /etc/supervisor/conf.d/baserow.conf
$ sed -i 's/\*YOUR_MEDIA_DOMAIN\*/https:\/\/media.domain.com/g' /etc/supervisor/conf.d/baserow.conf
```
**Backend**
- `SECRET_KEY`: The secret key that is used to generate tokens and other random
@ -261,6 +285,24 @@ in the `environment=` section.
- `DATABASE_HOST`: The host computer that runs the database (usually `localhost`)
- `REDIS_HOST`: The host computer that runs the caching server (usually `localhost`)
**Email SMTP configuration**
If you want to configure Baserow to send emails you will have to add the following
environment variables to the `/etc/supervisor/conf.d/baserow.conf` environment block.
Otherwise, by default Baserow will not send emails and instead just log them in
`/var/log/baserow/worker.error`.
* `EMAIL_SMTP` (default ``): Providing anything other than an empty string will enable
SMTP email.
* `EMAIL_SMTP_HOST` (default `localhost`): The hostname of the SMTP server.
* `EMAIL_SMTP_USE_TLS` (default ``): Providing anything other than an empty string will
enable connecting to the SMTP server via TLS.
* `EMAIL_SMTP_PORT` (default `25`): The port of the SMTP server.
* `EMAIL_SMTP_USER` (default ``): The username for the SMTP server.
* `EMAIL_SMTP_PASSWORD` (default ``): The password of the SMTP server.
* `FROM_EMAIL` (default `no-reply@localhost`): The 'from' email address of the emails
that the platform sends. Like when a user requests a password recovery.
After modifying these files you need to make supervisor reread the files and apply the
changes.
@ -322,7 +364,7 @@ aren't any additional instructions in the previous release blog posts.
Follow these steps if you installed after June first 2021:
```
```bash
$ cd /baserow/baserow
$ git pull
$ cd /baserow
@ -344,7 +386,7 @@ $ supervisorctl restart all
Follow these steps if you installed before June first 2021.
```
```bash
$ cd /baserow
$ git pull
$ source backend/env/bin/activate