Skip to content
Merged

build #178

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ YELLOW := \033[1;33m
# -------------------------------------------------------------------------------------------------------------------- #

ROOT_NETWORK := oullin_net
DATABASE := "api-db"
SOURCE := go_bindata
ROOT_PATH := $(shell pwd)
APP_PATH := $(ROOT_PATH)/
Expand Down
22 changes: 20 additions & 2 deletions infra/makefile/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,26 @@ build-deploy:
DB_SECRET_PASSWORD="$(DB_SECRET_PASSWORD)" \
DB_SECRET_DBNAME="$(DB_SECRET_DBNAME)"
chmod +x "$(DB_INFRA_SCRIPTS_PATH)/postgres-entrypoint.sh" && \
chmod +x "$(DB_INFRA_SCRIPTS_PATH)/run-migration.sh" && \
make db:migrate && \
chmod +x "$(DB_INFRA_SCRIPTS_PATH)/run-migration.sh"
@echo "Starting database service..."
docker compose --env-file ./.env up $(DB_DOCKER_SERVICE_NAME) -d
@echo "Waiting for database to be healthy..."
@attempt=0; max_attempts=30; \
while [ $$attempt -lt $$max_attempts ]; do \
if docker inspect --format="{{.State.Health.Status}}" $(DB_DOCKER_CONTAINER_NAME) 2>/dev/null | grep -q "healthy"; then \
echo "Database is healthy"; \
break; \
fi; \
attempt=$$((attempt + 1)); \
if [ $$attempt -eq $$max_attempts ]; then \
echo "Database failed to become healthy after 60 seconds" >&2; \
exit 1; \
fi; \
sleep 2; \
done
@echo "Running migrations..."
make db:migrate
@echo "Starting remaining services..."
docker compose --env-file ./.env --profile prod up -d

build-release:
Expand Down
2 changes: 1 addition & 1 deletion infra/makefile/db.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DB_API_RUNNER_SERVICE := api-runner
DB_DOCKER_SERVICE_NAME := api-db
DB_DOCKER_CONTAINER_NAME := oullin_db
DB_MIGRATE_SERVICE_NAME := api-db-migrate
DB_MIGRATE_SERVICE_NAME := $(DB_DOCKER_SERVICE_NAME)-migrate

# --- Paths
# Define root paths for clarity. Assumes ROOT_PATH is exported or defined.
Expand Down
Loading