mirror of
https://gitee.com/dify_ai/dify.git
synced 2024-11-30 02:08:37 +08:00
82 lines
2.4 KiB
Docker
82 lines
2.4 KiB
Docker
# base image
|
|
FROM python:3.10-slim-bookworm AS base
|
|
|
|
WORKDIR /app/api
|
|
|
|
# Install Poetry
|
|
ENV POETRY_VERSION=1.8.3
|
|
|
|
# if you located in China, you can use aliyun mirror to speed up
|
|
# RUN pip install --no-cache-dir poetry==${POETRY_VERSION} -i https://mirrors.aliyun.com/pypi/simple/
|
|
|
|
RUN pip install --no-cache-dir poetry==${POETRY_VERSION}
|
|
|
|
# Configure Poetry
|
|
ENV POETRY_CACHE_DIR=/tmp/poetry_cache
|
|
ENV POETRY_NO_INTERACTION=1
|
|
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
|
|
ENV POETRY_VIRTUALENVS_CREATE=true
|
|
ENV POETRY_REQUESTS_TIMEOUT=15
|
|
|
|
FROM base AS packages
|
|
|
|
# if you located in China, you can use aliyun mirror to speed up
|
|
# RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends gcc g++ libc-dev libffi-dev libgmp-dev libmpfr-dev libmpc-dev
|
|
|
|
# Install Python dependencies
|
|
COPY pyproject.toml poetry.lock ./
|
|
RUN poetry install --sync --no-cache --no-root
|
|
|
|
# production stage
|
|
FROM base AS production
|
|
|
|
ENV FLASK_APP=app.py
|
|
ENV EDITION=SELF_HOSTED
|
|
ENV DEPLOY_ENV=PRODUCTION
|
|
ENV CONSOLE_API_URL=http://127.0.0.1:5001
|
|
ENV CONSOLE_WEB_URL=http://127.0.0.1:3000
|
|
ENV SERVICE_API_URL=http://127.0.0.1:5001
|
|
ENV APP_WEB_URL=http://127.0.0.1:3000
|
|
|
|
EXPOSE 5001
|
|
|
|
# set timezone
|
|
ENV TZ=UTC
|
|
|
|
WORKDIR /app/api
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends curl nodejs libgmp-dev libmpfr-dev libmpc-dev \
|
|
# if you located in China, you can use aliyun mirror to speed up
|
|
# && echo "deb http://mirrors.aliyun.com/debian testing main" > /etc/apt/sources.list \
|
|
&& echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list \
|
|
&& apt-get update \
|
|
# For Security
|
|
&& apt-get install -y --no-install-recommends zlib1g=1:1.3.dfsg+really1.3.1-1 expat=2.6.3-1 libldap-2.5-0=2.5.18+dfsg-3 perl=5.38.2-5 libsqlite3-0=3.46.0-1 \
|
|
&& apt-get autoremove -y \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy Python environment and packages
|
|
ENV VIRTUAL_ENV=/app/api/.venv
|
|
COPY --from=packages ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
|
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
|
|
|
# Download nltk data
|
|
RUN python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
|
|
|
|
# Copy source code
|
|
COPY . /app/api/
|
|
|
|
# Copy entrypoint
|
|
COPY docker/entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
|
|
ARG COMMIT_SHA
|
|
ENV COMMIT_SHA=${COMMIT_SHA}
|
|
|
|
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
|