4.1 KiB
Development environment
If you want to contribute to Baserow you need to setup the development environment on
your local computer. The best way to do this is via docker-compose
so that can start
with the least amount of hassle.
Installing requirements
If you haven't already installed docker and docker-compose on your computer you can do so by following the instructions on https://docs.docker.com/desktop/.
If you haven't already installed git you can do so by following the instructions on https://www.linode.com/docs/development/version-control/how-to-install-git-on-linux-mac-and-windows/.
Once you have finished installing all the required software you should able to run the following commands in your terminal.
$ docker -v
Docker version 19.03.8, build afacb8b
$ docker-compose -v
docker-compose version 1.25.5, build 8a1c60f6
$ git --version
git version 2.24.3 (Apple Git-128)
If all commands return something similar as described in the example, then you are ready to proceed!
Starting development environment
Note that this has only been tested on MacOS Catalina. If you run into any issues with other operating systems, feel free to contact us via the form on https://baserow.io/contact.
For example purposes I have created a directory in my home folder named baserow
. You
can of course follow the steps in any directory, but in this tutorial I will assume
the working directory is ~/baserow
.
First we have to clone the repository. Execute the following commands to clone the master branch. If you are not familiar with git clone, this will download a copy of Baserow's code to your computer.
Note that if you have already started the demo environment once, you might need to to rebuild the images for the development environment by using the command
docker-compose up -d --build
because they have container name conflicts.
$ cd ~/baserow
$ git clone git@gitlab.com:bramw/baserow.git
Cloning into 'baserow'...
...
$ cd baserow
Now that we have our copy and we moved inside the newly created baserow
directory, we
can get started. You just have to execute the docker-compose up
command in detached
mode. It might take a while for the command finishes, this is because the image has to
be created from scratch.
$ docker network create baserow_default
$ docker-compose up -d
Building backend
...
Starting baserow_db_1 ... done
Starting baserow_mjml_1 ... done
Starting backend ... done
Starting web-frontend ... done
Starting backend development server
Now that you have your development environment up and running you can start by applying all the database migrations and starting the backend's development server. You need to execute the bash command of the backend container first. Because Baserow is not installed as a dependency you have to use the manage.py file in the source directory.
$ docker exec -it backend bash
$ python src/baserow/manage.py migrate
Running migrations:
...
$ python src/baserow/manage.py runserver 0.0.0.0:8000
Now that the server is running you should should see a response containing a message "Authentication credentials were not provided." if you visit http://localhost:8000/api/groups/ with your browser. If you want to see the API spec, you can visit http://localhost:8000/api/redoc/.
Starting web frontend development server
Now that the backend server is up and running you can start the web-frontend development server. Open a new tab in your terminal and execute the bash command of the web-frontend container first. After that you can install all the dependencies as they need to live on your host's file system.
$ docker exec -it web-frontend bash
$ yarn install
$ yarn run dev
Once those commands have executed and the development server is running you can visit http://localhost:3000 in your browser which should show the Baserow login page.
Keep the servers running.
Both servers need to keep running while you are developing. They also monitor file changes and update automatically so you don't need to worry about that. Go and make some changes yourself. You should see the result right away.