|
1 | | -.PHONY: all clean install docker_server_build docker_push serve auth_example transcripts fixtures transcripts |
| 1 | +.PHONY: all clean install docker_server_build docker_push serve auth_example transcripts fixtures transcripts reset_fixtures |
2 | 2 |
|
| 3 | +SHARE_PROJECT_ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) |
| 4 | +export SHARE_PROJECT_ROOT |
3 | 5 | UNAME := $(shell uname) |
4 | 6 | STACK_FLAGS := "--fast" |
5 | 7 | dist_dir := $(shell stack path | awk '/^dist-dir/{print $$2}') |
@@ -36,39 +38,66 @@ $(installed_share): $(exe) $(target_dir) |
36 | 38 | auth_example: |
37 | 39 | stack build --fast test-auth-app |
38 | 40 |
|
39 | | -docker_server_build: $(installed_share) |
40 | | - docker build $(docker_platform_flag) -f docker/Dockerfile --build-arg share_commit=$(share_commit) -t share docker |
41 | | - |
42 | | -docker_server_release: $(installed_share) |
43 | | - docker build $(docker_platform_flag) -f docker/Dockerfile -t $(docker_registry)/share:$(DRONE_BUILD_NUMBER) docker |
44 | | - |
45 | | -docker_push: $(docker_server_release) |
46 | | - docker push $(docker_registry)/share:$(DRONE_BUILD_NUMBER) |
47 | | - |
48 | | -docker_staging_release: $(installed_share) |
49 | | - docker build $(docker_platform_flag) -f docker/Dockerfile -t $(docker_registry)/share-staging:$(DRONE_BUILD_NUMBER) docker |
50 | | - |
51 | | -docker_staging_push: $(docker_server_release) |
52 | | - docker push $(docker_registry)/share-staging:$(DRONE_BUILD_NUMBER) |
53 | | - |
| 41 | +# Build Share and run it alongside its dependencies via docker-compose |
54 | 42 | serve: $(installed_share) |
55 | | - trap 'docker compose -f docker/docker-compose.yml down' EXIT INT TERM |
56 | | - docker compose -f docker/docker-compose.yml up postgres redis vault & |
57 | | - while ! ( pg_isready --host localhost -U postgres -p 5432 && redis-cli -p 6379 ping && VAULT_ADDR=http://localhost:8200 vault status) do \ |
58 | | - echo "Waiting for postgres and redis..."; \ |
| 43 | + @docker compose -f docker/docker-compose.base.yml down || true |
| 44 | + @trap 'docker compose -f docker/docker-compose.base.yml down' EXIT INT TERM |
| 45 | + @echo "Booting up docker dependencies..." |
| 46 | + docker compose -f docker/docker-compose.base.yml -f docker/docker-compose.fixtures.yml up --remove-orphans --detach |
| 47 | + @echo "Booting up docker dependencies..."; |
| 48 | + @while ! ( pg_isready --host localhost -U postgres -p 5432 >/dev/null 2>&1 && redis-cli -p 6379 ping >/dev/null 2>&1 && VAULT_ADDR=http://localhost:8200 vault status >/dev/null 2>&1 ) do \ |
59 | 49 | sleep 1; \ |
60 | 50 | done; |
61 | | - echo "Running Share at http://localhost:5424" |
62 | | - |
63 | | - if [ ${OPEN_BROWSER} = "true" ] ; then \ |
64 | | - (sleep 1 && $(OPEN) "http://localhost:5424/local/user/test/login" || true) & \ |
65 | | - fi |
66 | | - (. ./local.env && $(exe) 2>&1) |
67 | | - |
68 | | -fixtures: |
69 | | - echo "Resetting local database to fixture data" |
70 | | - PGPASSWORD="sekrit" psql -U postgres -p 5432 -h localhost -f "transcripts/sql/clean.sql" |
71 | | - PGPASSWORD="sekrit" psql -U postgres -p 5432 -h localhost -f "transcripts/sql/inserts.sql" |
| 51 | + @echo "Starting up Share at http://localhost:5424"; |
| 52 | + @if curl -f -s http://localhost:1234 >/dev/null 2>&1 ; then \ |
| 53 | + (sleep 1 && $(OPEN) "http://localhost:5424/local/user/test/login" && $(OPEN) "http://localhost:1234" || true) & \ |
| 54 | + fi; |
| 55 | + @(. ./local.env && $(exe) 2>&1) |
| 56 | + |
| 57 | +# Loads the local testing share with a bunch of realistic code. |
| 58 | +reset_fixtures: |
| 59 | + # Prompt for confirmation |
| 60 | + @echo "This will delete all data in your local share database. Are you sure? (y/N) " |
| 61 | + @read -r confirmation && [ "$$confirmation" = "y" ] || [ "$$confirmation" = "Y" ] |
| 62 | + @docker compose -f docker/docker-compose.base.yml down || true |
| 63 | + @trap 'docker compose -f docker/docker-compose.base.yml down' EXIT INT TERM |
| 64 | + # Remove the existing postgres volume to reset the database |
| 65 | + @echo "Removing any existing postgres volume" |
| 66 | + docker volume rm docker_postgresVolume || true |
| 67 | + @echo "Booting up docker dependencies..." |
| 68 | + docker compose -f docker/docker-compose.base.yml -f docker/docker-compose.fixtures.yml up --remove-orphans --detach |
| 69 | + @echo "Initializing fixture data"; |
| 70 | + @while ! ( pg_isready --host localhost -U postgres -p 5432 >/dev/null 2>&1 && redis-cli -p 6379 ping >/dev/null 2>&1 && VAULT_ADDR=http://localhost:8200 vault status >/dev/null 2>&1 ) do \ |
| 71 | + sleep 1; \ |
| 72 | + done; |
| 73 | + @echo "Booting up share"; |
| 74 | + @( . ./local.env \ |
| 75 | + $(exe) 2>&1 & \ |
| 76 | + SERVER_PID=$$!; \ |
| 77 | + trap "kill $$SERVER_PID 2>/dev/null || true" EXIT INT TERM; \ |
| 78 | + echo "Loading fixtures"; \ |
| 79 | + ./transcripts/fixtures/run.zsh; \ |
| 80 | + kill $$SERVER_PID 2>/dev/null || true; \ |
| 81 | + ) |
| 82 | + @echo "Done!"; |
72 | 83 |
|
73 | 84 | transcripts: |
74 | | - ./transcripts/run-transcripts.zsh |
| 85 | + @echo "Taking down any existing docker dependencies" |
| 86 | + @docker compose -f docker/docker-compose.base.yml down || true |
| 87 | + @trap 'docker compose -f docker/docker-compose.base.yml down' EXIT INT TERM |
| 88 | + @echo "Booting up transcript docker dependencies..." |
| 89 | + docker compose -f docker/docker-compose.base.yml up --remove-orphans --detach |
| 90 | + @while ! ( pg_isready --host localhost -U postgres -p 5432 >/dev/null 2>&1 && redis-cli -p 6379 ping >/dev/null 2>&1 && VAULT_ADDR=http://localhost:8200 vault status >/dev/null 2>&1 ) do \ |
| 91 | + sleep 1; \ |
| 92 | + done; |
| 93 | + ./transcripts/configure_transcript_database.zsh |
| 94 | + @echo "Booting up share"; |
| 95 | + ( . ./local.env ; \ |
| 96 | + $(exe) & \ |
| 97 | + SERVER_PID=$$!; \ |
| 98 | + trap "kill $$SERVER_PID 2>/dev/null || true" EXIT INT TERM; \ |
| 99 | + echo "Running transcripts"; \ |
| 100 | + ./transcripts/run-transcripts.zsh $(pattern); \ |
| 101 | + kill $$SERVER_PID 2>/dev/null || true; \ |
| 102 | + ) |
| 103 | + @echo "Transcripts complete!"; |
0 commit comments