Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Local development setup

Justin Clift edited this page Feb 10, 2023 · 17 revisions

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:

1. Clone the DBHub.io source code repository

$ git clone https://github.com/sqlitebrowser/dbhub.io
$ cd dbhub.io

2. Install NVM

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

3. Install NodeJS version 14 (not any other version!)

$ nvm install --latest-npm --lts 14
$ nvm alias default 14
$ nvm use 14

Confirm version 14 of NodeJS is active:

$ nvm list

4. Install Go manually

Download the appropriate installation package from the Go download page, then follow the instructions there to install it and verify your installation.

5. Install Yarn 1.x

$ npm install --global [email protected]

6. Install Docker

$ sudo apt install docker.io

7. Build local DBHub.io Docker image

$ yarn docker:build

This will take a few minutes, and likely download a GB or so of various docker image layers.

8. Start the DBHub.io Docker container

$ yarn docker:startlocal
$ yarn docker:recompile
$ yarn docker:restart

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:

https://github.com/sqlitebrowser/dbhub.io/blob/ed2459acec21b1c1030e14955ca3c4d04e1518dd/package.json#L11-L28

The command yarn docker:startlocal starts the DBHub.io docker container you just created, with DBHub.io web interface listening on https://localhost:9443, and DBHub.io API server listening on https://localhost:9444.

You should be able to connect to either of those with a web browser, though you will need to tell it to ignore the invalid https certificate they use. 😉

Install Cypress

$ yarn cypress:install

This downloads the Cypress (test suite) binary for your system, so the other yarn Cypress commands can use it.

The yarn commands

The most useful Yarn commands (from that package.json file) are:

yarn docker:recompile

Compiles your local DBHub.io source code in the container. eg any changes you've made in your local directory will be picked up and compiled into the running container

This command doesn't restart the running DBHub.io daemons in the container after recompiling though, so you'll need to do the restart next.

yarn docker:restart

Restarts the DBHub.io daemons running inside the local Docker container. Useful if you've changed stuff in the templates, or have recompiled the backend code.

yarn docker:stop

Stops the local DBHub.io docker container

yarn docker:psql

Connects psql (the PostgreSQL cli) to the database running inside the container

yarn docker:tail

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)

yarn cypress:install

Downloads and installs the Cypress (test suite) executable

yarn cypress:open

Opens the Cypress GUI. Only works after you've installed Cypress using yarn cypress:install.

yarn cypress:test

Run the test suite on the DBHub.io daemons in the local Docker container, reporting pass/failure, etc.

Using JetBrains IDEA as your IDE

JetBrains IDEA allows for remote debugging of Go executables (when configured).

So, there are two additional yarn commands useful here:

yarn docker:startdebug

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.

yarn docker:debug

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:

2023 02 10_17 24-Jetbrains_idea_remote_go_config

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
  • I haven't yet setup the DB4S end point in the docker container though, so there's no port number for it yet
Clone this wiki locally