Create a .env
file with the following entries
ALGOLIA_APP_ID=<ALGOLIA>
ALGOLIA_APP_KEY=<ALGOLIA-PUBLIC-SEARCH-KEY>
PORT=3030
DEPLOY_ENV=Development
I personally use haskell-language-server in VS Code. The haskell
extension should
be able to download the right binaries, and use hie.yaml
to configure the project.
To get everything going the first time, you can run stack build
(look into ghcup
to install all the haskell stuffs.)
Working locally should be rather painless, it's a simple stack
project; you can run the server with:
stack run
(You'll need to set ALGOLIA_APP_ID
and ALGOLIA_APP_KEY
as env vars for geolocation to work locally. See the Docker instructions for running with a .env
file.)
docker build -t freenatalchart .
Should take about 25 mins if doing it from scratch. The final image uses Debian, so between the base and our own files, it comes to about 160 MB.
docker run -p 3030:3030 --env-file .env freenatalchart
The examples here use my own deployment pipeline, to which you won't have access. You can create your own
heroku app for free (with heroku create your-app-name
) and replace freenatalchart-staging
with your app's name.
heroku container:push web -a freenatalchart-staging # (or freenatalchart-prod)
heroku container:release web -a freenatalchart-staging # (or freenatalchart-prod)
heroku open # to see it in the local browser
(More info at heroku's guide to docker deployments)
Note: heroku container:push ...
will build the docker image if it hasn't been built yet; this can take up to 30 mins,
depending on your hardware.
For rendering HTML and SVG, we use golden tests with the hspec-golden library. The files are written to test/files
and we only track the "golden" (expected) file. You'll notice that we .gitignore
the actual
file -- but it is produced by the test runner on each run, locally. The files are saved without extension, but they should be viewable in a browser if one sets the extension (once the extension is there, you can also navigate the directory with python3 -m http.server 8000
.) I personally just use the renderTest*
functions in Dev.hs
while developing.
If you've updated the Views
and the tests now fail because of the changes, but you've verified that they're working as expected (perhaps by manually producing the files for static inspection, see for example renderTestIndex
in Dev.hs
,) you can have hspec-golden replace
the golden
files with the current copy of the actual
file (produced by running the now-failing test,) by running
stack exec hgold -- -u test/files