|
|
|
FROM node:20.11-alpine3.19 AS base |
|
|
|
|
|
ENV NODE_OPTIONS="--max_old_space_size=2048" \ |
|
NEXT_TELEMETRY_DISABLED=1 \ |
|
NODE_ENV=production \ |
|
PYTHONDONTWRITEBYTECODE=1 \ |
|
POETRY_NO_INTERACTION=1 \ |
|
POETRY_VIRTUALENVS_CREATE=false \ |
|
POETRY_CACHE_DIR=/cache/poetry |
|
|
|
|
|
FROM base AS web-builder |
|
|
|
WORKDIR /app/web |
|
|
|
|
|
COPY web/package.json web/yarn.lock ./ |
|
|
|
|
|
RUN npm install -g code-inspector-plugin autoprefixer postcss tailwindcss |
|
|
|
|
|
RUN yarn install --frozen-lockfile --network-timeout 300000 && \ |
|
yarn add --dev @types/node @types/react code-inspector-plugin autoprefixer postcss tailwindcss |
|
|
|
|
|
COPY web/ . |
|
|
|
|
|
RUN NODE_PATH=/usr/local/lib/node_modules yarn build |
|
|
|
|
|
FROM python:3.10-slim-bookworm AS python-builder |
|
|
|
|
|
RUN apt-get update && \ |
|
apt-get install -y --no-install-recommends \ |
|
build-essential \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
WORKDIR /app/api |
|
|
|
|
|
RUN pip install --no-cache-dir poetry |
|
|
|
|
|
COPY api/pyproject.toml api/poetry.lock ./ |
|
RUN poetry config virtualenvs.create false && \ |
|
poetry install --no-dev --no-interaction --no-ansi |
|
|
|
|
|
FROM python:3.10-slim-bookworm |
|
|
|
|
|
RUN useradd -m -u 1000 user |
|
|
|
|
|
RUN apt-get update && \ |
|
apt-get install -y --no-install-recommends \ |
|
nodejs \ |
|
npm \ |
|
curl \ |
|
libgmp-dev \ |
|
libmpfr-dev \ |
|
libmpc-dev \ |
|
fonts-noto-cjk \ |
|
ffmpeg \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
WORKDIR /app |
|
RUN mkdir -p api web api/storage && chown -R user:user /app |
|
|
|
|
|
RUN pip install --no-cache-dir \ |
|
gunicorn \ |
|
gevent \ |
|
flask \ |
|
cloudscraper \ |
|
torch \ |
|
tensorflow \ |
|
flax \ |
|
transformers \ |
|
celery \ |
|
arxiv \ |
|
matplotlib \ |
|
duckduckgo_search \ |
|
jsonpath_ng \ |
|
pydub \ |
|
qrcode \ |
|
twilio \ |
|
vanna \ |
|
wikipedia \ |
|
yfinance \ |
|
scipy \ |
|
nltk \ |
|
unstructured |
|
|
|
|
|
RUN python -m nltk.downloader punkt averaged_perceptron_tagger |
|
|
|
|
|
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/ |
|
|
|
|
|
COPY --from=web-builder --chown=user /app/web/.next /app/web/.next |
|
COPY --from=web-builder --chown=user /app/web/public /app/web/public |
|
COPY --from=web-builder --chown=user /app/web/node_modules /app/web/node_modules |
|
COPY --from=web-builder --chown=user /app/web/package.json /app/web/package.json |
|
|
|
|
|
VOLUME ["/app/api/storage"] |
|
|
|
|
|
ENV FLASK_APP=app.py \ |
|
EDITION=SELF_HOSTED \ |
|
DEPLOY_ENV=PRODUCTION \ |
|
CONSOLE_API_URL=http://127.0.0.1:7860 \ |
|
CONSOLE_WEB_URL=http://127.0.0.1:3000 \ |
|
SERVICE_API_URL=http://127.0.0.1:7860 \ |
|
APP_WEB_URL=http://127.0.0.1:3000 \ |
|
NODE_ENV=production \ |
|
HOME=/app \ |
|
PATH="/usr/local/bin:${PATH}" \ |
|
PYTHONPATH=/app/api \ |
|
TZ=UTC \ |
|
NLTK_DATA=/usr/local/share/nltk_data \ |
|
|
|
DB_USERNAME=postgres \ |
|
DB_PASSWORD=difyai123456 \ |
|
DB_HOST=localhost \ |
|
DB_PORT=5432 \ |
|
DB_DATABASE=dify \ |
|
|
|
REDIS_HOST=localhost \ |
|
REDIS_PORT=6379 \ |
|
REDIS_DB=0 \ |
|
|
|
MAIL_TYPE=resend \ |
|
MAIL_DEFAULT_SENDER=no[email protected] \ |
|
MAIL_DEFAULT_SENDER_NAME=Dify \ |
|
MAIL_RESEND_API_KEY=null \ |
|
|
|
STORAGE_TYPE=local \ |
|
STORAGE_LOCAL_PATH=/app/api/storage \ |
|
|
|
VECTOR_STORE=qdrant \ |
|
QDRANT_URL=http://localhost:6333 \ |
|
|
|
SECRET_KEY=your-secret-key \ |
|
SECURITY_PASSWORD_SALT=your-password-salt \ |
|
|
|
EDITION=SELF_HOSTED \ |
|
DEPLOY_ENV=PRODUCTION \ |
|
|
|
DISABLE_TELEMETRY=true \ |
|
|
|
DEBUG=false \ |
|
|
|
LOG_LEVEL=INFO \ |
|
|
|
DEMO_MODE=false \ |
|
|
|
DISABLE_REGISTRATION=false \ |
|
|
|
CELERY_BROKER_URL=redis://localhost:6379/1 \ |
|
CELERY_RESULT_BACKEND=redis://localhost:6379/2 \ |
|
SENTRY_DSN="" \ |
|
SENTRY_TRACES_SAMPLE_RATE=1.0 \ |
|
SENTRY_PROFILES_SAMPLE_RATE=1.0 \ |
|
OAUTH_REDIRECT_PATH=/console/api/oauth/authorize \ |
|
OAUTH_REDIRECT_INDEX_PATH=/console/api/oauth/callback \ |
|
CONSOLE_URL=http://localhost:3000 \ |
|
SERVICE_API_URL=http://localhost:7860 \ |
|
APP_API_URL=http://localhost:7860 \ |
|
APP_WEB_URL=http://localhost:3000 |
|
|
|
|
|
USER user |
|
|
|
|
|
EXPOSE 7860 3000 5001 |
|
|
|
|
|
COPY --chown=user docker/entrypoint.sh /app/entrypoint.sh |
|
RUN chmod +x /app/entrypoint.sh |
|
|
|
WORKDIR /app |
|
|
|
CMD ["./entrypoint.sh"] |