Rather than running your own local Postgres and Redis servers, you can run hylo-node in a docker container that uses docker-compose to start a local instance of Postgres and Redis. VSCode can manage this process fairly transparently.
To learn about managing a dev environment with VSCode Remote Container, read this tutorial: https://code.visualstudio.com/docs/remote/containers-tutorial
When you have the Remote - Containers
extension installed, simply open this
repository in VSCode and select the Reopen in container
option when it pops
up. From there, yarn run dev
should work immediately.
Contributors who do not use VSCode may still wish to run the backend services via Docker to simplify configuration. You may do this by running the following command from the repo root:
docker-compose -f .devcontainer/docker-compose.servicesonly.yml up
Once the DB & Redis are active, you can boot the Hylo web app with the usual
npm run dev
command.
Note that this requires a minimum of Docker Compose v1.27 in order to run.
(All commands given relative to the .devcontainer
folder.)
- Postgres will already be running if you are using the VSCode container integration. If you manage the containers yourself, ensure they are online:
docker-compose -f docker-compose.servicesonly.yml up
- Run the seed script against the DB container:
- Change your
.env
file to setDATABASE_URL=postgres://postgres:postgres@db:5432/hylo
so that the seed container can resolve to the correct host. - Run
docker-compose -f docker-compose.seed.yml up
. The script should terminate with a 0 exit code. - Restore your
DATABASE_URL
to the appropriate URI to be resolved by the Hylo node backend in your setup. (If running the node service locally or in VSCode, this should belocalhost
.)
- Change your
(*In a VSCode configuration you may be able to run the
init-db.sh
command directly within the VSCode terminal, but YMMV.)
You can begin by copying .env.example
to .env
. These values allow the server
to talk to the Postgres and Redis servers running alongside hylo-node. The
example file contains invalid values for OAuth clients (e.g. Google and
Facebook), so be sure to fill in real values if you plan to use those
integrations.
If you have an existing configuration, the two configuration parameters to pay attention to are:
DATABASE_URL=postgres://postgres:postgres@localhost:5432/hylo
REDIS_URL=redis://localhost:6379