lf docker file

This commit is contained in:
Edwin Jose 2025-09-05 16:00:45 -04:00
parent 6debe0b0bf
commit 00243e660c
2 changed files with 115 additions and 13 deletions

99
Dockerfile.langflow Normal file
View file

@ -0,0 +1,99 @@
# syntax=docker/dockerfile:1
################################
# BUILDER-BASE
# Used to build deps + create our virtual environment
################################
# 1. use python:3.12.3-slim as the base image until https://github.com/pydantic/pydantic-core/issues/1292 gets resolved
# 2. do not add --platform=$BUILDPLATFORM because the pydantic binaries must be resolved for the final architecture
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder
# Install the project into `/app/langflow`
WORKDIR /app/langflow
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy
# Increase Node heap to avoid OOM during Vite build
ENV NODE_OPTIONS=--max-old-space-size=8192
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
# deps for building python deps
build-essential \
git \
ca-certificates \
# npm (includes nodejs)
npm \
# gcc
gcc \
&& update-ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Clone Langflow from the requested branch
RUN git clone --depth 1 --branch load_flows_autologin_false https://github.com/langflow-ai/langflow /app/langflow
# First resolve and download dependencies only (no project install) for better caching
ENV RUSTFLAGS="--cfg reqwest_unstable"
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-editable --extra postgresql
# Build frontend and place built assets into the backend package so they are included when installing
WORKDIR /app/langflow/src/frontend
RUN --mount=type=cache,target=/root/.npm \
npm ci \
&& npm run build \
&& mkdir -p /app/langflow/src/backend/langflow/frontend \
&& if [ -d dist ]; then cp -r dist/* /app/langflow/src/backend/langflow/frontend/; \
elif [ -d build ]; then cp -r build/* /app/langflow/src/backend/langflow/frontend/; \
else echo "No frontend build output found" && exit 1; fi
# Install the project into the virtual environment
WORKDIR /app/langflow
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-editable --extra postgresql
################################
# RUNTIME
# Setup user, utilities and copy the virtual environment only
################################
FROM python:3.12.3-slim AS runtime
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y curl git libpq5 gnupg \
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data
COPY --from=builder --chown=1000 /app/langflow/.venv /app/.venv
# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
LABEL org.opencontainers.image.title=langflow
LABEL org.opencontainers.image.authors=['Langflow']
LABEL org.opencontainers.image.licenses=MIT
LABEL org.opencontainers.image.url=https://github.com/langflow-ai/langflow
LABEL org.opencontainers.image.source=https://github.com/langflow-ai/langflow
USER user
WORKDIR /app
ENV LANGFLOW_HOST=0.0.0.0
ENV LANGFLOW_PORT=7860
EXPOSE 7860
CMD ["langflow", "run"]

View file

@ -1,9 +1,9 @@
services:
opensearch:
image: phact/openrag-opensearch:latest
#build:
#context: .
#dockerfile: Dockerfile
# image: phact/openrag-opensearch:latest
build:
context: .
dockerfile: Dockerfile
container_name: os
depends_on:
- openrag-backend
@ -39,10 +39,10 @@ services:
- "5601:5601"
openrag-backend:
image: phact/openrag-backend:latest
#build:
#context: .
#dockerfile: Dockerfile.backend
# image: phact/openrag-backend:latest
build:
context: .
dockerfile: Dockerfile.backend
container_name: openrag-backend
depends_on:
- langflow
@ -72,10 +72,10 @@ services:
gpus: all
openrag-frontend:
image: phact/openrag-frontend:latest
#build:
#context: .
#dockerfile: Dockerfile.frontend
# image: phact/openrag-frontend:latest
build:
context: .
dockerfile: Dockerfile.frontend
container_name: openrag-frontend
depends_on:
- openrag-backend
@ -87,7 +87,10 @@ services:
langflow:
volumes:
- ./flows:/app/flows:Z
image: phact/langflow:responses
# image: phact/langflow:responses
build:
context: .
dockerfile: Dockerfile.langflow
container_name: langflow
ports:
- "7860:7860"