* refactor(base.py): handle ImportError when importing is_pre_release function from langflow.version module to prevent crashing the application feat(base.py): dynamically determine if the version is a pre-release version by checking for 'a', 'b', or 'rc' in the version number * fix(Dockerfile): add missing backslash to ensure proper chaining of commands * refactor: Update get_lifespan function to handle ImportError and dynamically determine the version number The get_lifespan function in main.py has been updated to handle ImportError when importing the __version__ attribute from the langflow.version module. If the import fails, the version number is dynamically determined using the importlib.metadata.version function. This change ensures that the application does not crash when the langflow.version module is not available. Note: This commit message follows the convention used in the recent user commits. * chore: Add langflow-pre.db and langflow.db to .dockerignore * chore: Update .dockerignore to include langflow-pre.db and langflow.db * refactor: Add folder_id column to flow table and handle folder column migration This commit adds the folder_id column to the flow table in the database. It also handles the migration of the folder column to the new folder_id column. This change allows for better organization and management of flows within folders. Note: This commit message follows the convention used in the recent user commits. * refactor: Update Dockerfiles to include user creation and environment variable This commit updates the Dockerfiles to include the creation of a user with UID 1000 and the necessary permissions for the /app/langflow directory. It also adds the user's local bin directory to the PATH environment variable. This change improves the security and isolation of the application within the container. Note: This commit message follows the convention used in the recent user commits.
98 lines
2.8 KiB
Docker
98 lines
2.8 KiB
Docker
|
|
|
|
# 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.12-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
|
|
RUN apt-get update \
|
|
&& apt-get install --no-install-recommends -y \
|
|
# deps for installing poetry
|
|
curl \
|
|
# deps for building python deps
|
|
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 -
|
|
|
|
# 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
|
|
|
|
# Update PATH with home/user/.local/bin
|
|
ENV PATH="/home/user/.local/bin:${PATH}"
|
|
RUN cd src/backend/base && $POETRY_HOME/bin/poetry build
|
|
|
|
# Copy virtual environment and built .tar.gz from builder base
|
|
|
|
USER user
|
|
# Install the package from the .tar.gz
|
|
RUN python -m pip install /app/src/backend/base/dist/*.tar.gz --user
|
|
|
|
|
|
ENTRYPOINT ["python", "-m", "langflow", "run"]
|
|
CMD ["--host", "0.0.0.0", "--port", "7860"]
|