-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
71 lines (54 loc) · 2.38 KB
/
Makefile
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
66
67
68
69
70
71
.PHONY: all clean install docker_server_build docker_push serve auth_example transcripts fixtures
UNAME := $(shell uname)
STACK_FLAGS := "--fast"
dist_dir := $(shell stack path | awk '/^dist-dir/{print $$2}')
exe_name := share-api
exe := $(dist_dir)/build/$(exe_name)/$(exe_name)
target_dir := docker/tmp
installed_share := $(target_dir)/$(exe_name)
unison := $(shell command -v unison)
docker_registry=324181518966.dkr.ecr.us-west-2.amazonaws.com
share_commit := $(shell git diff-index --quiet HEAD -- && git rev-parse --short=10 HEAD || echo 'wip')
OPEN_BROWSER ?= "true"
ifeq ($(UNAME),Linux)
OPEN := xdg-open
endif
ifeq ($(UNAME),Darwin)
OPEN := open
endif
$(target_dir):
mkdir $@
$(exe): $(shell find . unison -type f -name '*.hs') package.yaml stack.yaml
@echo $(exe)
@echo $@
stack build $(STACK_FLAGS) share-api:share-api
$(installed_share): $(exe) $(target_dir)
cp $(exe) $(installed_share)
auth_example:
stack build --fast test-auth-app
docker_server_build: $(installed_share)
docker build $(docker_platform_flag) -f docker/Dockerfile --build-arg share_commit=$(share_commit) -t share docker
docker_server_release: $(installed_share)
docker build $(docker_platform_flag) -f docker/Dockerfile -t $(docker_registry)/share:$(DRONE_BUILD_NUMBER) docker
docker_push: $(docker_server_release)
docker push $(docker_registry)/share:$(DRONE_BUILD_NUMBER)
docker_staging_release: $(installed_share)
docker build $(docker_platform_flag) -f docker/Dockerfile -t $(docker_registry)/share-staging:$(DRONE_BUILD_NUMBER) docker
docker_staging_push: $(docker_server_release)
docker push $(docker_registry)/share-staging:$(DRONE_BUILD_NUMBER)
serve: $(installed_share)
trap 'docker compose -f docker/docker-compose.yml down' EXIT INT TERM
docker compose -f docker/docker-compose.yml up postgres redis &
while ! ( pg_isready --host localhost -U postgres -p 5432 && redis-cli -p 6379 ping) do \
echo "Waiting for postgres and redis..."; \
sleep 1; \
done;
echo "Running Share at http://localhost:5424"
if [ ${OPEN_BROWSER} = "true" ] ; then \
(sleep 1 && $(OPEN) "http://localhost:5424/local/user/test/login" || true) & \
fi
(. ./local.env && $(exe) 2>&1)
fixtures:
echo "Resetting local database to fixture data"
PGPASSWORD="sekrit" psql -U postgres -p 5432 -h localhost -f "transcripts/sql/clean.sql"
PGPASSWORD="sekrit" psql -U postgres -p 5432 -h localhost -f "transcripts/sql/inserts.sql"