|
|
|
|
|
|
|
FROM python:3.10-slim-bookworm AS base |
|
|
|
|
|
ARG CACHEBUST=1 |
|
ARG DEBIAN_FRONTEND=noninteractive |
|
|
|
|
|
RUN apt-get update && \ |
|
apt-get install -y --no-install-recommends \ |
|
curl \ |
|
gnupg \ |
|
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ |
|
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ |
|
&& apt-get update \ |
|
&& apt-get install -y nodejs \ |
|
&& npm install -g yarn \ |
|
&& apt-get clean \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
RUN apt-get update && \ |
|
apt-get install -y --no-install-recommends \ |
|
build-essential \ |
|
gcc \ |
|
g++ \ |
|
libc6-dev \ |
|
libffi-dev \ |
|
libgmp-dev \ |
|
libmpfr-dev \ |
|
libmpc-dev \ |
|
libssl-dev \ |
|
make \ |
|
pkg-config \ |
|
&& apt-get clean \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
RUN node --version && npm --version && yarn --version |
|
|
|
|
|
RUN pip install --no-cache-dir \ |
|
gunicorn \ |
|
gevent \ |
|
grpcio \ |
|
pydantic-settings \ |
|
protobuf \ |
|
grpcio-tools \ |
|
flask \ |
|
flask-cors \ |
|
Flask-SQLAlchemy==3.1.1 \ |
|
Flask-Migrate==4.0.7 \ |
|
flask-login \ |
|
flask-restful \ |
|
flask-limiter \ |
|
flask-caching \ |
|
flask-jwt-extended \ |
|
flask-socketio |
|
|
|
|
|
RUN pip install --no-cache-dir nltk && \ |
|
python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')" |
|
|
|
|
|
|
|
|
|
FROM base AS web-builder |
|
|
|
WORKDIR /app |
|
|
|
|
|
COPY web/ web/ |
|
|
|
WORKDIR /app/web |
|
|
|
|
|
RUN yarn install --frozen-lockfile && \ |
|
yarn add --dev autoprefixer postcss tailwindcss code-inspector-plugin && \ |
|
NEXT_TELEMETRY_DISABLED=1 yarn build && \ |
|
mkdir -p .next/standalone && \ |
|
cp -r .next/static .next/standalone/.next/ && \ |
|
cp -r public .next/standalone/ && \ |
|
yarn cache clean |
|
|
|
|
|
|
|
|
|
FROM base AS python-builder |
|
|
|
WORKDIR /app |
|
|
|
|
|
COPY api/ api/ |
|
|
|
WORKDIR /app/api |
|
|
|
|
|
RUN pip install --no-cache-dir poetry==1.8.3 && \ |
|
poetry config virtualenvs.create false && \ |
|
poetry install --no-dev --no-interaction --no-ansi |
|
|
|
|
|
|
|
|
|
FROM base |
|
|
|
|
|
RUN apt-get update && \ |
|
useradd -m -u 1000 user && \ |
|
mkdir -p /storage/files /storage/cache /storage/logs && \ |
|
chown -R user:user /storage && \ |
|
mkdir -p /app/api && \ |
|
chown -R user:user /app |
|
|
|
|
|
RUN apt-get update && \ |
|
apt-get install -y --no-install-recommends \ |
|
build-essential \ |
|
nodejs \ |
|
npm \ |
|
libgmp-dev \ |
|
libmpfr-dev \ |
|
libmpc-dev \ |
|
libssl-dev \ |
|
postgresql-client \ |
|
redis-tools && \ |
|
apt-get clean && \ |
|
rm -rf /var/lib/apt/lists/* && \ |
|
pip install --no-cache-dir \ |
|
gunicorn \ |
|
gevent \ |
|
grpcio \ |
|
pydantic-settings \ |
|
protobuf \ |
|
grpcio-tools \ |
|
flask \ |
|
flask-cors \ |
|
Flask-SQLAlchemy==3.1.1 \ |
|
Flask-Migrate==4.0.7 \ |
|
flask-login \ |
|
flask-restful \ |
|
flask-limiter \ |
|
flask-caching \ |
|
flask-jwt-extended \ |
|
flask-socketio \ |
|
PyYAML \ |
|
celery \ |
|
redis \ |
|
psycopg2-binary \ |
|
sqlalchemy \ |
|
alembic \ |
|
pyjwt \ |
|
requests \ |
|
numpy \ |
|
pandas \ |
|
python-dotenv \ |
|
pycryptodome \ |
|
cryptography \ |
|
bcrypt \ |
|
python-jose[cryptography] \ |
|
passlib \ |
|
python-multipart \ |
|
gmpy2 \ |
|
transformers \ |
|
torch \ |
|
tensorflow \ |
|
sentencepiece \ |
|
tokenizers \ |
|
nltk \ |
|
openai==1.14.0 \ |
|
anthropic==0.23.1 \ |
|
flask-migrate==4.0.5 \ |
|
Pillow \ |
|
opencv-python-headless \ |
|
scikit-learn \ |
|
scipy \ |
|
google-cloud-aiplatform \ |
|
google-generativeai \ |
|
vertexai \ |
|
google-cloud-core \ |
|
google-api-core \ |
|
yarl \ |
|
aiohttp \ |
|
tritonclient[all] \ |
|
cohere==4.43 \ |
|
anthropic \ |
|
replicate \ |
|
aleph-alpha-client \ |
|
stability-sdk \ |
|
huggingface_hub \ |
|
langchain \ |
|
langchain-community \ |
|
langchain-core \ |
|
langchain-openai \ |
|
openai==1.14.0 \ |
|
Flask-Migrate==4.0.7 \ |
|
Flask-SQLAlchemy==3.1.1 && \ |
|
python -m nltk.downloader punkt averaged_perceptron_tagger |
|
|
|
|
|
WORKDIR /app |
|
RUN mkdir -p api web && chown -R user:user /app |
|
|
|
|
|
COPY --from=python-builder --chown=user /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages |
|
COPY --chown=user api/ /app/api/ |
|
|
|
|
|
RUN mkdir -p /app/web/.next/standalone /app/web/.next/static |
|
COPY --from=web-builder --chown=user /app/web/.next/standalone /app/web/.next/standalone |
|
COPY --from=web-builder --chown=user /app/web/.next/static /app/web/.next/static |
|
COPY --from=web-builder --chown=user /app/web/public /app/web/public |
|
|
|
|
|
ENV FLASK_APP=app.py \ |
|
EDITION=SELF_HOSTED \ |
|
DEPLOY_ENV=PRODUCTION \ |
|
PYTHONPATH=/app/api \ |
|
PATH="/usr/local/bin:${PATH}" \ |
|
STORAGE_DIR=/storage \ |
|
|
|
DB_USERNAME=postgres \ |
|
DB_PASSWORD=difyai123456 \ |
|
DB_HOST=db \ |
|
DB_PORT=5432 \ |
|
DB_DATABASE=dify \ |
|
SQLALCHEMY_POOL_SIZE=30 \ |
|
SQLALCHEMY_POOL_RECYCLE=3600 \ |
|
|
|
REDIS_HOST=redis \ |
|
REDIS_PORT=6379 \ |
|
REDIS_PASSWORD=difyai123456 \ |
|
REDIS_DB=0 |
|
|
|
|
|
COPY docker/entrypoint.sh /app/entrypoint.sh |
|
RUN chmod +x /app/entrypoint.sh |
|
|
|
|
|
USER user |
|
|
|
|
|
EXPOSE 7860 3000 |
|
|
|
|
|
VOLUME ["/storage/files", "/storage/cache", "/storage/logs"] |
|
|
|
WORKDIR /app |
|
CMD ["./entrypoint.sh"] |