* docker: improve image layout and backend-only image * add tests * add tests * add frontend * add frontend * label * fix
77 lines
No EOL
2.4 KiB
Docker
77 lines
No EOL
2.4 KiB
Docker
# 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
|
|
################################
|
|
FROM python:3.12-slim as builder-base
|
|
|
|
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"
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install --no-install-recommends -y \
|
|
# deps for installing poetry
|
|
curl \
|
|
# deps for building python deps
|
|
build-essential 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 -
|
|
|
|
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
|
|
RUN $POETRY_HOME/bin/poetry lock --no-update \
|
|
&& $POETRY_HOME/bin/poetry install --no-interaction --no-ansi -E deploy \
|
|
&& $POETRY_HOME/bin/poetry build -f wheel \
|
|
&& $POETRY_HOME/bin/poetry run pip install dist/*.whl
|
|
|
|
################################
|
|
# RUNTIME
|
|
# Setup user, utilities and copy the virtual environment only
|
|
################################
|
|
FROM python:3.12-slim as runtime
|
|
|
|
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
|
|
|
|
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
|
|
|
|
ENTRYPOINT ["python", "-m", "langflow", "run"]
|
|
CMD ["--host", "0.0.0.0", "--port", "7860"] |