-
Notifications
You must be signed in to change notification settings - Fork 40
Local development setup
Development these days uses Go, NVM (to manage your NodeJS install), Yarn 1.x (a NodeJS package manager), and Docker.
On Ubuntu 20.04, these steps should work:
$ git clone https://github.com/sqlitebrowser/dbhub.io
$ cd dbhub.io
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
$ nvm install --latest-npm --lts 18
$ nvm alias default 18
$ nvm use 18
Confirm version 18 of NodeJS is active:
$ nvm list
Download the appropriate installation package from the Go download page, then follow the instructions there to install it and verify your installation.
$ npm install --global [email protected]
$ sudo apt install docker.io
$ yarn docker:build
This will take a few minutes, and likely download a GB or so of various docker image layers.
$ yarn docker:startlocal
$ yarn docker:recompile
You use yarn
commands to control things.
For the full list of the DBHub.io yarn commands, look at the package.json file in the repo. Specifically look at the "script" section:
The command yarn docker:startlocal
starts the DBHub.io docker container you just
created, with the DBHub.io daemons listening on specific tcp ports:
- DBHub.io web interface daemon listening on https://localhost:9443
- DBHub.io API daemon listening on https://localhost:9444
- DB4S end point daemon listening on https://localhost:9445.
You should be able to connect to either of the first two with a web browser, though you will need to tell it to ignore the invalid https certificate(s) they use. 😉
$ yarn cypress:install
This downloads the Cypress (test suite) binary for your system, so the other yarn Cypress commands can use it.
The most useful Yarn commands (from that package.json file) are:
Compiles your local DBHub.io source code in the container. eg any changes you've made in your local source code directory will be picked up and compiled into the running container
This command now does restart the running DBHub.io daemons in the container after recompiling, so you don't need to manually restart the daemons afterwards.
Restarts the DBHub.io daemons running inside the local Docker container. Useful if you've changed stuff in the templates. If you've changed the backend Go code though, you'll need to recompile instead.
Stops the local DBHub.io docker container
Connects psql (the PostgreSQL cli) to the database running inside the container
Shows the console output of the DBHub.io daemons in the container. Only works
after they've been restarted at least once though (eg after yarn docker:restart
)
Downloads and installs the Cypress (test suite) executable
Opens the Cypress GUI. Only works after you've installed Cypress using
yarn cypress:install
.
Run the test suite on the DBHub.io daemons in the local Docker container,
reporting pass/failure, etc. The test
variant uses the bundled
Electron browser, whereas the testff
variant uses a locally installed
Firefox to test with, if it's installed.
JetBrains IDEA allows for remote debugging of Go executables (when configured).
So, there are two additional yarn
commands useful here:
This does the same thing as yarn docker:startlocal
, but it additionally
opens up a few more ports in the local Docker container so IDEA can debug
the running Go executables.
So, use this instead of yarn docker:startlocal
when you're using JetBrains
IDEA.
Restarts the DBHub.io daemons inside the local docker container, but does so in a way that makes them ready for debugging.
Use this instead of yarn docker:restart
when you're using JetBrains IDEA
and want to do a debugging session.
Note that when you're using this command, you cannot connect to the DBHub.io daemons in your docker contain using a web browser until you've first start a debugging session in your IDE.
eg configure Jetbrains IDEA to connect to them, then press the "Debug" button in IDEA
Configuration in the Jetbrains IDEA GUI is super simple. Here's the screenshot from mine:
You only really need to get the host (localhost
) and port (2345
) right
to match what the Docker container is using.
- Port 2345 for the DBHub.io webUI daemon
- Port 2346 for the DBHub.io API daemon
- Port 2347 for the DB4S end point daemon
- I haven't yet setup the DB4S end point in the docker container though, so there's no port number for it yet