Tai Truong commited on
Commit
a23a652
1 Parent(s): d202ada

add dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +86 -0
Dockerfile ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # syntax=docker/dockerfile:1
2
+ # Keep this syntax directive! It's used to enable Docker BuildKit
3
+
4
+ ################################
5
+ # BUILDER-BASE
6
+ # Used to build deps + create our virtual environment
7
+ ################################
8
+
9
+ # 1. use python:3.12.3-slim as the base image until https://github.com/pydantic/pydantic-core/issues/1292 gets resolved
10
+ # 2. do not add --platform=$BUILDPLATFORM because the pydantic binaries must be resolved for the final architecture
11
+ # Use a Python image with uv pre-installed
12
+ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder
13
+
14
+ # Install the project into `/app`
15
+ WORKDIR /app
16
+
17
+ # Enable bytecode compilation
18
+ ENV UV_COMPILE_BYTECODE=1
19
+
20
+ # Copy from the cache instead of linking since it's a mounted volume
21
+ ENV UV_LINK_MODE=copy
22
+
23
+ RUN apt-get update \
24
+ && apt-get install --no-install-recommends -y \
25
+ # deps for building python deps
26
+ build-essential \
27
+ git \
28
+ # npm
29
+ npm \
30
+ # gcc
31
+ gcc \
32
+ && apt-get clean \
33
+ && rm -rf /var/lib/apt/lists/*
34
+
35
+ RUN --mount=type=cache,target=/root/.cache/uv \
36
+ --mount=type=bind,source=uv.lock,target=uv.lock \
37
+ --mount=type=bind,source=README.md,target=README.md \
38
+ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
39
+ --mount=type=bind,source=src/backend/base/README.md,target=src/backend/base/README.md \
40
+ --mount=type=bind,source=src/backend/base/uv.lock,target=src/backend/base/uv.lock \
41
+ --mount=type=bind,source=src/backend/base/pyproject.toml,target=src/backend/base/pyproject.toml \
42
+ uv sync --frozen --no-install-project --no-editable
43
+
44
+ ADD ./src /app/src
45
+
46
+ COPY src/frontend /tmp/src/frontend
47
+ WORKDIR /tmp/src/frontend
48
+ RUN --mount=type=cache,target=/root/.npm \
49
+ npm ci \
50
+ && npm run build \
51
+ && cp -r build /app/src/backend/langflow/frontend \
52
+ && rm -rf /tmp/src/frontend
53
+
54
+ WORKDIR /app
55
+ ADD ./pyproject.toml /app/pyproject.toml
56
+ ADD ./uv.lock /app/uv.lock
57
+ ADD ./README.md /app/README.md
58
+
59
+ RUN --mount=type=cache,target=/root/.cache/uv \
60
+ uv sync --frozen --no-editable
61
+
62
+ ################################
63
+ # RUNTIME
64
+ # Setup user, utilities and copy the virtual environment only
65
+ ################################
66
+ FROM python:3.12.3-slim AS runtime
67
+
68
+ RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data
69
+ COPY --from=builder --chown=1000 /app/.venv /app/.venv
70
+
71
+ # Place executables in the environment at the front of the path
72
+ ENV PATH="/app/.venv/bin:$PATH"
73
+
74
+ LABEL org.opencontainers.image.title=langflow
75
+ LABEL org.opencontainers.image.authors=['Langflow']
76
+ LABEL org.opencontainers.image.licenses=MIT
77
+ LABEL org.opencontainers.image.url=https://github.com/langflow-ai/langflow
78
+ LABEL org.opencontainers.image.source=https://github.com/langflow-ai/langflow
79
+
80
+ USER user
81
+ WORKDIR /app
82
+
83
+ ENV LANGFLOW_HOST=0.0.0.0
84
+ ENV LANGFLOW_PORT=7860
85
+
86
+ CMD ["langflow", "run"]