joelbirchler
2019-12-18 13f7b7c55186c0daeb26c4850f876e5b5f9cf0ec
commit | author | age
71ad07 1 A simple example application for use with PostgreSQL.
J 2
13f7b7 3 Books also features a /leak endpoint that grabs a few MB of memory and holds onto
J 4 it. Hit it with curl in a loop to simulate a memory leak.
5
6
7 ## Similarities to the Exoplanets Application
8
9 This application is similar to the "exoplanets" application in the same repository, and
10 there is currently some code duplication between the two. We considered combining
11 the applications into a single codebase, but the forking logic to juggle different
12 datasets and templates proved more complex than the value.
13
14
15 ## Table Drop Warning
16
17 The app drops and creates a new "exoplanets" table on start up. This is not
71ad07 18 ideal in a deployment or any real scenario, but makes everything easy from an
J 19 instructional point of view. A better approach would be to create a job that populates
20 the initial data.
21
d769fe 22
50158f 23 ## Environment Variables
J 24
25 We use the following ENVs to connect to the database:
26
27   * `DB_HOST`
28   * `DB_PORT`
29   * `DB_USER`
30   * `DB_PASSWORD`
31   * `DB_NAME`
32
cdba9f 33 If the variables are not present, the application will run but not attempt to connect
J 34 to the database. This may be useful for using the /leak endpoint, for example.
35
71ad07 36 ## Building
J 37
38 A Makefile exists to avoid the burden of remembering things.
39
40   * `make build`: Builds a container
41   * `make`: Gofmt, build, and run (locally).
42
43
44 ## Pushing
45
46 First log podman in to quay.io/redhattraining and verify the `version` and `repo` variables in the Makefile.
47
48 Once that's all good: `make tag push`.
49
50
51 ## Local Development
52
53 There are a few helper tasks in the Makefile that might be of use:
54
55   * `make pg-up`: Starts a PostgreSQL container.
56   * `make pg-down`: Completely stops (rm -f) PostgreSQL.
57   * `make run`: Runs the app (you'll need to build it first) with DB_HOST to the ip
58   of the postgres container.
59   * `make`: Gofmt, build, and run (locally).