-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: dockerfile with entrypoint (#4062)
Adds a dockerfile with an entrypoint for use with Datastax Langflow
- Loading branch information
1 parent
45c8f98
commit eedfe43
Showing
4 changed files
with
187 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# 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 | ||
################################ | ||
|
||
# 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 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/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 | ||
ADD ./pyproject.toml /app/pyproject.toml | ||
ADD ./uv.lock /app/uv.lock | ||
ADD ./README.md /app/README.md | ||
|
||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv sync --frozen --no-editable | ||
|
||
################################ | ||
# 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/.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 | ||
|
||
RUN useradd ragstack -u 10000 -g 0 --no-create-home --home-dir /app/data | ||
WORKDIR /app | ||
|
||
RUN mkdir /data | ||
RUN chown -R 10000:0 /data | ||
RUN chown -R 10000:0 /app | ||
|
||
ENV LANGFLOW_HOST=0.0.0.0 | ||
ENV LANGFLOW_PORT=7860 | ||
|
||
USER 10000 | ||
|
||
ENTRYPOINT ["python", "-m", "langflow", "run", "--host", "0.0.0.0", "--backend-only"] |