1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-11 07:51:20 +00:00

Merge branch '304-make-it-easier-to-run-production-version-on-local-machine' into 'develop'

Resolve "Make it easier to run production version on local machine"

Closes 

See merge request 
This commit is contained in:
Nigel Gott 2021-04-22 11:51:16 +00:00
commit bf66125a5e
58 changed files with 1605 additions and 463 deletions

3
.gitignore vendored
View file

@ -97,3 +97,6 @@ venv/
# intellij config files
*.iml
web-frontend/plugins/
backend/plugins/

View file

@ -10,6 +10,7 @@ web-frontend-eslint:
stage: lint
image: node:10
script:
- mkdir web-frontend/plugins && cp -r premium/web-frontend web-frontend/plugins/premium
- cd web-frontend
- make install-dependencies
- make eslint
@ -18,6 +19,7 @@ web-frontend-stylelint:
stage: lint
image: node:10
script:
- mkdir web-frontend/plugins && cp -r premium/web-frontend web-frontend/plugins/premium
- cd web-frontend
- make install-dependencies
- make stylelint
@ -26,6 +28,7 @@ web-frontend-test:
stage: test
image: node:10
script:
- mkdir web-frontend/plugins && cp -r premium/web-frontend web-frontend/plugins/premium
- cd web-frontend
- make install-dependencies
- make test
@ -34,6 +37,7 @@ backend-flake8:
stage: lint
image: python:3.7
script:
- mkdir backend/plugins && cp -r premium/backend backend/plugins/premium
- cd backend
- make install-dependencies
- make install-dev-dependencies
@ -45,17 +49,18 @@ backend-pytest:
services:
- name: postgres:11.3
alias: db
- name: liminspace/mjml-tcpserver:latest
- name: liminspace/mjml-tcpserver:0.10
alias: mjml
variables:
POSTGRES_USER: baserow
POSTGRES_PASSWORD: baserow
POSTGRES_DB: baserow
script:
- mkdir backend/plugins && cp -r premium/backend backend/plugins/premium
- cd backend
- make install-dependencies
- make install-dev-dependencies
- export PYTHONPATH=$CI_PROJECT_DIR/backend/src
- export PYTHONPATH=$CI_PROJECT_DIR/backend/src:$CI_PROJECT_DIR/backend/plugins/premium/src
- make test
backend-setup:
@ -64,5 +69,5 @@ backend-setup:
script:
- pip install -e ./backend
- python -c 'import baserow'
- export DJANGO_SETTINGS_MODULE='baserow.config.settings.demo'
- export DJANGO_SETTINGS_MODULE='baserow.config.settings.base'
- timeout --preserve-status 10s gunicorn --workers=1 -b 0.0.0.0:8000 -k uvicorn.workers.UvicornWorker baserow.config.asgi:application

View file

@ -34,60 +34,38 @@ development.
[Become a GitHub Sponsor](https://github.com/sponsors/bram2w)
## Try out a demo
## Try out Baserow on your machine
If you just want to try out Baserow, you can create an account on the SaaS version at
https://baserow.io. Just click on the create account or register button at the
homepage.
If you want to try out Baserow on your own computer, you can easily start a demo
If you want to try out Baserow on your own computer, you can easily start a local
environment via `docker-compose`. Just clone the repository, run the following commands
and visit http://localhost:3000 in your browser.
```
$ docker network create baserow_demo_default
$ docker-compose -f docker-compose.demo.yml up
$ git clone https://gitlab.com/bramw/baserow.git
$ cd baserow
$ docker-compose up
```
More detailed instructions and more information about the demo environment can be found
[here](./docs/guides/demo-environment.md) or at
https://baserow.io/docs/guides/demo-environment.
More detailed instructions and more information about running baserow locally check
[here](docs/guides/running-baserow-locally.md) or at
https://baserow.io/docs/guides/running-baserow-locally.
## Development environment
If you want to contribute to Baserow you need to setup the development environment.
Execute the following commands to start the backend API server.
> Note that the container might have a different name like `backend_1`.
Execute the following commands to start a development version of the baserow environment
which has debug and hot re-loading features enabled.
```
$ docker network create baserow_default
$ docker-compose up -d
$ docker exec -it backend bash
$ python src/baserow/manage.py migrate
$ python src/baserow/manage.py runserver 0.0.0.0:8000
```
Visit http://localhost:8000/api/groups/ in your browser and you should see a JSON
response containing "Authentication credentials were not provided.". This means that it
is working!
In order to process asynchronous tasks you also need to start a Celery worker this is
mainly used for the real time collaboration. Open a new tab or window and execute the
following commands.
```
$ docker exec -it backend bash
$ watchmedo auto-restart --directory=./ --pattern=*.py --recursive -- celery -A baserow worker -l INFO
```
In order to start the web-frontend environment you may execute the following commands.
```
$ docker network create baserow_default
$ docker exec -it web-frontend bash
$ yarn install
$ yarn dev
$ git clone https://gitlab.com/bramw/baserow.git
$ cd baserow
$ docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
$ # OR use our ./dev.sh script which also ensures your dev containers run as your user
$ ./dev.sh --build
```
The Baserow development environment is now running. Visit http://localhost:3000 in your

50
backend/Dockerfile Normal file
View file

@ -0,0 +1,50 @@
FROM python:3.7-slim-buster
ARG UID
ENV UID=${UID:-9999}
ARG GID
ENV GID=${GID:-9999}
# We might be running as a user which already exists in this image. In that situation
# Everything is OK and we should just continue on.
RUN groupadd -g $GID baserow_docker_group || exit 0
RUN useradd --shell /bin/bash -u $UID -g $GID -o -c "" -m baserow_docker_user || exit 0
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
curl \
gnupg2 \
libpq-dev \
dos2unix \
tini \
&& apt-get autoclean \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
USER $UID:$GID
ADD --chown=$UID:$GID ./backend/requirements/base.txt /baserow/requirements/
# Disable the path warn as we set the correct path in the entrypoint when it is easy
# to know the users $HOME/.local/bin location. Changing path in the docker image does
# not work as we do not know where $HOME when using an ENV command.
RUN pip3 install --no-warn-script-location -r /baserow/requirements/base.txt
ADD --chown=$UID:$GID ./docs /baserow/docs
ADD --chown=$UID:$GID ./backend /baserow/backend
ADD --chown=$UID:$GID ./premium/backend /baserow/backend/plugins/premium
WORKDIR /baserow/backend
# Ensure that Python outputs everything that's printed inside
# the application rather than buffering it.
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH $PYTHONPATH:/baserow/backend/src:/baserow/backend/plugins/premium/src
ENV DJANGO_SETTINGS_MODULE='baserow.config.settings.base'
RUN dos2unix /baserow/backend/docker/docker-entrypoint.sh && \
chmod a+x /baserow/backend/docker/docker-entrypoint.sh
ENTRYPOINT ["/usr/bin/tini", "--", "/bin/bash", "/baserow/backend/docker/docker-entrypoint.sh"]
CMD ["local"]

View file

@ -1,20 +0,0 @@
FROM python:3.7
ADD . /backend
RUN mkdir -p /media
WORKDIR /backend
ENV PYTHONPATH $PYTHONPATH:/backend/src
ENV DJANGO_SETTINGS_MODULE='baserow.config.settings.demo'
RUN apt-get update
RUN apt-get -y install make
RUN apt-get -y install curl
RUN apt-get -y install gnupg2
RUN make install-dependencies
ENTRYPOINT python src/baserow/manage.py migrate && \
python src/baserow/manage.py sync_templates && \
celery -A baserow worker -l INFO --detach && \
gunicorn --workers=3 -b 0.0.0.0:8000 -k uvicorn.workers.UvicornWorker baserow.config.asgi:application

View file

@ -1,18 +0,0 @@
FROM python:3.7
ADD . /backend
WORKDIR /backend
ENV PYTHONPATH $PYTHONPATH:/backend/src:/premium-backend/src
ENV DJANGO_SETTINGS_MODULE='baserow.config.settings.dev'
RUN apt-get update
RUN apt-get -y install make
RUN apt-get -y install curl
RUN apt-get -y install gnupg2
RUN make install-dependencies
RUN make install-dev-dependencies
CMD tail -f /dev/null

View file

@ -1,15 +1,17 @@
install-dependencies:
apt-get update && apt-get install -y libpq-dev postgresql postgresql-contrib
apt-get update && apt-get install -y libpq-dev
pip install -r requirements/base.txt
install-dev-dependencies:
pip install -r requirements/dev.txt
lint:
flake8 src tests && black . --check || exit;
flake8 src tests plugins && black . --check || exit;
lint-python: lint
format:
black . || exit;
test:
pytest tests || exit;
pytest || exit;

1
backend/baserow Normal file → Executable file
View file

@ -1,3 +1,4 @@
#!/usr/bin/env python
from baserow.manage import main

View file

@ -0,0 +1,54 @@
FROM python:3.7-slim-buster
# Default to 1000 as this is probably the running users UID.
ARG UID
ENV UID=${UID:-1000}
ARG GID
ENV GID=${GID:-1000}
# We might be running as a user which already exists in this image. In that situation
# Everything is OK and we should just continue on.
RUN groupadd -g $GID baserow_docker_group || exit 0
RUN useradd --shell /bin/bash -u $UID -g $GID -o -c "" -m baserow_docker_user || exit 0
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
curl \
gnupg2 \
libpq-dev \
dos2unix \
tini \
&& apt-get autoclean \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
USER $UID:$GID
ADD --chown=$UID:$GID ./backend/requirements /baserow/requirements
# Disable the path warn as we set the correct path in the entrypoint when it is easy
# to know the users $HOME/.local/bin location. Changing path in the docker image does
# not work as we do not know where $HOME when using an ENV command.
RUN pip3 install --no-warn-script-location -r /baserow/requirements/base.txt -r /baserow/requirements/dev.txt
ADD --chown=$UID:$GID ./docs /baserow/docs
ADD --chown=$UID:$GID ./backend /baserow/backend
ADD --chown=$UID:$GID ./premium/backend /baserow/backend/plugins/premium
WORKDIR /baserow/backend
# Ensure that Python outputs everything that's printed inside
# the application rather than buffering it.
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH $PYTHONPATH:/baserow/backend/src:/baserow/backend/plugins/premium/src
ENV DJANGO_SETTINGS_MODULE='baserow.config.settings.dev'
RUN dos2unix /baserow/backend/docker/docker-entrypoint.sh && \
chmod a+x /baserow/backend/docker/docker-entrypoint.sh
# Ensure we don't pollute the devs actual repo when mounting in files by
# putting these two folders into anonymous docker volumes.
VOLUME ["/baserow/backend/plugins"]
ENTRYPOINT ["/usr/bin/tini", "--", "/bin/bash", "/baserow/backend/docker/docker-entrypoint.sh"]
CMD ["dev"]

View file

@ -0,0 +1,128 @@
#!/bin/bash
# Bash strict mode: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
# Used by docker-entrypoint.sh to start the dev server
# If not configured you'll receive this: CommandError: "0.0.0.0:" is not a valid port number or address:port pair.
PORT="${PORT:-8000}"
DATABASE_USER="${DATABASE_USER:-postgres}"
DATABASE_HOST="${DATABASE_HOST:-db}"
DATABASE_PORT="${DATABASE_PORT:-5432}"
# Ensure the installed python dependencies are on the path and available.
export PATH="$PATH:$HOME/.local/bin"
postgres_ready() {
python << END
import sys
import psycopg2
try:
psycopg2.connect(
dbname="${DATABASE_NAME}",
user="${DATABASE_USER}",
password="${DATABASE_PASSWORD}",
host="${DATABASE_HOST}",
port="${DATABASE_PORT}",
)
except psycopg2.OperationalError:
sys.exit(-1)
sys.exit(0)
END
}
wait_for_postgres() {
until postgres_ready; do
>&2 echo 'Waiting for PostgreSQL to become available...'
sleep 1
done
>&2 echo 'PostgreSQL is available'
}
show_help() {
# If you change this please update ./docs/reference/baserow-docker-api.md
echo """
Usage: docker run <imagename> COMMAND
Commands
local : Start django using a prod ready gunicorn server
dev : Start a normal Django development server
bash : Start a bash shell
manage : Start manage.py
python : Run a python command
shell : Start a Django Python shell
celery : Run celery
celery-dev: Run a hot-reloading dev version of celery
lint: : Run the linting
help : Show this message
"""
}
run_setup_commands_if_configured(){
if [ "$MIGRATE_ON_STARTUP" = "true" ] ; then
echo "python /baserow/backend/src/baserow/manage.py migrate"
python /baserow/backend/src/baserow/manage.py migrate
fi
if [ "$SYNC_TEMPLATES_ON_STARTUP" = "true" ] ; then
echo "python /baserow/backend/src/baserow/manage.py sync_templates"
python /baserow/backend/src/baserow/manage.py sync_templates
fi
}
case "$1" in
dev)
wait_for_postgres
run_setup_commands_if_configured
echo "Running Development Server on 0.0.0.0:${PORT}"
echo "Press CTRL-p CTRL-q to close this session without stopping the container."
CMD="python /baserow/backend/src/baserow/manage.py runserver 0.0.0.0:${PORT}"
echo "$CMD"
# The below command lets devs attach to this container, press ctrl-c and only
# the server will stop. Additionally they will be able to use bash history to
# re-run the containers run server command after they have done what they want.
exec bash --init-file <(echo "history -s $CMD; $CMD")
;;
local)
wait_for_postgres
run_setup_commands_if_configured
exec gunicorn --workers=3 -b 0.0.0.0:"${PORT}" -k uvicorn.workers.UvicornWorker baserow.config.asgi:application
;;
bash)
exec /bin/bash "${@:2}"
;;
manage)
exec python /baserow/backend/src/baserow/manage.py "${@:2}"
;;
python)
exec python "${@:2}"
;;
shell)
exec python /baserow/backend/src/baserow/manage.py shell
;;
lint)
exec make lint-python
;;
celery)
exec celery -A baserow worker -l INFO
;;
celery-dev)
# Ensure we watch all possible python source code locations for changes.
directory_args=''
for i in $(echo "$PYTHONPATH" | tr ":" "\n")
do
directory_args="$directory_args -d=$i"
done
CMD="watchmedo auto-restart $directory_args --pattern=*.py --recursive -- celery -A baserow worker -l INFO"
echo "$CMD"
# The below command lets devs attach to this container, press ctrl-c and only
# the server will stop. Additionally they will be able to use bash history to
# re-run the containers run server command after they have done what they want.
exec bash --init-file <(echo "history -s $CMD; $CMD")
;;
*)
show_help
exit 1
;;
esac

View file

@ -1,4 +1,9 @@
[pytest]
DJANGO_SETTINGS_MODULE = baserow.config.settings.test
python_files = test_*.py
env = DJANGO_SETTINGS_MODULE = baserow.config.settings.test
env =
DJANGO_SETTINGS_MODULE = baserow.config.settings.test
ADDITIONAL_APPS = baserow_premium
testpaths =
tests
plugins

View file

@ -3,7 +3,6 @@ django-cors-headers==3.2.1
djangorestframework==3.11.0
djangorestframework-jwt==1.11.0
psycopg2==2.8.4
mysqlclient==1.4.6
ipython==7.13.0
Faker==4.0.2
Twisted==20.3.0

View file

@ -1,5 +1,5 @@
import os
import datetime
import os
from urllib.parse import urlparse, urljoin
from corsheaders.defaults import default_headers
@ -33,6 +33,10 @@ INSTALLED_APPS = [
"baserow.contrib.database",
]
ADDITIONAL_APPS = os.getenv("ADDITIONAL_APPS", None)
if ADDITIONAL_APPS is not None:
INSTALLED_APPS += ADDITIONAL_APPS.split(",")
MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
@ -230,7 +234,7 @@ if "INITIAL_TABLE_DATA_LIMIT" in os.environ:
MEDIA_URL_PATH = "/media/"
MEDIA_URL = os.getenv("MEDIA_URL", urljoin(PUBLIC_BACKEND_URL, MEDIA_URL_PATH))
MEDIA_ROOT = os.getenv("MEDIA_ROOT", "/media")
MEDIA_ROOT = os.getenv("MEDIA_ROOT", "/baserow/media")
# Indicates the directory where the user files and user thumbnails are stored.
USER_FILES_DIRECTORY = "user_files"
@ -246,6 +250,8 @@ if os.getenv("EMAIL_SMTP", ""):
EMAIL_PORT = os.getenv("EMAIL_SMTP_PORT", "25")
EMAIL_HOST_USER = os.getenv("EMAIL_SMTP_USER", "")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_SMTP_PASSWORD", "")
else:
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
# Configurable thumbnails that are going to be generated when a user uploads an image

View file

@ -1,5 +0,0 @@
from .base import * # noqa: F403, F401
DEBUG = True
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

View file

@ -6,6 +6,7 @@
* Switch to using a celery based email backend by default.
* Added `--add-columns` flag to the `fill_table` management command. It creates all the
field types before filling the table with random data.
* Reworked Baserow's Docker setup to be easier to use, faster to build and more secure.
* Make the view header more compact when the content doesn't fit anymore.
* Allow providing a `template_id` when registering a new account, which will install
that template instead of the default database.

View file

@ -43,7 +43,7 @@ autorestart=true
[program:nuxt]
user=cloudron
directory=/app/code/baserow/web-frontend
command=sh -c './node_modules/.bin/nuxt start --hostname 127.0.0.1 --config-file ./config/nuxt.config.demo.js'
command=sh -c './node_modules/.bin/nuxt start --hostname 127.0.0.1 --config-file ./config/nuxt.config.local.js'
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stdout

246
dev.sh Executable file
View file

@ -0,0 +1,246 @@
#!/bin/bash
# Bash strict mode: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
tabname() {
printf "\e]1;$1\a"
}
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
NC=$(tput sgr0) # No Color
print_manual_instructions(){
COMMAND=$1
echo -e "\nTo inspect the now running dev environment open a new tab/terminal and run:"
echo " $COMMAND"
}
PRINT_WARNING=true
new_tab() {
TAB_NAME=$1
COMMAND=$2
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [ -x "$(command -v gnome-terminal)" ]; then
gnome-terminal \
--tab --title="$TAB_NAME" --working-directory="$(pwd)" -- /bin/bash -c "$COMMAND"
else
if $PRINT_WARNING; then
echo -e "\n${YELLOW}./dev.sh WARNING${NC}: gnome-terminal is the only currently supported way of opening
multiple tabs/terminals for linux by this script, add support for your setup!"
PRINT_WARNING=false
fi
print_manual_instructions "$COMMAND"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
osascript \
-e "tell application \"Terminal\"" \
-e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
-e "do script \"printf '\\\e]1;$TAB_NAME\\\a'; $COMMAND\" in front window" \
-e "end tell" > /dev/null
else
if $PRINT_WARNING; then
echo -e "\n${WARNING}./dev.sh WARNING${NC}: The OS '$OSTYPE' is not supported yet for creating tabs to setup
baserow's dev environment, please add support!"
PRINT_WARNING=false
fi
print_manual_instructions "$COMMAND"
fi
}
show_help() {
echo """
./dev.sh starts the baserow development environment and by default attempts to
open terminal tabs which are attached to the running dev containers.
Usage: ./dev.sh [optional start dev commands] [optional docker-compose up commands]
The ./dev.sh Commands are:
restart : Stop the dev environment first before relaunching.
down : Down the dev environment and don't up after.
kill : Kill the dev environment and don't up after.
build_only : Build the dev environment and don't up after.
dont_migrate : Disable automatic database migration on baserow startup.
dont_sync : Disable automatic template sync on baserow startup.
dont_attach : Don't attach to the running dev containers after starting them.
ignore_ownership: Don't exit if there are files in the repo owned by a different user.
help : Show this message.
"""
}
dont_attach=false
down=false
kill=false
build=false
run=false
up=true
migrate=true
sync_templates=true
exit_if_other_owners_found=true
while true; do
case "${1:-noneleft}" in
dont_migrate)
echo "./dev.sh: Automatic migration on startup has been disabled."
shift
migrate=false
;;
dont_sync)
echo "./dev.sh: Automatic template syncing on startup has been disabled."
shift
sync_templates=false
;;
dont_attach)
echo "./dev.sh: Configured to not attach to running dev containers."
shift
dont_attach=true
;;
restart)
echo "./dev.sh: Restarting Dev Environment"
shift
down=true
up=true
;;
down)
echo "./dev.sh: Stopping Dev Environment"
shift
up=false
down=true
;;
kill)
echo "./dev.sh: Killing Dev Environment"
shift
up=false
kill=true
;;
run)
echo "./dev.sh: docker-compose running the provided commands"
shift
up=false
dont_attach=true
run=true
;;
build_only)
echo "./dev.sh: Only Building Dev Environment (use 'up --build' instead to
rebuild and up)"
shift
build=true
up=false
;;
ignore_ownership)
echo "./dev.sh: Continuing if files in repo are not owned by $USER."
shift
exit_if_other_owners_found=false
;;
help)
show_help
exit 0
;;
*)
break
;;
esac
done
OWNERS=$(find . ! -user "$USER")
if [[ $OWNERS ]]; then
if [[ "$exit_if_other_owners_found" = true ]]; then
echo "${RED}./dev.sh ERROR${NC}: Files not owned by your current user: $USER found in this repo.
This will cause file permission errors when Baserow starts up.
They are probably build files created by the old Baserow Docker images owned by root.
Run the following command to show which files are causing this:
find . ! -user $USER
Please run the following command to fix file permissions in this repository before using ./dev.sh:
${GREEN}sudo chown $USER -R .${NC}
OR you can ignore this check by running with the ignore_ownership arg:
${YELLOW}./dev.sh ignore_ownership ...${NC}"
exit;
else
echo "${YELLOW}./dev.sh WARNING${NC}: Files not owned by your current user: $USER found in this repo.
Continuing as 'ignore_ownership' argument provided."
fi
fi
# Set various env variables to sensible defaults if they have not already been set by
# the user.
if [[ -z "${UID:-}" ]]; then
UID=$(id -u)
export UID
fi
if [[ -z "${GID:-}" ]]; then
export GID
GID=$(id -g)
fi
if [[ -z "${MIGRATE_ON_STARTUP:-}" ]]; then
if [ "$migrate" = true ] ; then
export MIGRATE_ON_STARTUP="true"
else
# Because of the defaults set in the docker-compose file we need to explicitly turn
# this off as just not setting it will get the default "true" value.
export MIGRATE_ON_STARTUP="false"
fi
else
echo "./dev.sh Using the already set value for the env variable MIGRATE_ON_STARTUP = $MIGRATE_ON_STARTUP"
fi
if [[ -z "${SYNC_TEMPLATES_ON_STARTUP:-}" ]]; then
if [ "$sync_templates" = true ] ; then
export SYNC_TEMPLATES_ON_STARTUP="true"
else
# Because of the defaults set in the docker-compose file we need to explicitly turn
# this off as just not setting it will get the default "true" value.
export SYNC_TEMPLATES_ON_STARTUP="false"
fi
else
echo "./dev.sh Using the already set value for the env variable SYNC_TEMPLATES_ON_STARTUP = $SYNC_TEMPLATES_ON_STARTUP"
fi
echo "./dev.sh running docker-compose commands:
------------------------------------------------
"
if [ "$down" = true ] ; then
docker-compose -f docker-compose.yml -f docker-compose.dev.yml down
fi
if [ "$kill" = true ] ; then
docker-compose -f docker-compose.yml -f docker-compose.dev.yml kill
fi
if [ "$build" = true ] ; then
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build "$@"
fi
if [ "$up" = true ] ; then
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d "$@"
fi
if [ "$run" = true ] ; then
docker-compose -f docker-compose.yml -f docker-compose.dev.yml run "$@"
fi
if [ "$dont_attach" != true ] && [ "$up" = true ] ; then
new_tab "Backend" \
"docker logs backend && docker attach backend"
new_tab "Backend celery" \
"docker logs celery && docker attach celery"
new_tab "Web frontend" \
"docker logs web-frontend && docker attach web-frontend"
new_tab "Web frontend lint" \
"docker exec -it web-frontend /bin/bash /baserow/web-frontend/docker/docker-entrypoint.sh lint-fix"
fi

View file

@ -1,51 +0,0 @@
version: "3"
services:
db:
container_name: baserow-demo-db
image: postgres:11.3
environment:
- POSTGRES_USER=baserow
- POSTGRES_PASSWORD=baserow
- POSTGRES_DB=baserow
ports:
- 5432:5432
redis:
container_name: redis
image: redis:6.0
ports:
- 6379:6379
mjml:
container_name: baserow-demo-mjml
image: liminspace/mjml-tcpserver:latest
ports:
- 28101:28101
backend:
container_name: baserow-demo-backend
build:
context: ./backend/
dockerfile: Dockerfile.demo
ports:
- 8000:8000
depends_on:
- db
- redis
- mjml
web-frontend:
container_name: baserow-demo-web-frontend
build:
context: ./web-frontend/
dockerfile: Dockerfile.demo
ports:
- 3000:3000
depends_on:
- backend
networks:
default:
external:
name: baserow_demo_default

51
docker-compose.dev.yml Normal file
View file

@ -0,0 +1,51 @@
version: "3.7"
services:
backend:
build:
context: .
dockerfile: ./backend/docker/Dockerfile.dev
args:
# We allow configuring the UID/GID here so you can run as the dev's actual user
# reducing the chance the containers screw up the bind mounted folders.
UID: "${UID:-}"
GID: "${GID:-}"
image: baserow_backend_dev:latest
volumes:
- ./backend:/baserow/backend
- ./premium/backend/:/baserow/backend/plugins/premium
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
celery:
image: baserow_backend_dev:latest
command: celery-dev
volumes:
- ./backend:/baserow/backend
- ./premium/backend/:/baserow/backend/plugins/premium
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
web-frontend:
build:
context: .
dockerfile: ./web-frontend/docker/Dockerfile.dev
args:
# We allow configuring the UID/GID here so you can run as the dev's actual user
# reducing the chance the containers screw up the bind mounted folders.
UID: "${UID:-}"
GID: "${GID:-}"
image: baserow_web-frontend_dev:latest
volumes:
- ./web-frontend:/baserow/web-frontend
- ./premium/web-frontend/:/baserow/web-frontend/plugins/premium
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
media-volume-fixer:
command: chown ${UID:-1000}:${GID:-1000} -R /baserow/media

View file

@ -1,56 +1,119 @@
version: "3"
version: "3.7"
services:
db:
container_name: db
image: postgres:11.3
environment:
- POSTGRES_USER=baserow
- POSTGRES_PASSWORD=baserow
- POSTGRES_DB=baserow
- POSTGRES_USER=${DATABASE_USER:-baserow}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD:-baserow}
- POSTGRES_DB=${DATABASE_NAME:-baserow}
ports:
- 5432:5432
- "${POSTGRES_PORT:-5432}:5432"
networks:
local:
volumes:
- pgdata:/var/lib/postgresql/data
redis:
container_name: redis
image: redis:6.0
ports:
- 6379:6379
- "${REDIS_PORT:-6379}:6379"
networks:
local:
mjml:
container_name: mjml
image: liminspace/mjml-tcpserver:latest
image: liminspace/mjml-tcpserver:0.10
# mjml is based off the node image which creates a non root node user we can run as
user: "1000:1000"
ports:
- 28101:28101
- "${MJML_PORT:-28101}:28101"
networks:
local:
backend:
container_name: backend
build:
context: ./backend/
dockerfile: Dockerfile.dev
volumes:
- ./backend:/backend
- ./premium/backend:/premium-backend
dockerfile: ./backend/Dockerfile
context: .
image: baserow_backend:latest
environment:
- MIGRATE_ON_STARTUP=${MIGRATE_ON_STARTUP:-true}
- SYNC_TEMPLATES_ON_STARTUP=${SYNC_TEMPLATES_ON_STARTUP:-true}
- DATABASE_USER=${DATABASE_USER:-baserow}
- DATABASE_PASSWORD=${DATABASE_PASSWORD:-baserow}
- DATABASE_NAME=${DATABASE_NAME:-baserow}
- ADDITIONAL_APPS
- MEDIA_URL=http://localhost:${MEDIA_PORT:-4000}/media/
ports:
- 8000:8000
- "${BACKEND_PORT:-8000}:8000"
depends_on:
- db
- redis
- mjml
- media-volume-fixer
volumes:
- media:/baserow/media
networks:
local:
celery:
container_name: celery
image: baserow_backend:latest
command: celery
depends_on:
- backend
volumes:
- media:/baserow/media
networks:
local:
web-frontend:
container_name: web-frontend
build:
context: ./web-frontend/
dockerfile: Dockerfile.dev
volumes:
- ./web-frontend:/web-frontend
- ./premium/web-frontend:/premium-frontend
context: .
dockerfile: ./web-frontend/Dockerfile
image: baserow_web-frontend:latest
environment:
- ADDITIONAL_MODULES
ports:
- 3000:3000
- "${WEB_FRONTEND_PORT:-3000}:3000"
depends_on:
- backend
networks:
local:
# A nginx container purely to serve up django's MEDIA files.
media:
container_name: media
build: media
ports:
- "${MEDIA_PORT:-4000}:80"
depends_on:
- media-volume-fixer
volumes:
- media:/baserow/media
networks:
local:
# When switching between dev and local the media files in the media volume will be
# owned by different users. Ensure that we chown them to the user appropriate for the
# environment here.
media-volume-fixer:
container_name: media-volume-fixer
image: bash:4.4
command: chown 9999:9999 -R /baserow/media
volumes:
- media:/baserow/media
networks:
local:
volumes:
pgdata:
media:
networks:
default:
external:
name: baserow_default
local:
driver: bridge

View file

@ -0,0 +1,74 @@
## ./dev.sh
`dev.sh` is a helper bash script which makes working with baserow's development
environment a breeze.
By default, running `./dev.sh` will start the dev env, attach into the running
containers and make sure the containers are running as your actual user.
Additionally, Baserow's dev containers are especially configured to make the attaching
experience smooth and useful. In the per container tabs opened by using `./dev.sh`:
* The output of docker logs will be shown at the top letting you see everything that has
happened in the container so far.
* You can press ctrl-c to stop the process running inside the container leaving you in a
bash session inside the container, but not stop the container itself. This is useful
as you often want to stop the dev server, run a management command and quickly restart
it.
* The bash session you are left in after pressing ctrl-c will have a history populated,
so you can press up to get the command that the container was running before you
pressed ctrl-c!
### Usage
```bash
./dev.sh starts the baserow development environment and by default attempts to
open terminal tabs which are attached to the running dev containers.
Usage: ./dev.sh [optional start dev commands] [optional docker-compose up commands]
The ./dev.sh Commands are:
restart : Stop the dev environment first before relaunching.
down : Down the dev environment and don't up after.
kill : Kill the dev environment and don't up after.
build_only : Build the dev environment and don't up after.
dont_migrate : Disable automatic database migration on baserow startup.
dont_sync : Disable automatic template sync on baserow startup.
dont_attach : Don't attach to the running dev containers after starting them.
ignore_ownership: Don't exit if there are files in the repo owned by a different user.
help : Show this message.
```
### Examples of ./dev.sh usage:
```bash
$ ./dev.sh # same as the up command above but also ensures the containers run as the running user!
$ ./dev.sh --build # ups and rebuilds
$ ./dev.sh restart # stops and then ups
$ ./dev.sh restart --build # stops, builds, ups
$ ./dev.sh build_only # just builds
$ ./dev.sh dont_attach # does not create tabs and attach to the containers at the end
$ ./dev.sh dont_attach restart --build # You can combine multiple arguments like so
$ ./dev.sh dont_migrate # ups but doesn't migrate automatically on startup
$ ./dev.sh dont_migrate dont_sync dont_attach restart --build # even more flags!
$ ./dev.sh run backend manage migrate
# Any commands found after the last `./dev.sh` command will be passed to the `docker-compose up` call made by dev.sh
# This lets you say do --build on the end or any other docker-compose commands using dev.sh!
$ ./dev.sh restart {EXTRA_COMMANDS_PASSED_TO_UP}
$ ./dev.sh down # downs the env
$ ./dev.sh kill # kills (the old stop_dev.sh)
# Bind to different ports on the host manage incase you are already running them and they clash! (also works with just docker-compose up)
$ POSTGRES_PORT=5555 REDIS_PORT=6666 MJML_PORT=7777 ./dev.sh
```
### Why ./dev.sh ensures the containers run as you
In dev mode Baserow's source control directories are mounted from your local git repo
into the containers. By mounting these the containers will see source code changes and
automatically rebuild. However, if the containers are not running as your actual user
then the containers might accidentally change the ownership or create files owned by the
user running inside the container. So by running the containers as your user there is no
chance that your source control directories will have file ownership problems.
Additionally, it
is [best practice](https://medium.com/@mccode/processes-in-containers-should-not-run-as-root-2feae3f0df3b)
to not run Docker containers as the default root user.

View file

@ -1,133 +1,18 @@
# Development environment
# Baserow's dev 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 you can
start the app with the least amount of hassle.
The dev environment runs Baserow services with source code hot reloading enabled. It
also runs the backend django server and web-frontend nuxt server in debug and
development modes. It is recommended that you use [dev.sh](../development/dev_sh.md)
found in the root of the Baserow repo.
## 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 be 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
> If you run into any issues starting your development environment 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](../guides/demo-environment.md) once, you might need 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 https://gitlab.com/bramw/baserow.git
Cloning into 'baserow'...
...
$ cd baserow
```
Now that we have our copy of the repo and have changed directories to the newly
created `baserow`, we can bring up the containers. You just have to execute the
docker-compose command using the `docker-compose.demo.yml` file. It might take a while
for the command to finish, this is because the image has to be built from scratch.
```
$ docker network create baserow_default
$ docker-compose up -d
Building backend
...
Starting db ... done
Starting mjml ... done
Starting redis ... done
Starting backend ... done
Starting web-frontend ... done
```
## Starting backend development server
Now that you have your development environment up and running, you need to apply all the
database migrations, synchronize the templates and start 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 sync_templates
$ python src/baserow/manage.py runserver 0.0.0.0:8000
```
After executing these commands, the server is running. If you visit
http://localhost:8000/api/groups/ in your browser you should see the response
"Authentication credentials were not provided." If you want to see the API spec, you can
visit http://localhost:8000/api/redoc/.
## Starting the worker
In order to process asynchronous tasks you also need to start a Celery worker this is
mainly used for the real time collaboration. Open a new tab or window and execute the
following commands. The `watchmedo` command makes sure the worker is restarted whenever
you make a change.
```
$ docker exec -it backend bash
$ watchmedo auto-restart --directory=./ --pattern=*.py --recursive -- celery -A baserow worker -l INFO
```
## 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 need to install all the dependencies that the
web-frontend app relies on.
```
$ 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 the web-frontend and backend containers need to keep running while you are
developing. They also monitor file changes and update automatically so you don't need to
worry about reloading. Go and make some changes yourself. You should see the result
right away.
## Further reading
- See [running the dev environment](running-the-dev-environment.md) for a
step-by-step guide on how to set-up the dev env.
- See [baserow docker api](../reference/baserow-docker-api.md) for more detail on how
Baserow's docker setup can be used and configured.
- See [dev.sh](../development/dev_sh.md) for further detail on the CLI tool for managing
the dev environment.
## Fixing git blame

View file

@ -23,10 +23,10 @@ This whole directory is also added to the backend container.
source directory. This file is registered as a command via the `setup.py`. When
someone adds Baserow as a dependency they can use the command `baserow migrate` which
is the same as `python src/baserow/manage.py migrate`.
* `Dockerfile.demo`: the dockerfile that is used to build the demo image of the
backend.
* `Dockerfile.dev`: the dockerfile that is used to build the development image of the
backend.
* `Dockerfile`: the dockerfile that is used to build the image of the
backend for running baserow on your local machine.
* `docker/Dockerfile.dev`: the dockerfile that is used to build the development image
of the backend.
* `Makefile`: contains a few commands to install the dependencies, run the linter and
run the tests.
* `pytest.ini`: pytest configuration when running the tests.
@ -85,10 +85,10 @@ web frontend. This whole directory is also added to the web-frontend container.
* `.eslintrc.js`: the configuration for the eslint linter.
* `.prettierrc`: configuration for prettier.
* `.stylelintrc`: configuration for stylelint which lints the scss code.
* `Dockerfile.demo`: the dockerfile that is used to build the demo image of the
web-frontend.
* `Dockerfile.dev`: the dockerfile that is used to build the development image of the
web-frontend.
* `Dockerfile`: the dockerfile that is used to build the image of the
web-frontend for running baserow on your local machine.
* `docker/Dockerfile.dev`: the dockerfile that is used to build the development image
of the web-frontend.
* `intellij-idea.webpack.config.js` a webpack config file that can be used by Intellij
iDEA. It adds the correct aliases for the editor.
* `jest.config.js`: config file for running the tests with JEST.
@ -128,3 +128,10 @@ https://baserow.io/docs.
Contains a cookiecutter boilerplate for a Baserow plugin. More information can be found
on the [plugin boilerplate page](../plugins/boilerplate.md).
## media
Contains a nginx based docker image which is used in Baserow's docker setup to serve
any uploaded user files. This is needed as Django will not serve media files when
not in debug mode and instead requires you to run your own web server to serve these
assets.

View file

@ -0,0 +1,161 @@
# Running the dev 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 you can
start the app with the least amount of hassle.
### Quickstart
If you are familiar with git and docker-compose run these commands to launch baserow's
dev environment locally, otherwise please start from the Installing Requirements section
below.
```bash
$ git clone https://gitlab.com/bramw/baserow.git
$ cd baserow
$ docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
$ # OR use our ./dev.sh script which also ensures your dev containers run as your user
$ ./dev.sh --build
```
## 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/ and
https://docs.docker.com/compose/install/.
You will also need git installed which you can do 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 be 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 the dev environment
> If you run into any issues starting your development environment 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
> [running baserow locally guide](../guides/running-baserow-locally.md) once, you might
> need to rebuild the images for the development environment by using the command
> `docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build`
> or just `./dev.sh build_only` because they have container name conflicts.
```
$ cd ~/baserow
$ git clone https://gitlab.com/bramw/baserow.git
Cloning into 'baserow'...
...
$ cd baserow
```
Now that we have our copy of the repo and have changed directories to the newly
created `baserow`, we can bring up the containers. You just have to execute the
docker-compose command using the `docker-compose.yml` file. It might take a while for
the command to finish, this is because the images have to be built from scratch.
```
$ docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
$ # Or instead you can use ./dev.sh which also ensures the dev environment runs as you
$ ./dev.sh
$ # Run ./dev.sh for more details on what it can do!
Building backend
...
Starting db ... done
Starting mjml ... done
Starting redis ... done
Starting backend ... done
Starting web-frontend ... done
```
Your dev environment is now running, the database has been automatically migrated for
you and the baserow templates have been synced. You can now visit http://localhost:3000
to sign up and login to your Baserow.
## Looking at the web api
Baserow's backend container exposes a rest API. Find the API spec for your local version
of Baserow at http://localhost:8000/api/redoc/ . To check that it is working correctly
when you visit http://localhost:8000/api/groups/ in a browser you should see the error
"Authentication credentials were not provided." as no JWT was provided.
## Attaching to the dev environment
The dev environment consists of a number of docker containers, see:
If you use `./dev.sh` by default it will attempt to open tabs in your terminal and
attach to the running baserow containers. Otherwise you can do so manually by running
the following commands:
```bash
$ # Run the commands below to connect to the various different parts of Baserow
$ docker attach backend
$ docker attach celery
$ docker attach web-frontend
```
When attached you can press CTRL-C to end the current containers main process. However
unlike normal docker containers this one will not exit immediately but instead present
you with a bash terminal. In this terminal you can then run any admin commands you wish
or inspect the state of the containers. Simply press up and go through the containers
bash history to get the original command to restart the containers main process.
## Other useful commands
See the [docker how to guide](../guides/baserow-docker-how-to.md) for a larger collection of
useful operations and commands, below is a quick example of some of the more common
ones:
```bash
$ # View the logs
$ docker-compose logs
$ # Migrate
$ ./dev.sh run backend manage migrate
$ # Restart and Build
$ ./dev.sh restart --build
```
## Keep the servers running
Both the web-frontend and backend containers need to keep running while you are
developing. They also monitor file changes and update automatically, so you don't need
to worry about reloading. Go and make some changes yourself. You should see the result
right away.
## Working with Docker and Django
For further reading on how to work with docker containers and django check out:
- [django's getting started tutorial](https://docs.djangoproject.com/en/3.1/intro/tutorial01/)
- [docker's getting started tutorial](https://docs.docker.com/get-started/)
- [docker's cli reference](https://docs.docker.com/engine/reference/run/)
- [docker composes reference](https://docs.docker.com/compose/)
## Baserow further reading
- See [introduction](../getting-started/introduction.md) for more details on Baserow's
architecture.
- See [baserow docker api](../reference/baserow-docker-api.md) for more detail on how
Baserow's docker setup can be used and configured.
- See [dev.sh](dev_sh.md) for further detail on what dev.sh does and why

View file

@ -91,7 +91,7 @@ are accepted.
* `DATABASE_HOST` (default `db`): The hostname of the PostgreSQL server.
* `DATABASE_PORT` (default `5432`): The port of the PostgreSQL server.
* `MJML_SERVER_HOST` (default `mjml`): The hostname of the MJML TCP server. In the
development environment we use the `liminspace/mjml-tcpserver:latest` image.
development environment we use the `liminspace/mjml-tcpserver:0.10` image.
* `MJML_SERVER_PORT` (default `28101`): The port of the MJML TCP server.
* `PUBLIC_BACKEND_URL` (default `http://localhost:8000`): The publicly accessible URL of
the backend. For the development environment this is `http://localhost:8000`, but if

View file

@ -0,0 +1,132 @@
# Baserow Docker how to
Find below a list of FAQs and common operations when working with Baserow's docker
environment.
See [baserow's docker api](../reference/baserow-docker-api.md) for the full details on
what commands and environment variables baserow's docker-compose and docker image's
support.
## How To
### View the logs
```bash
$ docker-compose logs
```
### Run Baserow alongside existing services
Baserow's docker-compose files will automatically bind to various ports on your
machine's network. If you already have applications or services using those ports the
Baserow service which uses that port will crash:
```bash
Creating network "baserow_local" with driver "bridge"
Creating db ...
Creating db ... error
Creating redis ...
WARNING: Host is already in use by another container
Creating mjml ... done
Creating redis ... done
ERROR: for db Cannot start service db: driver failed programming external connectivity on endpoint db (...): Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use
ERROR: Encountered errors while bringing up the project.
```
To fix this you can change which ports Baserow will use by setting the corresponding
environment variable:
- For `postgres` set `POSTGRES_PORT` which defaults to `5432`
- For `redis` set `REDIS_PORT` which defaults to `6379`
- For `mjml` set `MJML_PORT` which defaults to `28101`
- For `backend` set `BACKEND_PORT` which defaults to `8000`
- For `web-frontend` set `WEB_FRONTEND_PORT` which defaults to `3000`
- For `media` set `MEDIA_PORT` which defaults to `4000`
This is how to set these variables in bash:
```bash
$ POSTGRES_PORT=5555 REDIS_PORT=6666 MJML_PORT=7777 docker-compose up
$ # or using dev.sh
$ POSTGRES_PORT=5555 REDIS_PORT=6666 MJML_PORT=7777 ./dev.sh
```
### Change the container user
When running the dev env you can set the `UID` and `GID` environment variables when
building and running Baserow to change the user id and group id for the following
containers:
- backend
- celery
- web-frontend
> Remember you need to re-build if you change these variables or run `./dev.sh` from a
> new user.
> This is because Baserow's images build with file permissions set to the
> given `UID` and `GID`, so if they change without a re-build they will be incorrect.
When using `./dev.sh` it will automatically set `UID` and `GID` to the ids of the user
running the command for you.
### Disable automatic migration
You can disable automatic migration by setting the `MIGRATE_ON_STARTUP` environment
variable to `false` (or any value which is not `true`) like so:
```bash
$ MIGRATE_ON_STARTUP=false docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
$ # Or instead using ./dev.sh
$ ./dev.sh dont_migrate # dev.sh supports this as an explicit argument.
$ MIGRATE_ON_STARTUP=false ./dev.sh # or dev.sh will pass through whatever you have set.
```
### Run a one off migration
```bash
# Run a one off dev container using the backend image which supports the "manage" command like so:
$ docker-compose -f docker-compose.yml -f docker-compose.dev.yml run backend manage migrate
$ # Or instead using ./dev.sh
$ ./dev.sh run backend manage migrate
```
### Disable automatic template syncing
You can disable automatic baserow template syncing by setting the
`SYNC_TEMPLATES_ON_STARTUP` environment variable to `false` (or any value which is
not `true`) like so:
```bash
$ SYNC_TEMPLATES_ON_STARTUP=false docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
$ # Or instead using ./dev.sh
$ ./dev.sh dont_sync # dev.sh supports this as an explicit argument.
$ SYNC_TEMPLATES_ON_STARTUP=false ./dev.sh # or dev.sh it will pass through whatever you have set.
```
### Run a one off management command
```bash
# Run a one off dev container using the backend image which supports the "manage" command like so:
$ docker-compose -f docker-compose.yml -f docker-compose.dev.yml run backend manage sync_templates
$ # Or instead using ./dev.sh
$ ./dev.sh run backend manage sync_templates
```
## Common Problems
### Permission denied errors
If you used Baserow's dev env prior to April 2021 with the provided docker files you
might encounter permission errors in the containers when upgrading. With the old docker
files build output could end up being owned by root. These root owned files if they
still exist in your repo will cause a problem starting the new dev env as Baserow's
containers now run as a non-root user.
To fix simply ensure all files in your baserow git repo are owned by your current user
like so:
```bash
chown YOUR_USERNAME_HERE -R baserow/
```

View file

@ -7,6 +7,6 @@ environment =
PUBLIC_WEB_FRONTEND_URL='https://FRONTEND_DOMAIN',
PUBLIC_BACKEND_URL='https://BACKEND_DOMAIN'
directory = /baserow/web-frontend
command = sh -c './node_modules/.bin/nuxt start --hostname 127.0.0.1 --config-file ./config/nuxt.config.demo.js'
command = sh -c './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

View file

@ -129,7 +129,7 @@ $ cd web-frontend
$ yarn install
# Build frontend
$ ./node_modules/nuxt/bin/nuxt.js build --config-file config/nuxt.config.demo.js
$ ./node_modules/nuxt/bin/nuxt.js build --config-file config/nuxt.config.local.js
```
## Install NGINX
@ -313,7 +313,7 @@ $ baserow sync_templates
$ deactivate
$ cd web-frontend
$ yarn install
$ ./node_modules/nuxt/bin/nuxt.js build --config-file config/nuxt.config.demo.js
$ ./node_modules/nuxt/bin/nuxt.js build --config-file config/nuxt.config.local.js
$ supervisorctl reread
$ supervisorctl update
$ supervisorctl restart all

View file

@ -1,17 +1,30 @@
# Demo environment
# Running Baserow locally
If you just want to try out Baserow on your local computer, it is best to start the
demo environment via `docker-compose`.
If you just want to try out Baserow on your local computer, it is best to use
`docker-compose`. The provided `docker-compose.yml` file will launch a production
version of Baserow and can be used to run Baserow locally or as a starting point for
building your own production Baserow setup.
### Quickstart
If you are familiar with git and docker-compose run these commands to launch baserow
locally, otherwise please start from the Installing Requirements section below.
```bash
$ git clone https://gitlab.com/bramw/baserow.git
$ cd baserow
$ docker-compose up
```
## 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/.
so by following the instructions on https://docs.docker.com/desktop/ and
https://docs.docker.com/compose/install/.
If you haven't already installed git you can do so by following the instructions on
You will also need git installed which you can do 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
After installing all the required software you should be able to run the
following commands in your terminal.
```
@ -26,22 +39,22 @@ 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 demo environment
## Starting baserow using docker-compose
> 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
> Note that this has only been tested on MacOS Catalina and Ubuntu 20.04. 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-demo`.
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-demo`.
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
Baserow's code to your computer.
```
$ cd ~/baserow-demo
$ cd ~/baserow
$ git clone https://gitlab.com/bramw/baserow.git
Cloning into 'baserow'...
...
@ -50,18 +63,17 @@ $ cd baserow
Now that we have our copy of the repo and have changed directories to the newly
created `baserow`, we can bring up the containers. You just have to execute the
docker-compose command using the `docker-compose.demo.yml` file. It might take a
while for the command finishes, this is because the image has to be created from
scratch.
`docker-compose up` command. It might take a while for the command to finish, this is
because the image has to be built from scratch.
```
$ docker network create baserow_demo_default
$ docker-compose -f docker-compose.demo.yml up
$ docker-compose up
Building backend
...
Starting baserow_db_1 ... done
Starting baserow_mjml_1 ... done
Starting db ... done
Starting mjml ... done
Starting backend ... done
Starting celery ... done
Starting web-frontend ... done
```
@ -69,5 +81,8 @@ Once everything has finished, you can visit http://localhost:3000 in your browse
and you should be redirected to the login screen. From here you can create a new account
and start using the software.
> I strongly discourage running these images in production. These are just for demo
> purposes only.
## Further Reading
- See [docker how to guide](baserow-docker-how-to.md) for a larger collection of
useful operations and commands.
- See [docker usage](../reference/baserow-docker-api.md) for more detail on how
Baserow's docker setup can be used and configured.

View file

@ -2,10 +2,10 @@
Baserow is an open-source online database tool. Users can use this no-code platform to
create a database without any technical experience. It lowers the barriers to app
creation so that anyone who can work with a spreadsheet can also create a database. The
interface looks a lot like a spreadsheet. Our goal is to provide a perfect and fast
user experience while keeping it easy for developers to write plugins and maintain the
codebase. The developer documentation contains several topics you might need as a
creation so that anyone who can work with a spreadsheet can also create a database. The
interface looks a lot like a spreadsheet. Our goal is to provide a perfect and fast user
experience while keeping it easy for developers to write plugins and maintain the
codebase. The developer documentation contains several topics you might need as a
developer.
## Getting started
@ -14,10 +14,10 @@ New to Baserow? This is the place to start.
* [Introduction](./getting-started/introduction.md): An introduction to some important
concepts before using Baserow.
* [API](./getting-started/api.md): An introduction to the REST API and information
about API resources.
* [API](./getting-started/api.md): An introduction to the REST API and information about
API resources.
* [WebSocket API](./getting-started/web-socket-api.md): An introduction to the
WebSockets API which is used to broad cast real time updates.
WebSockets API which is used to broadcast real time updates.
* [Database plugin](./getting-started/database-plugin.md) An introduction to the
database plugin which is installed by default.
@ -25,42 +25,57 @@ New to Baserow? This is the place to start.
Need some help with setting things up?
* [Local demo](./guides/demo-environment.md): Run a local demo on your computer using
`docker-compose`.
* [Install on Ubuntu](./guides/installation/install-on-ubuntu.md): A step by step guide
on how to install Baserow on an Ubuntu server.
* [Install on Cloudron](guides/installation/install-on-cloudron.md): Instructions on
how to manually install Baserow on Cloudron.
* [Running Locally](guides/running-baserow-locally.md): A step-by-step guide to run
Baserow on your computer.
* [Install on Ubuntu](./guides/installation/install-on-ubuntu.md): A step-by-step guide
to install Baserow on an Ubuntu server.
* [Install on Cloudron](guides/installation/install-on-cloudron.md): Instructions
to manually install Baserow on Cloudron.
## Development
Everything related to contributing and developing for Baserow.
* [Development environment](./development/development-environment.md): Setting up your
local development environment using `docker-compose`.
* [Development environment](./development/development-environment.md): More detailed
information on baserow's local development environment.
* [Running the Dev Environment](development/running-the-dev-environment.md): A
step-by-step guide to run Baserow for development.
* [Directory structure](./development/directory-structure.md): The structure of all the
directories in the Baserow repository explained.
* [Tools](./development/tools.md): The tools (flake8, pytest, eslint, etc) and how to
use them.
* [Tools](./development/tools.md): The tools (flake8, pytest, eslint, etc) and how to
use them.
* [Code quality](./development/code-quality.md): More information about the code style,
quality, choices we made, and how we enforce them.
* [Create a template](./development/create-a-template.md): Create a template that can
be previewed and installed by others.
* [Create a template](./development/create-a-template.md): Create a template that can be
previewed and installed by others.
* [dev.sh](./development/dev_sh.md): Further details on how to use Baserow's `./dev.sh`
helper script.
## FAQs
* [Baserow Docker How To](./guides/baserow-docker-how-to.md): Common operations and
solutions for working with baserow's docker environments.
## Reference
* [Baserow Docker API](./reference/baserow-docker-api.md): An API reference with all
supported environment variables, command line arguments and usage patterns for
Baserow's docker images and compose files.
## Plugins
Everything related to custom plugin development.
* [Plugin basics](./plugins/introduction.md): An introduction into Baserow plugins.
* [Plugin boilerplate](./plugins/boilerplate.md): Don't reinvent the wheel, use
the boilerplate for quick plugin development.
* [Create application](./plugins/application-type.md): Want to create an application
* [Plugin boilerplate](./plugins/boilerplate.md): Don't reinvent the wheel, use the
boilerplate for quick plugin development.
* [Create application](./plugins/application-type.md): Want to create an application
type? Learn how to do that here.
* [Create database table view](./plugins/view-type.md): Display table data like a
* [Create database table view](./plugins/view-type.md): Display table data like a
calendar, Kanban board or however you like by creating a view type.
* [Create database table view filter](./plugins/view-filter-type.md): Filter the rows
of a view with custom conditions.
* [Create database table field](./plugins/field-type.md): You can store data in a
custom format by creating a field type.
* [Creata a field converter](./plugins/field-converter.md): Converters alter a
field and convert the related data for specific field changes.
* [Create database table view filter](./plugins/view-filter-type.md): Filter the rows of
a view with custom conditions.
* [Create database table field](./plugins/field-type.md): You can store data in a custom
format by creating a field type.
* [Creata a field converter](./plugins/field-converter.md): Converters alter a field and
convert the related data for specific field changes.

View file

@ -0,0 +1,135 @@
# Baserow's Docker API
Baserow uses docker and docker-compose when running the local or development
environments. Below you will find details on how this is structured, how to configure
baserow running this way and usage references.
## Baserow's Docker Files
Below are the files used by our docker setup and what they are responsible for:
### The Local Env
- `docker-compose.yml`: A compose file which starts Baserow in local mode with no
development features enabled.
- `./backend/Dockerfile`: The backend's Dockerfile for local mode. See below for
supported command line arguments. Also used to run the celery worker.
- `./web-frontend/Dockerfile`: The web-frontend's Dockerfile for local mode. See below
for supported command line arguments.
- `./media/Dockerfile`: A simple nginx image used to serve uploaded user files only.
### The Dev Env
- `docker-compose.dev.yml`: A compose file which overrides parts of `docker-compose.yml`
to enable development features, do not use this in production.
- `./backend/docker/Dockerfile.dev`: The backends's Dockerfile for dev mode.
- `./web-frontend/docker/Dockerfile.dev`: The web-frontend's Dockerfile for dev mode.
### For Both Envs
- `./backend/docker/docker-entrypoint.sh`: The entrypoint script used for both of the
backend images.
- `./web-frontend/docker/docker-entrypoint.sh`: The entrypoint script used for both of
the web-frontend images.
## Backend Image CLI
The `baserow_backend` and `baserow_backend_dev` images provide various commands used to
change what process is started inside the container.
```bash
Usage: docker run <imagename> COMMAND
Commands
local : Start django using a prod ready gunicorn server
dev : Start a normal Django development server
bash : Start a bash shell
manage : Start manage.py
python : Run a python command
shell : Start a Django Python shell
celery : Run celery
celery-dev: Run a hot-reloading dev version of celery
lint: : Run the linting
help : Show this message
```
You can run one of these as a one off command like so:
```bash
# In the local environment
$ docker-compose run backend COMMAND
# In the dev environment
$ ./dev.sh run backend COMMAND
```
## Web Frontend CLI
The `baserow_web-frontend` and `baserow_web-frontend_dev` images provide various commands
used to change what process is started inside the container.
```bash
Usage: docker run <imagename> COMMAND
Commands
dev : Start a normal nuxt development server
local : Start a non-dev prod ready nuxt server
lint : Run the linting
lint-fix : Run eslint fix
bash : Start a bash shell
help : Show this message
```
You can run one of these as a one off command like so:
```bash
# In the local environment
$ docker-compose run web-frontend COMMAND
# In the dev environment
$ ./dev.sh run web-frontend COMMAND
```
## Environment Variables
See [the introduction](../getting-started/introduction.md) for the environment variables
supported specifically by the backend and web-frontend processes. Below are the
variables available for configuring baserow's docker setup.
All of these variables can be set like so:
```bash
$ POSTGRES_PORT=5555 REDIS_PORT=6666 MJML_PORT=7777 docker-compose up
$ # or using dev.sh
$ POSTGRES_PORT=5555 MIGRATE_ON_STARTUP=false ./dev.sh
```
### Local and Dev Variables
Port configuration (these only work when used with the docker-compose files):
- `POSTGRES_PORT` (default `5432`) : The port the `db` container will bind to on your
local network.
- `REDIS_PORT` (default `6379`) : The port the `redis` container will bind to on your
local network.
- `MJML_PORT` (default `28101`) : The port the `mjml` container will bind to on your
local network.
- `BACKEND_PORT` (default `8000`) : The port the `backend` container will bind to on
your local network.
- `WEB_FRONTEND_PORT` (default `3000`) : The port the `web-frontend` container will bind
to on your local network.
- `MEDIA_PORT` (default `4000`) : The port the `media` nginx container will bind to on
your local network.
Backend configuration:
- `MIGRATE_ON_STARTUP` (default `true`) : When `true` on backend server startup it will
perform a django migration before launching the backend server.
- `SYNC_TEMPLATES_ON_STARTUP` (default `true`) : When `true` on backend server startup
it will run the baserow management command `sync_templates` which loads any templates
found in `./backend/templates` into Baserow.
### Dev Only Variables
- `UID` (default `1000` or your user id when using `./dev.sh`) : Sets which user id will
be used to build Baserow's images with and the user id which will be used to run the
processes inside Baserow containers.
- `GID` (default `1000` or your group id when using `./dev.sh`) : Sets which group id
will be used to build Baserow's images with and the group id which will be used to run
the processes inside Baserow containers.

15
media/Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM nginx:1.19.10
ARG UID
ENV UID=${UID:-9999}
ARG GID
ENV GID=${GID:-9999}
# The nginx image already creates a non-root user to run as, update its ids so they
# match the provided UID and GID we wish to build and run this image with.
# If GID or UID already exist that's OK no need to stop the build.
RUN groupmod -g ${GID} nginx
RUN usermod -u ${UID} -g ${GID} nginx
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d

28
media/nginx.conf Normal file
View file

@ -0,0 +1,28 @@
client_body_temp_path /run/client_body;
proxy_temp_path /run/proxy_temp;
fastcgi_temp_path /run/fastcgi_temp;
scgi_temp_path /run/scgi_temp;
uwsgi_temp_path /run/uwsgi_temp;
server {
access_log /dev/stdout;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
gzip on;
gzip_disable "msie6";
listen 80;
proxy_read_timeout 1800s;
client_max_body_size 0; # avoid HTTP 413 for large image uploads
# required to avoid HTTP 411: see Issue #1486 (https://github.com/dotcloud/docker/issues/1486)
chunked_transfer_encoding on;
location /media/ {
alias /baserow/media/;
}
}

View file

@ -19,7 +19,7 @@ services:
mjml:
container_name: {{ cookiecutter.project_slug }}-mjml
image: liminspace/mjml-tcpserver:latest
image: liminspace/mjml-tcpserver:0.10
ports:
- 28101:28101

View file

@ -1 +1 @@
default_app_config = 'baserow_premium.config.BaserowPremiumConfig'
default_app_config = "baserow_premium.config.BaserowPremiumConfig"

View file

@ -2,4 +2,4 @@ from django.apps import AppConfig
class BaserowPremiumConfig(AppConfig):
name = 'baserow_premium'
name = "baserow_premium"

View file

View file

@ -0,0 +1,6 @@
import pytest
@pytest.mark.django_db
def test_premium_app_installed(settings):
assert "baserow_premium" in settings.INSTALLED_APPS

View file

@ -1 +1,5 @@
export default ({}) => {}
import { PremPlugin } from '@baserow_premium/plugins'
export default ({ app }) => {
app.$registry.register('plugin', new PremPlugin())
}

View file

@ -0,0 +1,7 @@
import { BaserowPlugin } from '@baserow/modules/core/plugins'
export class PremPlugin extends BaserowPlugin {
static getType() {
return 'plugin'
}
}

View file

@ -0,0 +1,24 @@
module.exports = {
rootDir: '../../',
testEnvironment: 'node',
expand: true,
forceExit: true,
moduleNameMapper: {
'^@baserow/(.*)$': '<rootDir>/../../$1',
'^@baserow_premium/(.*)$': '<rootDir>/$1',
'^@/(.*)$': '<rootDir>/$1',
'^~/(.*)$': '<rootDir>/$1',
'^vue$': 'vue/dist/vue.common.js',
},
moduleFileExtensions: ['js', 'vue', 'json'],
transform: {
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest',
},
transformIgnorePatterns: ['node_modules/(?!(baserow)/)'],
collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/components/**/*.vue',
'<rootDir>/pages/**/*.vue',
],
}

View file

@ -0,0 +1,8 @@
const baseConfig = require('../jest.base.config')
module.exports = Object.assign({}, baseConfig, {
testEnvironment: 'jsdom',
testMatch: ['<rootDir>/test/unit/**/*.spec.js'],
displayName: 'premium-unit',
setupFilesAfterEnv: ['./test/unit/jest.setup.js'],
})

View file

@ -0,0 +1,13 @@
import Vue from 'vue'
import { config } from '@vue/test-utils'
Vue.config.silent = true
// Mock Nuxt components
config.stubs.nuxt = { template: '<div />' }
config.stubs['nuxt-link'] = { template: '<a><slot /></a>' }
config.stubs['no-ssr'] = { template: '<span><slot /></span>' }
process.on('unhandledRejection', (err) => {
fail(err)
})

View file

@ -0,0 +1,47 @@
import Error from '@baserow/modules/core/components/Error'
import { bootstrapVueContext } from '@baserow/test/helpers/components'
describe('Error Component Tests', () => {
let vueContext = null
beforeEach(() => {
vueContext = bootstrapVueContext()
})
afterEach(() => {
vueContext.teardownVueContext()
})
function errorComponent(props) {
return vueContext.vueTestUtils.shallowMount(Error, {
localVue: vueContext.vue,
propsData: props,
})
}
test('When visible prop is true title and message are shown', () => {
const error = errorComponent({
error: {
visible: true,
title: 'TestError',
message: 'message',
},
})
const html = error.html()
expect(html).toMatch('TestError')
expect(html).toMatch('message')
})
test('When visible prop is false no html is rendered', () => {
const error = errorComponent({
error: {
visible: false,
title: 'TestError',
message: 'message',
},
})
expect(error.html()).toStrictEqual('')
})
})

View file

@ -1,68 +0,0 @@
#!/bin/bash
tabname() {
printf "\e]1;$1\a"
}
print_manual_instructions(){
COMMAND=$1
CONTAINER_COMMAND=$2
echo -e "\nOpen a new tab/terminal and run:"
echo " $COMMAND"
echo "Then inside the container run:"
echo " $CONTAINER_COMMAND"
}
PRINT_WARNING=true
new_tab() {
TAB_NAME=$1
COMMAND=$2
CONTAINER_COMMAND=$3
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [ -x "$(command -v gnome-terminal)" ]; then
gnome-terminal \
--tab --title="$TAB_NAME" --working-directory=`pwd` -- $COMMAND -c \
"echo '$CONTAINER_COMMAND'; $CONTAINER_COMMAND; exec bash"
else
if $PRINT_WARNING; then
echo -e "\nWARNING: gnome-terminal is the only currently supported way of opening
multiple tabs/terminals for linux by this script, add support for your setup!"
PRINT_WARNING=false
fi
print_manual_instructions "$COMMAND" "$CONTAINER_COMMAND"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
osascript \
-e "tell application \"Terminal\"" \
-e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
-e "do script \"printf '\\\e]1;$TAB_NAME\\\a'; $COMMAND\" in front window" \
-e "do script \"$CONTAINER_COMMAND\" in front window" \
-e "end tell" > /dev/null
else
if $PRINT_WARNING; then
echo -e "\nWARNING: The OS '$OSTYPE' is not supported yet for creating tabs to setup
baserow's dev environemnt, please add support!"
PRINT_WARNING=false
fi
print_manual_instructions "$COMMAND" "$CONTAINER_COMMAND"
fi
}
docker-compose up -d
new_tab "Backend" \
"docker exec -it backend bash" \
"python src/baserow/manage.py runserver 0.0.0.0:8000"
new_tab "Backend celery" \
"docker exec -it backend bash" \
"watchmedo auto-restart --directory=./ --pattern=*.py --recursive -- celery -A baserow worker -l INFO"
new_tab "Web frontend" \
"docker exec -it web-frontend bash" \
"yarn run dev"
new_tab "Web frontend eslint" \
"docker exec -it web-frontend bash" \
"yarn run eslint --fix"

View file

@ -1,3 +0,0 @@
#!/bin/bash
docker-compose kill

View file

@ -0,0 +1,2 @@
.nuxt/
coverage

50
web-frontend/Dockerfile Normal file
View file

@ -0,0 +1,50 @@
FROM node:10-buster
ARG UID
ENV UID=${UID:-9999}
ARG GID
ENV GID=${GID:-9999}
# Perform all OS package installation and cleanup in one single command to reduce the
# size of the created layer.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
curl \
gnupg2 \
dos2unix \
tini \
&& apt-get autoclean \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
# The node image already creates a non-root user to run as, update its ids so they
# match the provided UID and GID we wish to build and run this image with.
# If GID or UID already exist that's OK no need to stop the build.
RUN groupmod -g ${GID} node || exit 0
RUN usermod -u ${UID} -g ${GID} node || exit 0
USER $UID:$GID
# Create and install the dependencies in separate ADD commands
ADD --chown=$UID:$GID ./web-frontend/package.json ./web-frontend/yarn.lock /baserow/web-frontend/
WORKDIR /baserow/web-frontend
# We still need dev-dependencies as we will be running a nuxt build below
RUN yarn install
ADD --chown=$UID:$GID ./web-frontend /baserow/web-frontend/
ADD --chown=$UID:$GID ./premium/web-frontend /baserow/web-frontend/plugins/premium
RUN yarn run build-local
RUN dos2unix /baserow/web-frontend/docker/docker-entrypoint.sh && \
chmod a+x /baserow/web-frontend/docker/docker-entrypoint.sh
# tini installed above protects us from zombie processes and ensures the default signal
# handlers work, see https://github.com/krallin/tini.
ENTRYPOINT ["/usr/bin/tini", "--", "/bin/bash", "/baserow/web-frontend/docker/docker-entrypoint.sh"]
CMD ["local"]

View file

@ -1,16 +0,0 @@
FROM node:10
ADD . /web-frontend
WORKDIR /web-frontend
RUN apt-get update
RUN apt-get -y install make
RUN apt-get -y install curl
RUN apt-get -y install gnupg2
RUN make install-dependencies
RUN yarn install
RUN yarn run build
ENTRYPOINT yarn run demo

View file

@ -1,12 +0,0 @@
FROM node:10
ADD . /web-frontend
WORKDIR /web-frontend
RUN apt-get update
RUN apt-get -y install make
RUN apt-get -y install curl
RUN apt-get -y install gnupg2
CMD tail -f /dev/null

View file

@ -9,6 +9,8 @@ stylelint:
lint: eslint stylelint
lint-javascript: lint
jest:
yarn run jest-all || exit;

View file

@ -1,8 +1,17 @@
export default function (base = '@') {
// Support adding in extra modules say from a plugin using the ADDITIONAL_MODULES
// env variable which is a comma separated list of absolute module paths.
const additionalModulesCsv = process.env.ADDITIONAL_MODULES
const additionalModules = additionalModulesCsv
? additionalModulesCsv.split(',')
: []
const baseModules = [
base + '/modules/core/module.js',
base + '/modules/database/module.js',
]
const modules = baseModules.concat(additionalModules)
return {
modules: [
base + '/modules/core/module.js',
base + '/modules/database/module.js',
],
modules,
}
}

View file

@ -1,3 +1,5 @@
import base from './nuxt.config.base.js'
// WARNING: This file is deprecated and you should switch to using nuxt.config.local.js
export default base()

View file

@ -0,0 +1,3 @@
import base from './nuxt.config.base.js'
export default base()

View file

@ -0,0 +1,50 @@
FROM node:10-buster
ARG UID
ENV UID=${UID:-1000}
ARG GID
ENV GID=${GID:-1000}
# Perform all OS package installation and cleanup in one single command to reduce the
# size of the created layer.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
curl \
gnupg2 \
dos2unix \
tini \
&& apt-get autoclean \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
# The node image already creates a non-root user to run as, update its ids so they
# match the provided UID and GID we wish to build and run this image with.
# If GID or UID already exist that's OK no need to stop the build.
RUN groupmod -g ${GID} node || exit 0
RUN usermod -u ${UID} -g ${GID} node || exit 0
USER $UID:$GID
# Create and install the dependencies in separate ADD commands
ADD --chown=$UID:$GID ./web-frontend/package.json ./web-frontend/yarn.lock /baserow/web-frontend/
WORKDIR /baserow/web-frontend
RUN yarn install
ADD --chown=$UID:$GID ./web-frontend /baserow/web-frontend/
ADD --chown=$UID:$GID ./premium/web-frontend /baserow/web-frontend/plugins/premium
RUN dos2unix /baserow/web-frontend/docker/docker-entrypoint.sh && \
chmod a+x /baserow/web-frontend/docker/docker-entrypoint.sh
# Ensure we don't pollute the devs actual repo when mounting in files by
# putting these two folders into anonymous docker volumes.
VOLUME ["/baserow/web-frontend/plugins"]
# tini installed above protects us from zombie processes and ensures the default signal
# handlers work, see https://github.com/krallin/tini.
ENTRYPOINT ["/usr/bin/tini", "--", "/bin/bash", "/baserow/web-frontend/docker/docker-entrypoint.sh"]
CMD ["dev"]

View file

@ -0,0 +1,49 @@
#!/bin/bash
# Bash strict mode: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
show_help() {
# If you change this please update ./docs/reference/baserow-docker-api.md
echo """
Usage: docker run <imagename> COMMAND
Commands
dev : Start a normal nuxt development server
local : Start a non-dev prod ready nuxt server
lint : Run the linting
lint-fix : Run eslint fix
bash : Start a bash shell
help : Show this message
"""
}
case "$1" in
dev)
CMD="yarn run dev"
echo "$CMD"
# The below command lets devs attach to this container, press ctrl-c and only
# the server will stop. Additionally they will be able to use bash history to
# re-run the containers run server command after they have done what they want.
exec bash --init-file <(echo "history -s $CMD; $CMD")
;;
local)
exec yarn run start
;;
lint)
exec make lint-javascript
;;
lint-fix)
CMD="yarn run eslint --fix"
echo "$CMD"
exec bash --init-file <(echo "history -s $CMD; $CMD")
;;
bash)
exec /bin/bash "${@:2}"
;;
*)
show_help
exit 1
;;
esac

View file

@ -1,3 +1,3 @@
module.exports = {
projects: ['test/server', 'test/unit'],
projects: ['test/server', 'test/unit', 'plugins/*/test/unit'],
}

View file

@ -7,9 +7,9 @@
"license": "MIT",
"scripts": {
"build": "nuxt build",
"build-local": "nuxt build --config-file ./config/nuxt.config.local.js",
"dev": "nuxt --hostname 0.0.0.0",
"start": "nuxt start --hostname 0.0.0.0",
"demo": "nuxt start --hostname 0.0.0.0 --config-file config/nuxt.config.demo.js",
"eslint": "eslint --ext .js,.vue .",
"stylelint": "stylelint **/*.scss --syntax scss",
"jest": "jest -i --verbose false",