- Install
sudo apt install postgresql - Add yourself as user and also create one called bellevue
If your postgres server runs on your machine:
sudo -u postgres \
createuser \
--superuser \
$USER
# this is the same as running:
# psql -U postgres -c "CREATE ROLE \"$USER\" WITH SUPERUSER LOGIN;"
# once you have your own user in the DB, you no longer need
# to use `sudo -u postgres`.
createuser --superuser bellevue
createdb bellevue
psql -d bellevueIf your postgres server runs as a docker container: You specify the user name and the database name with environment variables.
createuser bellevue == POSTGRES_USER: bellevuecreatedb bellevue == POSTGRESDB: bellevue
-
then in postgres, alter the bellevue password
ALTER USER bellevue WITH PASSWORD 'pa55word';CTRL + d to quite the psql program. -
Run the migration scripts.
To run a script, use the command:
psql -U username -d myDataBase -a -f myInsertFile
# Options:
# -d / --dbname bellevue
# -a / --echo-all
# -f / --file migrations/file.sql
# -h / --host localhost
# -p / --port 5433 (5432 is default; optional, useful if port is not 5432)
# i.e.:
psql \
-d bellevue \
-a \
-f migrations/000001_create_roles.up.sqlIn the folder db there is a docker compose script
-
Change into the db folder
-
Run the docker compose with
docker compose up -d. Note that we have mapped the data directory into thedbfolder. The data will be persisted and you only need to do this setup once. To delete the database data, just delete the folderdb/data_postgresthat was created when you ran docker compose. -
Jump into a bash terminal on the container with:
docker exec -it \
-e PGPASSWORD="pa55word" \
-e PGDATABASE="bellevue" \
-e PGUSER="bellevue" \
postgres bash- Run the initialisation scripts that you copied earlier
psql -f migrations/000001_create_roles.up.sql
psql -f migrations/000002_data_model_products.up.sql
psql -f migrations/000003_populate_product_tables.up.sqlIf you have psql as a command on your system and docker is running in a container, you can export env vars and access psql in the container directly.
export PGDATABASE=bellevue
export PGUSER=bellevue
export PGPASSWORD=pa55sword
export PGPORT=5432
psql -X -q -c '\conninfo'Install npm dependencies with npm install in the root of the directory and then npm install esbuild
In order to make the JS and CSS bundels, you need to update the path to esbuild in the make/bundle.mk file.
If you install esbuild locally to the project, you should find it in a folder called node_modules. For me, it was node_modules/esbuild/bin/esbuild
Then run
make bundle/css
make bundle/jsThe website is configured via envriomental variables. Create a file called envs and past the following variables into it:
export DB_SCHEME="postgres"
export DB_USER="bellevue"
export DB_PASSWORD="pa55word"
export DB_ADDRESS="localhost"
export DB_NAME="bellevue"
export PGHOST=localhost
export PGPORT="5432"
export PGUSER="bellevue"
export PGDATABASE="bellevue"
export PG_DSN="contact your administrator"
export JWT_SECRET_KEY="contact your administrator"
export COOKIE_DOMAIN=localhost
export OIDC_CLIENT_ID="contact your administrator"
export OIDC_CLIENT_SECRET="contact your administrator"
export OIDC_ISSUER="https://sso.dwbn.org"
export OIDC_REDIRECT_URL="http://localhost:8875/login/dwbn/callback"
export SESSION_SECRET="randomly-genearted-secret--see-Makefile"Run the with go run ./cmd/web/. If all went correctly, you should be able to see it at http://localhost:8875.