chore: update docker images to use uv (#3916)

* fix dev dependencies

* fix dev dependencies

* update lock

* Add langchain-unstructured dependency to pyproject.toml

* Switch to uv-based Docker image and streamline build process

- Use `ghcr.io/astral-sh/uv:python3.12-bookworm-slim` as the base image
- Simplify environment variable setup and remove unnecessary ones
- Install project dependencies using `uv sync` with cache mounts
- Add and copy necessary files for the build process
- Update npm installation and frontend build steps
- Adjust entrypoint and runtime configurations
- Remove redundant user setup and streamline CMD execution

* Refactor Dockerfile to use multi-stage builds for optimized image size

- Introduce a builder stage to install dependencies and build the frontend.
- Use npm ci instead of npm install for more reliable builds.
- Copy built frontend assets to the final image.
- Transition to a runtime stage with a slimmer Python base image.
- Ensure the final image only contains necessary runtime dependencies.

* Switch base image to `ghcr.io/astral-sh/uv:python3.12-bookworm-slim` and update Dockerfile

- Replace `python:3.12.3-slim` with `ghcr.io/astral-sh/uv:python3.12-bookworm-slim` as the base image.
- Enable bytecode compilation and set link mode to copy.
- Update dependency installation process using `uv sync`.
- Simplify frontend build and copy process.
- Add OCI labels for image metadata.
- Update CMD to use `langflow-base` for running the application.

* Update Dockerfile to use uv base image and optimize dependency installation

- Switch base image to `ghcr.io/astral-sh/uv:python3.12-bookworm-slim`
- Combine apt-get commands and clean up to reduce image size
- Replace Poetry with uv for dependency management and caching

* Refactor Dockerfile to use multi-stage build for optimized image size

- Introduce a builder stage using `ghcr.io/astral-sh/uv:python3.12-bookworm-slim`
- Add a runtime stage using `python:3.12.3-slim`
- Copy the virtual environment from the builder stage to the runtime stage
- Remove the `uv` entrypoint to avoid invoking it by default

* Update Dockerfile: Fix indentation and remove redundant ENTRYPOINT reset

* ci: update release workflows to use uv (#3919)

* Update nightly build workflow to use 'uv' for dependency management and caching

- Replace Poetry with 'uv' for dependency installation and project setup
- Add steps to install 'uv' and set up caching for 'uv.lock'
- Modify Python setup to use version specified in 'pyproject.toml'
- Remove Node.js setup steps

* Update release workflow to use uv for dependency management

- Replace Poetry with uv for dependency installation and caching
- Update Python setup to use version specified in pyproject.toml
- Add steps to restore uv cache and install project dependencies using uv
- Adjust publish steps to maintain functionality with new setup

* Replace 'poetry publish' with 'uv publish' in Makefile for consistency

* Update nightly build workflow to use 'uv' for dependency management and caching

* Set up Node.js 20 in release_nightly workflow and update version verification logic

* Update Makefile to use `uv sync --frozen` for backend dependencies installation

* Update Makefile to pass arguments to 'uv build' and remove '--skip-existing' from publish commands

- Modified 'build_langflow' target to accept arguments.
- Removed '--skip-existing' from 'publish_base' and 'publish_base_testpypi' commands.
- Added TODO comments for updating test-pypi repository usage.

* Remove --skip-existing flag from uv publish commands and add TODO comments for test-pypi updates

* new lock

* Update CI workflow to remove version prefix and add build args

- Removed 'v' prefix from version extraction in nightly release workflow.
- Added '--no-sources' argument to the build command in the distribution step.

* Update CI workflow to use 'uv' for versioning and publishing

- Replace 'poetry' with 'uv' for version extraction in release checks

* Update CI workflow to use UV_PUBLISH_TOKEN for PyPI publishing

* Add verification step for 'langflow-nightly' name and version in CI workflow

- Corrected awk commands for extracting 'langflow-base' name and version.
- Added a new step to verify 'langflow-nightly' name and version against expected values.

* feat: Update dev.Dockerfile to use 'uv' for dependency management and caching

* update dockerfiles with --no-editable

---------

Co-authored-by: phact <estevezsebastian@gmail.com>
Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com>
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-09-30 19:49:25 -03:00 committed by GitHub
commit 43ad226ddb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 231 additions and 239 deletions

View file

@ -29,23 +29,31 @@ jobs:
with:
persist-credentials: true
- name: Set up Python ${{ env.PYTHON_VERSION }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_caching"
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ env.PYTHON_VERSION }}
poetry-version: ${{ env.POETRY_VERSION }}
cache-key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
poetry env use ${{ env.PYTHON_VERSION }}
poetry install
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --dev
- name: Generate main nightly tag
id: generate_main_tag
run: |
# NOTE: This outputs the tag with the `v` prefix.
MAIN_TAG="$(poetry run python ./scripts/ci/pypi_nightly_tag.py main)"
MAIN_TAG="$(uv run python ./scripts/ci/pypi_nightly_tag.py main)"
echo "main_tag=$MAIN_TAG" >> $GITHUB_OUTPUT
echo "main_tag=$MAIN_TAG"
@ -64,7 +72,7 @@ jobs:
if: ${{ steps.check_main_tag.outputs.main_tag_exists == 'false' }}
run: |
# NOTE: This outputs the tag with the `v` prefix.
BASE_TAG="$(poetry run python ./scripts/ci/pypi_nightly_tag.py base)"
BASE_TAG="$(uv run python ./scripts/ci/pypi_nightly_tag.py base)"
echo "base_tag=$BASE_TAG" >> $GITHUB_OUTPUT
echo "base_tag=$BASE_TAG"
@ -82,17 +90,17 @@ jobs:
# project-name is updated, which does not have dependencies installed.
BASE_TAG="${{ steps.generate_base_tag.outputs.base_tag }}"
echo "Updating base project version to $BASE_TAG"
poetry run python ./scripts/ci/update_pyproject_name.py langflow-base-nightly base
poetry run python ./scripts/ci/update_pyproject_version.py $BASE_TAG base
uv run python ./scripts/ci/update_pyproject_name.py langflow-base-nightly base
uv run python ./scripts/ci/update_pyproject_version.py $BASE_TAG base
# This updates the dependency of langflow-base to langflow-base-nightly in {project_root}/pyproject.toml
poetry run python ./scripts/ci/update_lf_base_dependency.py $BASE_TAG
uv run python ./scripts/ci/update_lf_base_dependency.py $BASE_TAG
# Use the main tag created earlier
MAIN_TAG="${{ steps.generate_main_tag.outputs.main_tag }}"
echo "Updating main project version to $MAIN_TAG"
poetry run python ./scripts/ci/update_pyproject_version.py $MAIN_TAG main
poetry run python ./scripts/ci/update_pyproject_name.py langflow-nightly main
uv run python ./scripts/ci/update_pyproject_version.py $MAIN_TAG main
uv run python ./scripts/ci/update_pyproject_name.py langflow-nightly main
git add pyproject.toml src/backend/base/pyproject.toml
git commit -m "Update version and project name"
@ -122,10 +130,10 @@ jobs:
working-directory: src/backend/base
run: |
# If the main tag already exists, we need to retrieve the base version from the main tag codebase.
version=$(poetry version --short)
echo "base_tag=v$version" >> $GITHUB_OUTPUT
echo "base_tag=v$version"
version=$(uv tree | grep 'langflow-base' | awk '{print $3}')
echo "base_tag=$version" >> $GITHUB_OUTPUT
echo "base_tag=$version"
- name: Set Base Tag
id: set_base_tag
run: |

View file

@ -57,17 +57,25 @@ jobs:
skipped: ${{ steps.check-version.outputs.skipped }}
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.12
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
- name: Set up Nodejs 20
uses: actions/setup-node@v4
python-version-file: "pyproject.toml"
- name: Restore uv cache
uses: actions/cache@v4
with:
node-version: "20"
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --dev
- name: Check Version
id: check-version
run: |
@ -103,10 +111,10 @@ jobs:
echo "Server terminated successfully"
fi
- name: Publish to PyPI
if: steps.check-version.outputs.skipped == 'false'
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: make publish base=true
run: |
make publish base=true
- name: Upload Artifact
if: steps.check-version.outputs.skipped == 'false'
uses: actions/upload-artifact@v4
@ -123,23 +131,31 @@ jobs:
version: ${{ steps.check-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.12
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
- name: Set up Nodejs 20
uses: actions/setup-node@v4
python-version-file: "pyproject.toml"
- name: Restore uv cache
uses: actions/cache@v4
with:
node-version: "20"
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --dev
# If pre-release is true, we need to check if ["a", "b", "rc", "dev", "post"] is in the version string
# if the version string is incorrect, we need to exit the workflow
- name: Check if pre-release
if: inputs.pre_release == 'true'
run: |
version=$(poetry version --short)
version=$(uv tree | grep 'langflow' | awk '{print $2}' | sed 's/^v//')
if [[ "${version}" =~ ^([0-9]+\.)?([0-9]+\.)?[0-9]+((a|b|rc|dev|post)([0-9]+))$ ]]; then
echo "Pre-release version detected. Continuing with the release."
else
@ -149,7 +165,7 @@ jobs:
- name: Check Version
id: check-version
run: |
version=$(poetry version --short)
version=$(uv tree | grep 'langflow' | awk '{print $2}' | sed 's/^v//')
last_released_version=$(curl -s "https://pypi.org/pypi/langflow/json" | jq -r '.releases | keys | .[]' | sort -V | tail -n 1)
if [ "$version" = "$last_released_version" ]; then
echo "Version $version is already released. Skipping release."
@ -182,8 +198,9 @@ jobs:
fi
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: make publish main=true
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
make publish main=true
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:

View file

@ -60,24 +60,35 @@ jobs:
with:
ref: ${{ inputs.nightly_tag_main }}
persist-credentials: true
- name: Install poetry
run: |
pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.12
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
python-version-file: "pyproject.toml"
- name: Set up Nodejs 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --dev
- name: Verify Nightly Name and Version
working-directory: src/backend/base
run: |
name=$(poetry version | cut -d' ' -f1)
version=v$(poetry version --short)
name=$(uv tree | grep 'langflow-base' | awk '{print $1}')
version=$(uv tree | grep 'langflow-base' | awk '{print $2}')
if [ "$name" != "langflow-base-nightly" ]; then
echo "Name $name does not match langflow-base-nightly. Exiting the workflow."
exit 1
@ -133,35 +144,43 @@ jobs:
with:
ref: ${{ inputs.nightly_tag_main }}
- name: Install poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.12
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
- name: Set up Nodejs 20
uses: actions/setup-node@v4
python-version-file: "pyproject.toml"
- name: Restore uv cache
uses: actions/cache@v4
with:
node-version: "20"
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --dev
- name: Verify Nightly Name and Version
run: |
name=$(poetry version | cut -d' ' -f1)
version=v$(poetry version --short)
name=$(uv tree | grep 'langflow' | awk '{print $1}')
version=$(uv tree | grep 'langflow' | awk '{print $2}')
if [ "$name" != "langflow-nightly" ]; then
echo "Name $name does not match langflow-nightly. Exiting the workflow."
exit 1
fi
if [ "$version" != "${{ inputs.nightly_tag_main }}" ]; then
echo "Version $version does not match nightly tag ${{ inputs.nightly_tag_main }}. Exiting the workflow."
if [ "$version" != "${{ inputs.nightly_tag_base }}" ]; then
echo "Version $version does not match nightly tag ${{ inputs.nightly_tag_base }}. Exiting the workflow."
exit 1
fi
- name: Wait for PyPI Propagation
run: sleep 300 # wait for 5 minutes to ensure PyPI propagation of base
- name: Build project for distribution
run: make build main=true
run: make build main=true args="--no-sources"
- name: Test CLI
run: |
python -m pip install dist/*.whl

View file

@ -322,7 +322,7 @@ ifdef main
make install_frontendci
make build_frontend
make build_langflow_base
make build_langflow
make build_langflow args="$(args)"
endif
build_langflow_base:
@ -334,7 +334,7 @@ build_langflow_backup:
build_langflow:
uv lock --no-upgrade
uv build
uv build $(args)
ifdef restore
mv pyproject.toml.bak pyproject.toml
mv uv.lock.bak uv.lock
@ -403,20 +403,18 @@ update: ## update dependencies
uv sync --upgrade
publish_base:
#TODO: replace with uvx twine upload dist/*
cd src/backend/base && poetry publish --skip-existing
cd src/backend/base && uv publish
publish_langflow:
#TODO: replace with uvx twine upload dist/*
poetry publish
uv publish
publish_base_testpypi:
#TODO: replace with uvx twine upload dist/*
cd src/backend/base && poetry publish --skip-existing -r test-pypi
# TODO: update this to use the test-pypi repository
cd src/backend/base && uv publish -r test-pypi
publish_langflow_testpypi:
#TODO: replace with uvx twine upload dist/*
poetry publish -r test-pypi
# TODO: update this to use the test-pypi repository
uv publish -r test-pypi
publish: ## build the frontend static files and package the project and publish it to PyPI
@echo 'Publishing the project'

View file

@ -1,7 +1,6 @@
# syntax=docker/dockerfile:1
# Keep this syntax directive! It's used to enable Docker BuildKit
################################
# BUILDER-BASE
# Used to build deps + create our virtual environment
@ -9,76 +8,66 @@
# 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
FROM python:3.12.3-slim as builder-base
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder
ENV 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.8.2 \
# 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"
# Install the project into `/app`
WORKDIR /app
# 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
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
# deps for installing poetry
curl \
# deps for building python deps
build-essential npm \
build-essential \
# npm
npm \
# gcc
gcc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,target=/root/.cache \
curl -sSL https://install.python-poetry.org | python3 -
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=README.md,target=README.md \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=src/backend/base/README.md,target=src/backend/base/README.md \
--mount=type=bind,source=src/backend/base/uv.lock,target=src/backend/base/uv.lock \
--mount=type=bind,source=src/backend/base/pyproject.toml,target=src/backend/base/pyproject.toml \
uv sync --frozen --no-install-project --no-editable
ADD ./src /app/src
COPY src/frontend /tmp/src/frontend
WORKDIR /tmp/src/frontend
RUN --mount=type=cache,target=/root/.npm \
npm ci \
&& npm run build \
&& cp -r build /app/src/backend/langflow/frontend \
&& rm -rf /tmp/src/frontend
WORKDIR /app
COPY pyproject.toml poetry.lock README.md ./
COPY src/ ./src
COPY scripts/ ./scripts
RUN python -m pip install requests --user && cd ./scripts && python update_dependencies.py
ADD ./pyproject.toml /app/pyproject.toml
ADD ./uv.lock /app/uv.lock
# 1. Install the dependencies using the current poetry.lock file to create reproducible builds
# 2. Do not install dev dependencies
# 3. Install all the extras to ensure all optionals are installed as well
# 4. --sync to ensure nothing else is in the environment
# 5. Build the wheel and install "langflow" package (mainly for version)
# Note: moving to build and installing the wheel will make the docker images not reproducible.
RUN $POETRY_HOME/bin/poetry lock --no-update \
# install current lock file with fixed dependencies versions \
# do not install dev dependencies \
&& $POETRY_HOME/bin/poetry install --without dev --sync -E deploy -E couchbase -E cassio \
&& $POETRY_HOME/bin/poetry build -f wheel \
&& $POETRY_HOME/bin/poetry run pip install dist/*.whl
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-editable
################################
# RUNTIME
# Setup user, utilities and copy the virtual environment only
################################
# 1. use python:3.12.3-slim as the base image until https://github.com/pydantic/pydantic-core/issues/1292 gets resolved
FROM python:3.12.3-slim as runtime
FROM python:3.12.3-slim AS runtime
RUN apt-get -y update \
&& apt-get install --no-install-recommends -y \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data
COPY --from=builder --chown=1000 /app/.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']
@ -86,14 +75,10 @@ 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
RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data
COPY --from=builder-base --chown=1000 /app/.venv /app/.venv
ENV PATH="/app/.venv/bin:${PATH}"
USER user
WORKDIR /app
ENV LANGFLOW_HOST=0.0.0.0
ENV LANGFLOW_PORT=7860
CMD ["python", "-m", "langflow", "run"]
CMD ["langflow", "run"]

View file

@ -1,58 +1,28 @@
# 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
################################
# use python:3.12.3-slim as the base image until https://github.com/pydantic/pydantic-core/issues/1292 gets resolved
FROM python:3.12.3-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.8.2 \
# 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
# 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`
WORKDIR /app
# 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
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
# deps for installing poetry
curl \
# deps for building python deps
build-essential \
# npm
@ -61,41 +31,48 @@ RUN apt-get update \
gcc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=src/backend/base/README.md,target=src/backend/base/README.md \
--mount=type=bind,source=src/backend/base/uv.lock,target=src/backend/base/uv.lock \
--mount=type=bind,source=src/backend/base/pyproject.toml,target=src/backend/base/pyproject.toml \
cd src/backend/base && uv sync --frozen --no-install-project --no-dev --no-editable
RUN --mount=type=cache,target=/root/.cache \
curl -sSL https://install.python-poetry.org | python3 -
ADD ./src /app/src
# Now we need to copy the entire project into the image
COPY pyproject.toml poetry.lock ./
COPY src/frontend/package.json /tmp/package.json
RUN cd /tmp && npm install
WORKDIR /app
COPY src/frontend ./src/frontend
RUN rm -rf src/frontend/node_modules
RUN cp -a /tmp/node_modules /app/src/frontend
COPY scripts ./scripts
COPY Makefile ./
COPY README.md ./
RUN cd src/frontend && npm run build
COPY src/backend ./src/backend
RUN cp -r src/frontend/build src/backend/base/langflow/frontend
RUN rm -rf src/backend/base/dist
RUN useradd -m -u 1000 user && \
mkdir -p /app/langflow && \
chown -R user:user /app && \
chmod -R u+w /app/langflow
COPY src/frontend /tmp/src/frontend
WORKDIR /tmp/src/frontend
RUN npm install \
&& npm run build \
&& cp -r build /app/src/backend/base/langflow/frontend \
&& rm -rf /tmp/src/frontend
# Update PATH with home/user/.local/bin
ENV PATH="/home/user/.local/bin:${PATH}"
RUN cd src/backend/base && $POETRY_HOME/bin/poetry build
WORKDIR /app/src/backend/base
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-editable
# Copy virtual environment and built .tar.gz from builder base
################################
# RUNTIME
# Setup user, utilities and copy the virtual environment only
################################
FROM python:3.12.3-slim AS runtime
RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data
COPY --from=builder --chown=1000 /app/src/backend/base/.venv /app/src/backend/base/.venv
# Place executables in the environment at the front of the path
ENV PATH="/app/src/backend/base/.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
# Install the package from the .tar.gz
RUN python -m pip install /app/src/backend/base/dist/*.tar.gz --user
WORKDIR /app
ENV LANGFLOW_HOST=0.0.0.0
ENV LANGFLOW_PORT=7860
CMD ["python", "-m", "langflow", "run"]
CMD ["langflow-base", "run"]

View file

@ -1,20 +1,26 @@
FROM python:3.12-bookworm
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
ENV TZ=UTC
WORKDIR /app
RUN apt update -y
RUN apt install \
RUN apt-get update && apt-get install -y \
build-essential \
curl \
npm \
-y
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY . /app
RUN pip install poetry
RUN poetry config virtualenvs.create false
RUN poetry install --no-interaction --no-ansi
# Install dependencies using uv
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=README.md,target=README.md \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=src/backend/base/README.md,target=src/backend/base/README.md \
--mount=type=bind,source=src/backend/base/uv.lock,target=src/backend/base/uv.lock \
--mount=type=bind,source=src/backend/base/pyproject.toml,target=src/backend/base/pyproject.toml \
uv sync --frozen --no-install-project --no-dev
EXPOSE 7860
EXPOSE 3000

36
uv.lock generated
View file

@ -335,14 +335,14 @@ wheels = [
[[package]]
name = "authlib"
version = "1.3.1"
version = "1.3.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "cryptography" },
]
sdist = { url = "https://files.pythonhosted.org/packages/09/47/df70ecd34fbf86d69833fe4e25bb9ecbaab995c8e49df726dd416f6bb822/authlib-1.3.1.tar.gz", hash = "sha256:7ae843f03c06c5c0debd63c9db91f9fda64fa62a42a77419fa15fbb7e7a58917", size = 146074 }
sdist = { url = "https://files.pythonhosted.org/packages/f3/75/47dbab150ef6f9298e227a40c93c7fed5f3ffb67c9fb62cd49f66285e46e/authlib-1.3.2.tar.gz", hash = "sha256:4b16130117f9eb82aa6eec97f6dd4673c3f960ac0283ccdae2897ee4bc030ba2", size = 147313 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/87/1f/bc95e43ffb57c05b8efcc376dd55a0240bf58f47ddf5a0f92452b6457b75/Authlib-1.3.1-py2.py3-none-any.whl", hash = "sha256:d35800b973099bbadc49b42b256ecb80041ad56b7fe1216a362c7943c088f377", size = 223827 },
{ url = "https://files.pythonhosted.org/packages/df/4c/9aa0416a403d5cc80292cb030bcd2c918cce2755e314d8c1aa18656e1e12/Authlib-1.3.2-py2.py3-none-any.whl", hash = "sha256:ede026a95e9f5cdc2d4364a52103f5405e75aa156357e831ef2bfd0bc5094dfc", size = 225111 },
]
[[package]]
@ -2321,19 +2321,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/66/2b/a6e68d7ea6f4fbc31cce20e354d6cef484da0a9891ee6a3eaf3aa9659d01/grpcio-1.66.1-cp312-cp312-win_amd64.whl", hash = "sha256:b0aa03d240b5539648d996cc60438f128c7f46050989e35b25f5c18286c86734", size = 4275565 },
]
[[package]]
name = "grpcio-health-checking"
version = "1.62.3"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "grpcio" },
{ name = "protobuf" },
]
sdist = { url = "https://files.pythonhosted.org/packages/eb/9f/09df9b02fc8eafa3031d878c8a4674a0311293c8c6f1c942cdaeec204126/grpcio-health-checking-1.62.3.tar.gz", hash = "sha256:5074ba0ce8f0dcfe328408ec5c7551b2a835720ffd9b69dade7fa3e0dc1c7a93", size = 15640 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/40/4c/ee3173906196b741ac6ba55a9788ba9ebf2cd05f91715a49b6c3bfbb9d73/grpcio_health_checking-1.62.3-py3-none-any.whl", hash = "sha256:f29da7dd144d73b4465fe48f011a91453e9ff6c8af0d449254cf80021cab3e0d", size = 18547 },
]
[[package]]
name = "grpcio-status"
version = "1.62.3"
@ -2497,7 +2484,7 @@ wheels = [
[[package]]
name = "httpx"
version = "0.27.0"
version = "0.27.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "anyio" },
@ -2506,9 +2493,9 @@ dependencies = [
{ name = "idna" },
{ name = "sniffio" },
]
sdist = { url = "https://files.pythonhosted.org/packages/5c/2d/3da5bdf4408b8b2800061c339f240c1802f2e82d55e50bd39c5a881f47f0/httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5", size = 126413 }
sdist = { url = "https://files.pythonhosted.org/packages/78/82/08f8c936781f67d9e6b9eeb8a0c8b4e406136ea4c3d1f89a5db71d42e0e6/httpx-0.27.2.tar.gz", hash = "sha256:f7c2be1d2f3c3c3160d441802406b206c2b76f5947b11115e6df10c6c65e66c2", size = 144189 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/41/7b/ddacf6dcebb42466abd03f368782142baa82e08fc0c1f8eaa05b4bae87d5/httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5", size = 75590 },
{ url = "https://files.pythonhosted.org/packages/56/95/9377bcb415797e44274b51d46e3249eba641711cf3348050f76ee7b15ffc/httpx-0.27.2-py3-none-any.whl", hash = "sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0", size = 76395 },
]
[package.optional-dependencies]
@ -7887,21 +7874,16 @@ wheels = [
[[package]]
name = "weaviate-client"
version = "4.8.1"
version = "3.26.7"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "authlib" },
{ name = "grpcio" },
{ name = "grpcio-health-checking" },
{ name = "grpcio-tools" },
{ name = "httpx" },
{ name = "pydantic" },
{ name = "requests" },
{ name = "validators" },
]
sdist = { url = "https://files.pythonhosted.org/packages/4f/4d/650831937f25b8e788870b46a693a6e141d9d3d72bfd708ce88b0b01d69f/weaviate_client-4.8.1.tar.gz", hash = "sha256:2756996a2205bb991f258c064fc502011fc78a40e8786cb072208b1d3d7c9932", size = 681877 }
sdist = { url = "https://files.pythonhosted.org/packages/f8/2e/9588bae34c1d67d05ccc07d74a4f5d73cce342b916f79ab3a9114c6607bb/weaviate_client-3.26.7.tar.gz", hash = "sha256:ea538437800abc6edba21acf213accaf8a82065584ee8b914bae4a4ad4ef6b70", size = 210480 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/c8/d8/88610f5aaaffd3d2447fe755b86a8bb06b79472e45ec999baa5040dea9a3/weaviate_client-4.8.1-py3-none-any.whl", hash = "sha256:c16453ebfd9bd4045675f8e50841d1af21aa9af1332f379d0418c4531c03bd44", size = 374526 },
{ url = "https://files.pythonhosted.org/packages/2a/95/fb326052bc1d73cb3c19fcfaf6ebb477f896af68de07eaa1337e27ee57fa/weaviate_client-3.26.7-py3-none-any.whl", hash = "sha256:48b8d4b71df881b4e5e15964d7ac339434338ccee73779e3af7eab698a92083b", size = 120051 },
]
[[package]]