PHIN VADS written in Go. Load phinvads.dump
into a PostgreSQL database using pg_restore
, run the app with air, and go!
Clone down the repository:
git clone https://github.com/CDCgov/phinvads-go.git
cd phinvads-go
Create a .env
file:
cp .env.sample .env
direnv
We use direnv
to automatically set environment variables on a per-project basis. The .envrc
file found in the project's directory tells direnv
to read in the environment variables specified in the .env
file.
Follow these steps to set up direnv
on your machine:
brew install direnv
)direnv allow
in the project directoryWhen navigating into the phinvads-go
project directory, you should see something like this in your terminal, which lets you know that the environment variables are loaded:
direnv: export +DB_HOST +DB_NAME +DB_PASSWORD +DB_PORT +DB_USER +HOST +PORT
In this section, we'll:
You may choose to manage your database using Docker. phinvads-go
provides a Docker Compose file to allow for a streamlined database setup. Please download and install Rancher Desktop if you don't already have it installed.
Note: If you'd prefer to install PostgreSQL locally, please skip the rest of this section and refer to the Local Database Setup section instead.
To start your database, run this command:
make startdb
Next, please follow these steps in order to load in the data:
phinvads.dump
into the top level of your /phinvads-go
project directory (Please let an engineering team member know if you need a copy of phinvads.dump
)make startdb
(if the container isn't already running)make refreshdb
to create the phinvads
database and load in the dataIn order to run the app you'll need to have completed the following steps:
Install Go
Install air:
go install github.com/air-verse/air@latest
Install templ
go install github.com/a-h/templ/cmd/templ@latest
Install mkcert
Create your own self-signed certs for local development:
cd tls
mkcert -install
mkcert localhost
cd ..
Once all dependencies have been installed, run this command:
make startapp
The application is now running and available in your browser at http://localhost:4000. As files are modified and saved, your application will automatically rebuild.
If you'd like to use live reloading in your browser when doing frontend work, you can make use of the templ proxy. The proxy can be accessed in your browser at http://localhost:7331. Changes to *.templ
files will be automatically reflected in the browser.
You can stop running the app with ctrl + c
.
If you'd prefer to not rely on Docker and instead run PostgreSQL locally, you will need to:
Install and run PostgreSQL
Create an empty database:
psql -c 'CREATE DATABASE phinvads'
Load the database dump file:
pg_restore -d phinvads --no-owner --role=$(whoami) phinvads.dump
Pull requests to the main
branch are required to pass linting checks. We use pre-commit
to run these checks. To run them locally, install pre-commit
and then install the hooks to run before every commit.
pip install pre-commit
pre-commit install
You can also run the checks on demand using pre-commit run
(staged files) or pre-commit run --all-files
(entire repo).