Workflow-Engine / Dockerfile
Severian's picture
Update Dockerfile
3f8fa9d verified
raw
history blame
2.04 kB
# Base stage with shared configuration
FROM node:20.11-alpine3.19 AS base
# Configure shared environment variables
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
# Web builder stage
FROM langgenius/dify-web:latest AS web-builder
WORKDIR /app/web
# Copy web artifacts
COPY --from=langgenius/dify-web:latest /app/web/.next /app/web/.next
COPY --from=langgenius/dify-web:latest /app/web/public /app/web/public
COPY --from=langgenius/dify-web:latest /app/web/package.json /app/web/package.json
# API builder stage
FROM langgenius/dify-api:latest AS api-builder
WORKDIR /app/api
# Copy API artifacts
COPY --from=langgenius/dify-api:latest /app/api /app/api/
# Final stage
FROM python:3.10-slim-bookworm
# Create non-root user (required by Hugging Face)
RUN useradd -m -u 1000 user
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
nodejs \
npm \
&& rm -rf /var/lib/apt/lists/*
# Set up directory structure
WORKDIR /app
RUN mkdir -p api web && chown -R user:user /app
# Copy artifacts from builders
COPY --from=api-builder --chown=user /app/api /app/api/
COPY --from=web-builder --chown=user /app/web /app/web
# Install Python requirements
RUN pip install --no-cache-dir gunicorn gevent
# Set environment variables for Hugging Face Spaces
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
# Switch to non-root user
USER user
# Expose Hugging Face Spaces required port
EXPOSE 7860 3000
# Setup entrypoint
COPY --chown=user docker/entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
WORKDIR /app
CMD ["./entrypoint.sh"]