-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (53 loc) · 1.69 KB
/
Makefile
File metadata and controls
66 lines (53 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
include .env.defaults
# Verify that all environment variables are set
testenv := $(shell cabal exec dotenv -- -f .env --example .env.example echo 0)
ifeq ($(testenv),0)
include .env
export
else
echo $(testenv); exit 1
endif
# Run with local server
run:
make run-db && cabal run fakeworld
# Run with external server
run-external:
cabal run fakeworld -- -e
# Run server only (no Brick front-end)
run-server:
make run-db && cabal run fakeworld -- -s
# Build docker image for running the server
docker-build:
docker build -t adql/fakeworld .
# # Run the docker image
# docker-run:
# docker run -dp 8000:8000 adql/fakeworld
# Run PostgreSQL in a container, for development of the app itself
# without a container
run-db:
docker ps | grep $(DB_CONTAINER_NAME) || \
docker run \
--name $(DB_CONTAINER_NAME) \
-e POSTGRES_PASSWORD=$(DB_PASSWORD) \
-v $(DB_VOLUME_NAME):/var/lib/postgresql/data \
-p $(DB_PORT):5432 \
-d \
$(DB_DOCKER_IMAGE)
kill-db:
docker rm -f $(DB_CONTAINER_NAME)
run-psql:
docker exec -it fakeworld-postgres psql -U postgres
# Run PostgresSQL in a container and (re)setup the database schema
# (OVERRIDES EXISTING TABLES)
set-db:
make run-db; sleep 3
docker cp $(DB_SCHEMA_FILE) $(DB_CONTAINER_NAME):/home/
docker exec $(DB_CONTAINER_NAME) psql -U postgres -f home/schema.sql
# (Re)setup database and populate with dummy data (OVERRIDES EXISTING
# TABLES)
populate-db:
make set-db; sleep 1
docker cp db_dummy $(DB_CONTAINER_NAME):/var/lib/postgresql/data/
docker cp populate.sql $(DB_CONTAINER_NAME):/home/
docker exec $(DB_CONTAINER_NAME) psql -U postgres -f home/populate.sql
.PHONY: run run-external run-server docker-build docker-run run-db kill-db run-psql set-db populate-db