📦 chore(deploy): add deployment files and configurations for Docker Compose setup
This commit is contained in:
parent
861b8d048e
commit
6b0383be50
9 changed files with 215 additions and 0 deletions
18
deploy/backend.env
Normal file
18
deploy/backend.env
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Database configuration
|
||||
DB_USER=langflow
|
||||
DB_PASSWORD=langflow
|
||||
DB_HOST=db
|
||||
DB_PORT=5432
|
||||
DB_NAME=langflow
|
||||
|
||||
# Logging configuration
|
||||
LOG_LEVEL=debug
|
||||
|
||||
# Cache configuration
|
||||
LANGFLOW_CACHE_TYPE=redis
|
||||
|
||||
# Redis configuration
|
||||
LANGFLOW_REDIS_HOST=queue
|
||||
LANGFLOW_REDIS_PORT=6379
|
||||
LANGFLOW_REDIS_DB=0
|
||||
LANGFLOW_REDIS_EXPIRE=3600
|
||||
87
deploy/base.Dockerfile
Normal file
87
deploy/base.Dockerfile
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
|
||||
|
||||
# syntax=docker/dockerfile:1
|
||||
# Keep this syntax directive! It's used to enable Docker BuildKit
|
||||
|
||||
# Based on https://github.com/python-poetry/poetry/discussions/1879?sort=top#discussioncomment-216865
|
||||
# but I try to keep it updated (see history)
|
||||
|
||||
################################
|
||||
# PYTHON-BASE
|
||||
# Sets up all our shared environment variables
|
||||
################################
|
||||
FROM python:3.10-slim as python-base
|
||||
|
||||
# python
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
# prevents python creating .pyc files
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
\
|
||||
# pip
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=on \
|
||||
PIP_DEFAULT_TIMEOUT=100 \
|
||||
\
|
||||
# poetry
|
||||
# https://python-poetry.org/docs/configuration/#using-environment-variables
|
||||
POETRY_VERSION=1.5.1 \
|
||||
# make poetry install to this location
|
||||
POETRY_HOME="/opt/poetry" \
|
||||
# make poetry create the virtual environment in the project's root
|
||||
# it gets named `.venv`
|
||||
POETRY_VIRTUALENVS_IN_PROJECT=true \
|
||||
# do not ask any interactive question
|
||||
POETRY_NO_INTERACTION=1 \
|
||||
\
|
||||
# paths
|
||||
# this is where our requirements + virtual environment will live
|
||||
PYSETUP_PATH="/opt/pysetup" \
|
||||
VENV_PATH="/opt/pysetup/.venv"
|
||||
|
||||
|
||||
# prepend poetry and venv to path
|
||||
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
|
||||
|
||||
|
||||
################################
|
||||
# BUILDER-BASE
|
||||
# Used to build deps + create our virtual environment
|
||||
################################
|
||||
FROM python-base as builder-base
|
||||
RUN apt-get update \
|
||||
&& apt-get install --no-install-recommends -y \
|
||||
# deps for installing poetry
|
||||
curl \
|
||||
# deps for building python deps
|
||||
build-essential
|
||||
|
||||
# install poetry - respects $POETRY_VERSION & $POETRY_HOME
|
||||
# The --mount will mount the buildx cache directory to where
|
||||
# Poetry and Pip store their cache so that they can re-use it
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
curl -sSL https://install.python-poetry.org | python3 -
|
||||
|
||||
# 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
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
poetry install --without dev --extras deploy
|
||||
|
||||
|
||||
################################
|
||||
# DEVELOPMENT
|
||||
# Image used during development / testing
|
||||
################################
|
||||
FROM python-base as development
|
||||
WORKDIR $PYSETUP_PATH
|
||||
|
||||
# copy in our built poetry + venv
|
||||
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
|
||||
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
|
||||
|
||||
# quicker install as runtime deps are already installed
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
poetry install --with=dev --extras deploy
|
||||
8
deploy/celeryworker.env
Normal file
8
deploy/celeryworker.env
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
LANGFLOW_CACHE_TYPE=redis
|
||||
LANGFLOW_REDIS_HOST=queue
|
||||
LANGFLOW_REDIS_PORT=6379
|
||||
LANGFLOW_REDIS_DB=0
|
||||
LANGFLOW_REDIS_EXPIRE=3600
|
||||
BROKER_URL=redis://queue:6379/0
|
||||
RESULT_BACKEND=redis://queue:6379/0
|
||||
C_FORCE_ROOT="true # ! Only for development"
|
||||
3
deploy/db.env
Normal file
3
deploy/db.env
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
POSTGRES_USER=langflow
|
||||
POSTGRES_PASSWORD=langflow
|
||||
POSTGRES_DB=langflow
|
||||
83
deploy/docker-compose.yml
Normal file
83
deploy/docker-compose.yml
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
backend:
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: base.Dockerfile
|
||||
# user: your-non-root-user # Make sure your Dockerfile creates this user
|
||||
depends_on:
|
||||
- queue
|
||||
- db
|
||||
env_file:
|
||||
- ./backend.env
|
||||
ports:
|
||||
- "7860:7860"
|
||||
volumes:
|
||||
- ./:/app
|
||||
- ./startup-backend.sh:/startup-backend.sh # Ensure the paths match
|
||||
command: /startup-backend.sh # Fixed the path
|
||||
|
||||
db:
|
||||
image: postgres:15.4
|
||||
env_file:
|
||||
- ./db.env
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
pgadmin:
|
||||
image: dpage/pgadmin4
|
||||
env_file:
|
||||
- ./pgadmin.env
|
||||
ports:
|
||||
- "5050:80"
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
- ./pgadmin:/var/lib/pgadmin
|
||||
|
||||
queue:
|
||||
image: redis:6.2.5 # Use a specific version
|
||||
ports:
|
||||
- "6379:6379"
|
||||
|
||||
celeryworker:
|
||||
# user: your-non-root-user
|
||||
depends_on:
|
||||
- queue
|
||||
env_file:
|
||||
- ./celeryworker.env
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: base.Dockerfile
|
||||
command: celery -A langflow.worker.celery_app worker --loglevel=INFO
|
||||
|
||||
flower:
|
||||
# user: your-non-root-user
|
||||
networks:
|
||||
- default
|
||||
depends_on:
|
||||
- queue
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: base.Dockerfile
|
||||
env_file:
|
||||
- ./flower.env
|
||||
command: celery -A langflow.worker.celery_app --broker=redis://queue:6379/0 flower --port=5555
|
||||
ports:
|
||||
- "5555:5555"
|
||||
|
||||
frontend:
|
||||
# user: your-non-root-user
|
||||
build:
|
||||
context: ../src/frontend
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
- BACKEND_URL=http://backend:7860
|
||||
depends_on:
|
||||
- backend
|
||||
env_file:
|
||||
- ./frontend.env
|
||||
ports:
|
||||
- "80:80"
|
||||
restart: on-failure
|
||||
5
deploy/flower.env
Normal file
5
deploy/flower.env
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
LANGFLOW_CACHE_TYPE=redis
|
||||
LANGFLOW_REDIS_HOST=queue
|
||||
LANGFLOW_REDIS_PORT=6379
|
||||
LANGFLOW_REDIS_DB=0
|
||||
LANGFLOW_REDIS_EXPIRE=3600
|
||||
3
deploy/frontend.env
Normal file
3
deploy/frontend.env
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
VITE_PROXY_TARGET=http://backend:7860/api/
|
||||
BACKEND_URL=http://backend:7860
|
||||
2
deploy/pgadmin.env
Normal file
2
deploy/pgadmin.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
PGADMIN_DEFAULT_EMAIL=admin@admin.com
|
||||
PGADMIN_DEFAULT_PASSWORD=admin
|
||||
6
deploy/startup-backend.sh
Executable file
6
deploy/startup-backend.sh
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
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}
|
||||
Loading…
Add table
Add a link
Reference in a new issue