dify/api/Dockerfile

67 lines
1.5 KiB
Docker
Raw Normal View History

# base image
FROM python:3.10-slim-bookworm AS base
2023-05-15 08:51:32 +08:00
WORKDIR /app/api
# Install Poetry
ENV POETRY_VERSION=1.8.3
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --upgrade 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
2023-05-15 08:51:32 +08:00
FROM base AS packages
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
2023-05-15 08:51:32 +08:00
EXPOSE 5001
# set timezone
ENV TZ=UTC
2023-05-15 08:51:32 +08:00
WORKDIR /app/api
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl wget vim nodejs ffmpeg libgmp-dev libmpfr-dev libmpc-dev \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
2023-05-15 08:51:32 +08:00
# Copy Python environment and packages
ENV VIRTUAL_ENV=/app/api/.venv
COPY --from=packages ${VIRTUAL_ENV} ${VIRTUAL_ENV}
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
# Copy source code
2023-05-15 08:51:32 +08:00
COPY . /app/api/
# Copy entrypoint
2023-05-15 08:51:32 +08:00
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
2023-05-15 08:51:32 +08:00
ARG COMMIT_SHA
ENV COMMIT_SHA=${COMMIT_SHA}
2023-05-15 08:51:32 +08:00
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]