Question about working with the codebase on docker

Please fill in the questionnaire below.

Technical Help Questionnaire

Have you read and followed the instructions at: *READ ME FIRST* Technical Help FAQs - #2 by nigel ?
Answer: Yes

Hi, I tried to install the project with docker through the docker tutorial and it works just fine. I am able to navigate on the frontend and everything runs smooth.

Now, my question is regarding being able to work on the code.
I’d like to have the project source code that is inside the container mounted into my computer, so whenever I make a change in a file, it will reflect on the docker image as well.

So the first command in the quick start

docker run \
  -d \
  --name baserow \
  -e BASEROW_PUBLIC_URL=http://localhost \
  -v baserow_data:/baserow/data \
  -p 80:80 \
  -p 443:443 \
  --restart unless-stopped \
  baserow/baserow:1.17.0

I see baserow/data folder being mounted to my computer, so I tried to change that to
-v baserow_src:/baserow \ so I could see the entire codebase

That mounted baserow_src but it’s empty with an error occuring when trying to run the container:

/baserow.sh: line 106: /baserow/supervisor/default_baserow_env.sh: No such file or directory

I see on line 116 of the baserow.sh that probably the error is caused by not having the data folder mounted, so I tried to mount both:

docker run \
  -d \
  --name baserow \
  -e BASEROW_PUBLIC_URL=http://localhost \
  -v baserow_data:/baserow/data -v baserow_src:/baserow/ \
  -p 80:80 \
  -p 443:443 \
  --restart unless-stopped \
  baserow/baserow:1.17.0

but that did not work either.

I’m not super expert with Docker, but have used it before and usually this is the way I’d go for working on a project: make the source code from the container mount in my computer, so I can use my IDE to visualize the project. How can I achieve this here?
I’m probably missing something very basic here, so sorry if it’s a stupid question

I also tried to find some resources on https://baserow.io/installation/install-with-docker/
but the link is broken

I also tried to mount to baserow/backend instead of just baserow/ and the container runs with no problem, but the only folder that seems to mount is baserow/backend/data , and no file to it.

I’m clueless now on what’s going on :sweat_smile:

Hi @Julie , we have dev scripts all ready to go which do all of this mounting for you the correct way. We also provide setup guides for intellij and vscode.

Check out our development docs at Baserow’s dev environment // Baserow for more info.

Hi Nigel, thanks for the reply.
I use PyCharm as my main IDE. I tried looking at the guide for Intellij to see if it would give me some clue about it, but the way I see on that setup it does not use any dockerization at all. It instructs me to clone the repo at the very beginning and then install/config things manually which in my view seems unnecessary if you already have a docker image built with all that done.

With PyCharm there’s a smooth docker integration that I also tried to use and to mount volumes but no success.

I tried then this other option https://baserow.io/docs/development%2Frunning-the-dev-environment

and when I run ./dev.sh it gets stuck on Container baserow-db-1, so the script does not finish as you can see on my screenshot

What are the logs for the baserow-db-1 container?

On the intellij/pycharm guide, sure you could mount the virtualenv in our docker images and make it available to Intellij and also do the same with the postgres container if you don’t want to follow the guide exactly. It’s just we personally find it much easier to be able to run tests directly in Intellij without first having to startup and run an entire docker env (all you need is a virtual env + postgres + the node modules installed).

here are the logs I get from Docker Desktop (macOS)

On the docker desktop I see db-1 as running. Can confirm that on terminal by running docker ps as shows the screenshot:

However the dev.sh script is still stuck showing “Starting” for db-1

Is that the full docker ps screenshot? I’d be expecting to see a bunch of extra Baserow services running also like the backend/celery worker/celery export worker services also.

Yeah these are the only ones that are running. Others are created but not running (see screenshot)

Also worth to mention the db-1 only actually runs if I restart it standalone.


Comparing the 2 screenshots my guess is that the other services you’d expect to see running are not running just created because the script is stuck at db-1

Notice, I don’t actually get logs for db-1 (see 3rd image, that’s where the logs stop) . I was only able to get these logs before that I sent to you, because I specifically restarted the db-1 service through docker desktop, which “works” to start it but I guess doing that won’t help the script to progress with the overall setup

This is all the logs I get actually

Could it be because I have another database already on my localhost:5432 ?

Yup that will be it, the db will be failing to startup as our docker-compose.dev.yml tries to bind it to 5432 by default. Try doing POSTGRES_PORT=SOME_OTHER_FREE_PORT ./dev.sh (you can also make a .env file in the git repo root and set POSTGRES_PORT=xxxx to not have to remember every time).

Alright, that was exactly the problem.

Think it would be nice to mention in that page that one needs to change the db PORT in the docker-compose.yml file in case the PORT is already in use, cause it’s hard to identify that is the issue since logs don’t show anything

Anyhow, now I get a new error😅 . See screenshot below:

So the dev env has started up from the looks at it, we then try to open brand new terminal tabs and attach to each container so you have a tab showing you the logs for each of our services.

This part of ./dev.sh for macos tries to do this with osascript to make terminal tabs. You can instead just pass the no_attach argument to ./dev.sh to prevent this and then manually look at the logs of the containers and/or exec into the containers to run the tests / management commands etc.

Ah fantastic. But everything seems to be working fine now. Thank you so much Nigel! :star_struck: