🐛 fix(base.Dockerfile): remove unnecessary copy of ./src/backend directory to improve build performance

 feat(base.Dockerfile): add healthcheck for queue and celeryworker services to ensure their availability
 feat(docker-compose.yml): add healthcheck for queue, celeryworker, and flower services to ensure their availability
🐛 fix(docker-compose.yml): fix the path in the command for backend service startup
🐛 fix(flower.env): add missing double quote at the end of C_FORCE_ROOT value
🐛 fix(startup-backend.sh): remove unnecessary --reload flag from uvicorn command and add --workers -1 flag to utilize all available CPU cores
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-18 08:51:30 -03:00
commit a7ff7da778
4 changed files with 21 additions and 6 deletions

View file

@ -63,7 +63,6 @@ RUN --mount=type=cache,target=/root/.cache \
# copy project requirement files here to ensure they will be cached.
WORKDIR $PYSETUP_PATH
COPY ./poetry.lock ./pyproject.toml ./
COPY ./src/backend ./src/backend
# Copy README.md to the build context
COPY ./README.md ./
# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
@ -82,6 +81,7 @@ WORKDIR $PYSETUP_PATH
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
COPY ./src/backend ./src/backend
# quicker install as runtime deps are already installed
RUN --mount=type=cache,target=/root/.cache \
poetry install --with=dev --extras deploy

View file

@ -17,6 +17,8 @@ services:
- ../:/app
- ./startup-backend.sh:/startup-backend.sh # Ensure the paths match
command: /startup-backend.sh # Fixed the path
healthcheck:
test: "exit 0"
db:
image: postgres:15.4
@ -37,27 +39,35 @@ services:
- ./pgadmin:/var/lib/pgadmin
queue:
image: redis:7.2.0
image: redis:6.2.5
ports:
- "6379:6379"
healthcheck:
test: "exit 0"
celeryworker:
# user: your-non-root-user
depends_on:
- queue
queue:
condition: service_healthy
env_file:
- ./celeryworker.env
build:
context: ../
dockerfile: base.Dockerfile
command: celery -A langflow.worker.celery_app worker --loglevel=INFO
healthcheck:
test: "exit 0"
flower:
# user: your-non-root-user
networks:
- default
depends_on:
- queue
queue:
condition: service_healthy
celeryworker:
condition: service_healthy
build:
context: ../
dockerfile: base.Dockerfile
@ -75,7 +85,9 @@ services:
args:
- BACKEND_URL=http://backend:7860
depends_on:
- backend
backend:
condition: service_healthy
env_file:
- ./frontend.env
ports:

View file

@ -4,3 +4,6 @@ LANGFLOW_REDIS_PORT=6379
LANGFLOW_REDIS_DB=0
LANGFLOW_REDIS_EXPIRE=3600
LANGFLOW_REDIS_PASSWORD=
BROKER_URL=redis://queue:6379/0
RESULT_BACKEND=redis://queue:6379/0
C_FORCE_ROOT="true # ! Only for development"

View file

@ -3,4 +3,4 @@
export LANGFLOW_DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}"
# Your command to start the backend
exec uvicorn --factory langflow.main:create_app --host 0.0.0.0 --port 7860 --reload --log-level ${LOG_LEVEL:-info}
exec python -m uvicorn --factory langflow.main:create_app --host 0.0.0.0 --port 7860 --log-level ${LOG_LEVEL:-info} --workers -1