Skip to content

Commit

Permalink
create an all service make target
Browse files Browse the repository at this point in the history
  • Loading branch information
tmonty12 committed Dec 2, 2024
1 parent ec35b56 commit 1473217
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 118 deletions.
55 changes: 30 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ NC := \033[0m # No Color
# Explicitly use bash
SHELL := /bin/bash

# List of all services used - pdf model services
NON_PDF_MODEL_SERVICES := redis minio api-service agent-service pdf-service tts-service jaeger

PDF_MODEL_SERVICES := redis pdf-api celery-worker

NVINGEST_URL := https://nv-ingest-rest-endpoint.brevlab.com/v1

# Check if environment variables are set
check_env:
@for var in $(REQUIRED_ENV_VARS); do \
Expand All @@ -43,51 +50,49 @@ uv:
@echo "$(GREEN)Setting up UV environment...$(NC)"
@bash setup.sh

# Development target
dev: check_env
create-minio-data-dir:
@if [ ! -d "data/minio" ]; then \
echo "$(GREEN)Creating data/minio directory...$(NC)"; \
mkdir -p data/minio; \
fi
docker compose down
@if [ -z "$(MODEL_API_URL)" ]; then \
echo "$(GREEN)USING NV-INGEST$(NC)"; \
else \
echo "$(GREEN)USING DOCLING$(NC)"; \
fi

# Development target that runs with external nvingest
dev: check_env create-minio-data-dir
docker compose down $(NON_PDF_MODEL_SERVICES)
@echo "$(GREEN)Starting development environment...$(NC)"
@if [ "$(DETACH)" = "1" ]; then \
docker compose -f docker-compose.yaml --env-file .env up --build -d; \
MODEL_API_URL=$(NVINGEST_URL) docker compose -f docker-compose.yaml --env-file .env up $(NON_PDF_MODEL_SERVICES) --build -d; \
else \
docker compose -f docker-compose.yaml --env-file .env up --build; \
MODEL_API_URL=$(NVINGEST_URL) docker compose -f docker-compose.yaml --env-file .env up $(NON_PDF_MODEL_SERVICES) --build; \
fi

# Development target for pdf model service
model-dev:
docker compose -f services/PDFService/PDFModelService/docker-compose.yml down
docker compose down $(PDF_MODEL_SERVICES)
@echo "$(GREEN)Starting development environment...$(NC)"
docker compose -f services/PDFService/PDFModelService/docker-compose.yml up --build
docker compose up $(PDF_MODEL_SERVICES) --build

# Production target
prod: check_env
@if [ ! -d "data/minio" ]; then \
echo "$(GREEN)Creating data/minio directory...$(NC)"; \
mkdir -p data/minio; \
fi
# Development target that will run all services including pdf model locally
all-services: check_env create-minio-data-dir
docker compose down
@if [ -z "$(MODEL_API_URL)" ]; then \
echo "$(GREEN)USING NV-INGEST$(NC)"; \
@echo "$(GREEN)Starting development environment all-services...$(NC)"
@if [ "$(DETACH)" = "1" ]; then \
docker compose -f docker-compose.yaml --env-file .env up --build -d; \
else \
echo "$(GREEN)USING DOCLING$(NC)"; \
docker compose -f docker-compose.yaml --env-file .env up --build; \
fi

# Production target
prod: check_env create-minio-data-dir
docker compose down $(NON_PDF_MODEL_SERVICES)
@echo "$(GREEN)Starting production environment with version $(VERSION)...$(NC)"
VERSION=$(VERSION) docker compose -f docker-compose-remote.yaml --env-file .env up
VERSION=$(VERSION) MODEL_API_URL=$(NVINGEST_URL) docker compose -f docker-compose-remote.yaml --env-file .env up $(NON_PDF_MODEL_SERVICES)

# Production target for pdf model service
model-prod:
docker compose -f services/PDFService/PDFModelService/docker-compose-remote.yml down
docker compose -f docker-compose-remote.yaml down $(PDF_MODEL_SERVICES)
@echo "$(GREEN)Starting production environment with version $(VERSION)...$(NC)"
VERSION=$(VERSION) docker compose -f services/PDFService/PDFModelService/docker-compose-remote.yml up
VERSION=$(VERSION) docker compose -f docker-compose-remote.yaml up $(PDF_MODEL_SERVICES)

# Version bump (minor) and release target
version-bump:
Expand Down Expand Up @@ -127,4 +132,4 @@ format:

ruff: lint format

.PHONY: check_env dev clean ruff prod version-bump version-bump-major uv model-prod model-dev
.PHONY: check_env dev clean ruff prod version-bump version-bump-major uv model-prod model-dev all-services create-minio-data-dir
43 changes: 42 additions & 1 deletion docker-compose-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
command: redis-server --appendonly no
networks:
- app-network

minio:
image: minio/minio:latest
ports:
Expand Down Expand Up @@ -41,6 +42,7 @@ services:
- jaeger
networks:
- app-network

agent-service:
image: nvcr.io/pfteb4cqjzrs/playground/agent-service:${VERSION:-1.1}
ports:
Expand All @@ -55,19 +57,21 @@ services:
- redis
networks:
- app-network

pdf-service:
image: nvcr.io/pfteb4cqjzrs/playground/pdf-service:${VERSION:-1.1}
ports:
- "8003:8003"
environment:
- REDIS_URL=redis://redis:6379
- MODEL_API_URL=${MODEL_API_URL:-https://nv-ingest-8t8cjywa2.brevlab.com/v1}
- MODEL_API_URL=${MODEL_API_URL:-http://pdf-api:8004}
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
- redis
networks:
- app-network

tts-service:
image: nvcr.io/pfteb4cqjzrs/playground/tts-service:${VERSION:-1.1}
ports:
Expand Down Expand Up @@ -96,6 +100,43 @@ services:
networks:
- app-network

pdf-api:
image: nvcr.io/pfteb4cqjzrs/playground/pdf-model-api:${VERSION}
ports:
- "8003:8003"
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- REDIS_HOST=redis
- REDIS_PORT=6379
- TEMP_FILE_DIR=/tmp/pdf_conversions
volumes:
- pdf_temp:/tmp/pdf_conversions
depends_on:
- redis
- celery-worker
restart: unless-stopped
networks:
- app-network

celery-worker:
image: nvcr.io/pfteb4cqjzrs/playground/pdf-model-worker:${VERSION}
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- TEMP_FILE_DIR=/tmp/pdf_conversions
volumes:
- pdf_temp:/tmp/pdf_conversions
depends_on:
- redis
restart: unless-stopped
networks:
- app-network

volumes:
redis_data:
pdf_temp:

networks:
app-network:
driver: bridge
43 changes: 42 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ services:
- "8003:8003"
environment:
- REDIS_URL=redis://redis:6379
- MODEL_API_URL=${MODEL_API_URL:-https://nv-ingest-8t8cjywa2.brevlab.com/v1}
- MODEL_API_URL=${MODEL_API_URL:-http://pdf-api:8004}
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
Expand Down Expand Up @@ -109,6 +109,47 @@ services:
retries: 3
networks:
- app-network

pdf-api:
build:
context: services/PDFService/PDFModelService
dockerfile: Dockerfile.api
ports:
- "8004:8004"
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- REDIS_HOST=redis
- REDIS_PORT=6379
- TEMP_FILE_DIR=/tmp/pdf_conversions
volumes:
- pdf_temp:/tmp/pdf_conversions
depends_on:
- redis
- celery-worker
restart: unless-stopped
networks:
- app-network

celery-worker:
build:
context: services/PDFService/PDFModelService
dockerfile: Dockerfile.worker
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- TEMP_FILE_DIR=/tmp/pdf_conversions
volumes:
- pdf_temp:/tmp/pdf_conversions
depends_on:
- redis
restart: unless-stopped
networks:
- app-network

volumes:
redis_data:
pdf_temp:

networks:
app-network:
Expand Down
4 changes: 2 additions & 2 deletions services/PDFService/PDFModelService/Dockerfile.api
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ COPY tasks.py /app/
# Create directory for temporary files
RUN mkdir -p /tmp/pdf_conversions

EXPOSE 8003
EXPOSE 8004

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8003"]
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8004"]
42 changes: 0 additions & 42 deletions services/PDFService/PDFModelService/docker-compose-remote.yml

This file was deleted.

46 changes: 0 additions & 46 deletions services/PDFService/PDFModelService/docker-compose.yml

This file was deleted.

2 changes: 1 addition & 1 deletion services/PDFService/PDFModelService/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ async def health():
if __name__ == "__main__":
import uvicorn

uvicorn.run(app, host="0.0.0.0", port=8003)
uvicorn.run(app, host="0.0.0.0", port=8004)

0 comments on commit 1473217

Please sign in to comment.