Kevin Hu commited on
Commit
3e56b9c
·
1 Parent(s): 9c8f077

Refactor dockerfile (#3741)

Browse files

### What problem does this PR solve?


### Type of change

- [x] Refactoring

Files changed (1) hide show
  1. Dockerfile +33 -33
Dockerfile CHANGED
@@ -59,6 +59,21 @@ USER root
59
 
60
  WORKDIR /ragflow
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  COPY .git /ragflow/.git
63
 
64
  RUN current_commit=$(git rev-parse --short HEAD); \
@@ -78,28 +93,16 @@ RUN current_commit=$(git rev-parse --short HEAD); \
78
  echo "RAGFlow version: $version_info"; \
79
  echo $version_info > /ragflow/VERSION
80
 
81
- COPY web web
82
- COPY docs docs
83
- RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
84
- cd web && npm install --force && npm run build
85
-
86
- # install dependencies from poetry.lock file
87
- COPY pyproject.toml poetry.toml poetry.lock ./
88
-
89
- RUN --mount=type=cache,id=ragflow_builder_poetry,target=/root/.cache/pypoetry,sharing=locked \
90
- if [ "$LIGHTEN" == "1" ]; then \
91
- poetry install --no-root; \
92
- else \
93
- poetry install --no-root --with=full; \
94
- fi
95
-
96
  # production stage
97
  FROM base AS production
98
  USER root
99
 
100
  WORKDIR /ragflow
101
 
102
- COPY --from=builder /ragflow/VERSION /ragflow/VERSION
 
 
 
103
 
104
  # Install python packages' dependencies
105
  # cv2 requires libGL.so.1
@@ -107,15 +110,6 @@ RUN --mount=type=cache,id=ragflow_production_apt,target=/var/cache/apt,sharing=l
107
  apt update && apt install -y --no-install-recommends nginx libgl1 vim less && \
108
  rm -rf /var/lib/apt/lists/*
109
 
110
- COPY web web
111
- COPY api api
112
- COPY conf conf
113
- COPY deepdoc deepdoc
114
- COPY rag rag
115
- COPY agent agent
116
- COPY graphrag graphrag
117
- COPY pyproject.toml poetry.toml poetry.lock ./
118
-
119
  # Copy models downloaded via download_deps.py
120
  RUN mkdir -p /ragflow/rag/res/deepdoc /root/.ragflow
121
  RUN --mount=type=bind,source=huggingface.co,target=/huggingface.co \
@@ -153,18 +147,24 @@ RUN --mount=type=bind,source=chromedriver-linux64-121-0-6167-85,target=/chromedr
153
  mv chromedriver /usr/local/bin/ && \
154
  rm -f /usr/bin/google-chrome
155
 
156
- # Copy compiled web pages
157
- COPY --from=builder /ragflow/web/dist /ragflow/web/dist
158
-
159
- # Copy Python environment and packages
160
- ENV VIRTUAL_ENV=/ragflow/.venv
161
- COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
162
- ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
163
-
164
  ENV PYTHONPATH=/ragflow/
165
 
 
 
 
 
 
 
 
 
 
166
  COPY docker/service_conf.yaml.template ./conf/service_conf.yaml.template
167
  COPY docker/entrypoint.sh ./entrypoint.sh
168
  RUN chmod +x ./entrypoint.sh
169
 
 
 
 
 
 
170
  ENTRYPOINT ["./entrypoint.sh"]
 
59
 
60
  WORKDIR /ragflow
61
 
62
+ # install dependencies from poetry.lock file
63
+ COPY pyproject.toml poetry.toml poetry.lock ./
64
+
65
+ RUN --mount=type=cache,id=ragflow_builder_poetry,target=/root/.cache/pypoetry,sharing=locked \
66
+ if [ "$LIGHTEN" == "1" ]; then \
67
+ poetry install --no-root; \
68
+ else \
69
+ poetry install --no-root --with=full; \
70
+ fi
71
+
72
+ COPY web web
73
+ COPY docs docs
74
+ RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
75
+ cd web && npm install --force && npm run build
76
+
77
  COPY .git /ragflow/.git
78
 
79
  RUN current_commit=$(git rev-parse --short HEAD); \
 
93
  echo "RAGFlow version: $version_info"; \
94
  echo $version_info > /ragflow/VERSION
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  # production stage
97
  FROM base AS production
98
  USER root
99
 
100
  WORKDIR /ragflow
101
 
102
+ # Copy Python environment and packages
103
+ ENV VIRTUAL_ENV=/ragflow/.venv
104
+ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
105
+ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
106
 
107
  # Install python packages' dependencies
108
  # cv2 requires libGL.so.1
 
110
  apt update && apt install -y --no-install-recommends nginx libgl1 vim less && \
111
  rm -rf /var/lib/apt/lists/*
112
 
 
 
 
 
 
 
 
 
 
113
  # Copy models downloaded via download_deps.py
114
  RUN mkdir -p /ragflow/rag/res/deepdoc /root/.ragflow
115
  RUN --mount=type=bind,source=huggingface.co,target=/huggingface.co \
 
147
  mv chromedriver /usr/local/bin/ && \
148
  rm -f /usr/bin/google-chrome
149
 
 
 
 
 
 
 
 
 
150
  ENV PYTHONPATH=/ragflow/
151
 
152
+ COPY web web
153
+ COPY api api
154
+ COPY conf conf
155
+ COPY deepdoc deepdoc
156
+ COPY rag rag
157
+ COPY agent agent
158
+ COPY graphrag graphrag
159
+ COPY pyproject.toml poetry.toml poetry.lock ./
160
+
161
  COPY docker/service_conf.yaml.template ./conf/service_conf.yaml.template
162
  COPY docker/entrypoint.sh ./entrypoint.sh
163
  RUN chmod +x ./entrypoint.sh
164
 
165
+ # Copy compiled web pages
166
+ COPY --from=builder /ragflow/web/dist /ragflow/web/dist
167
+
168
+ COPY --from=builder /ragflow/VERSION /ragflow/VERSION
169
+
170
  ENTRYPOINT ["./entrypoint.sh"]