Skip to content

Commit 34c9131

Browse files
committed
refactor: Changes Makefile to use docker commands
1 parent 61c10ec commit 34c9131

File tree

6 files changed

+41
-2
lines changed

6 files changed

+41
-2
lines changed

Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
.phony:
22
test
33

4+
PROJECT_NAME=$(notdir $(PWD))
5+
HOST_NAME=$(USER)
6+
CONTAINER_UID=$(HOSTNAME)_$(PROJECT_NAME)
47

5-
tests:
8+
test-local:
69
@echo "*** `tests` directory should exist at project root. Stop."
710

811
db-migration:
@@ -18,5 +21,21 @@ test-integration:
1821
test-e2e:
1922
pytest --color=yes --showlocals --tb=short -v tests/auth/e2e
2023

21-
test: tests db-migration test-unit test-integration test-e2e
24+
test-local: tests db-migration test-unit test-integration test-e2e
25+
26+
build:
27+
docker-compose build
28+
29+
test:
30+
docker-compose -p $(CONTAINER_UID) run --rm --use-aliases --service-ports web docker/test.sh
31+
32+
clean:
33+
docker-compose -p $(CONTAINER_UID) down --remove-orphans --rmi all 2>/dev/null
34+
35+
web:
36+
docker-compose -p $(CONTAINER_UID) up
37+
38+
prune:
39+
docker system prune -af
40+
2241

docker/entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#/bin/bash
2+
# sh ./docker/migration.sh && sh ./docker/uvicorn.sh
3+
sh ./docker/migration.sh && sh ./docker/test.sh

docker/init-user-db.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
6+
CREATE USER tester;
7+
CREATE DATABASE court;
8+
GRANT ALL PRIVILEGES ON DATABASE court TO tester;
9+
EOSQL

docker/migration.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alembic -x data=true downgrade base
2+
alembic -x data=true upgrade head

docker/test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bash/sh
2+
sh docker/migration.sh
3+
pytest --color=yes --showlocals --tb=short -v tests/auth/unit
4+
pytest --color=yes --showlocals --tb=short -v tests/auth/integration
5+
pytest --color=yes --showlocals --tb=short -v tests/auth/e2e

docker/uvicorn.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uvicorn src.server.app:app --port $PORT --host $HOST --loop uvloop --log-level info --workers $MAX_CONCURRENCY

0 commit comments

Comments
 (0)