2024-09-20 17:28:55 +00:00
|
|
|
COMPOSE_FILES := -f ./docker/docker-compose.yml
|
2024-09-10 09:50:11 +00:00
|
|
|
|
|
|
|
# Function to add service files
|
|
|
|
define add_service
|
|
|
|
ifeq ($(PROD), true)
|
|
|
|
COMPOSE_FILES += -f ./docker/docker-compose.$(1).yml
|
|
|
|
ifneq ($(wildcard ./docker/docker-compose.$(1).prod.yml),)
|
|
|
|
COMPOSE_FILES += -f ./docker/docker-compose.$(1).prod.yml
|
|
|
|
endif
|
2024-09-20 17:28:55 +00:00
|
|
|
else ifeq ($(DEV_MODE), true)
|
2024-09-18 16:33:12 +00:00
|
|
|
COMPOSE_FILES += -f ./docker/docker-compose.$(1).yml
|
|
|
|
ifneq ($(wildcard ./docker/docker-compose.$(1).dev.yml),)
|
|
|
|
COMPOSE_FILES += -f ./docker/docker-compose.$(1).dev.yml
|
|
|
|
endif
|
2024-09-10 09:50:11 +00:00
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
2024-09-20 17:28:55 +00:00
|
|
|
# Function to set up COMPOSE_FILES
|
|
|
|
define compose_files
|
|
|
|
ifeq ($(1), true)
|
|
|
|
ifneq ($(wildcard ./docker/docker-compose.dev.yml),)
|
|
|
|
COMPOSE_FILES += -f ./docker/docker-compose.dev.yml
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifneq ($(NGINX),)
|
|
|
|
$(eval $(call add_service,nginx))
|
|
|
|
endif
|
|
|
|
ifneq ($(NLU),)
|
|
|
|
$(eval $(call add_service,nlu))
|
|
|
|
endif
|
|
|
|
endef
|
2024-09-18 16:33:12 +00:00
|
|
|
|
2024-09-10 09:50:11 +00:00
|
|
|
# Ensure .env file exists and matches .env.example
|
|
|
|
check-env:
|
|
|
|
@if [ ! -f "./docker/.env" ]; then \
|
|
|
|
echo "Error: .env file does not exist. Creating one now from .env.example ..."; \
|
|
|
|
cp ./docker/.env.example ./docker/.env; \
|
|
|
|
fi
|
|
|
|
@echo "Checking .env file for missing variables..."
|
|
|
|
@awk -F '=' 'NR==FNR {a[$$1]; next} !($$1 in a) {print "Missing env var: " $$1}' ./docker/.env ./docker/.env.example
|
|
|
|
|
|
|
|
init:
|
|
|
|
cp ./docker/.env.example ./docker/.env
|
|
|
|
|
|
|
|
dev: check-env
|
2024-09-20 17:28:55 +00:00
|
|
|
$(eval $(call compose_files,true))
|
2024-09-10 09:50:11 +00:00
|
|
|
docker compose $(COMPOSE_FILES) up -d
|
|
|
|
|
|
|
|
start: check-env
|
2024-09-20 17:28:55 +00:00
|
|
|
$(eval $(call compose_files,false))
|
|
|
|
docker compose $(COMPOSE_FILES) up -d
|
2024-09-10 09:50:11 +00:00
|
|
|
|
|
|
|
stop: check-env
|
2024-09-20 17:28:55 +00:00
|
|
|
$(eval $(call compose_files,true))
|
2024-09-10 09:50:11 +00:00
|
|
|
docker compose $(COMPOSE_FILES) down
|
|
|
|
|
|
|
|
destroy: check-env
|
2024-09-20 17:28:55 +00:00
|
|
|
$(eval $(call compose_files,true))
|
2024-09-10 09:50:11 +00:00
|
|
|
docker compose $(COMPOSE_FILES) down -v
|
|
|
|
|
|
|
|
migrate-up:
|
2024-09-20 17:28:55 +00:00
|
|
|
$(eval $(call compose_files,false))
|
2024-09-18 16:33:12 +00:00
|
|
|
docker-compose $(COMPOSE_FILES) up --no-deps -d database-init
|