Underground-Digital/Workflow-Engine
0
1# base image2FROM python:3.10-slim-bookworm AS base3 4WORKDIR /app/api5 6# Install Poetry7ENV POETRY_VERSION=1.8.38 9# if you located in China, you can use aliyun mirror to speed up10# RUN pip install --no-cache-dir poetry==${POETRY_VERSION} -i https://mirrors.aliyun.com/pypi/simple/11 12RUN pip install --no-cache-dir poetry==${POETRY_VERSION}13 14# Configure Poetry15ENV POETRY_CACHE_DIR=/tmp/poetry_cache16ENV POETRY_NO_INTERACTION=117ENV POETRY_VIRTUALENVS_IN_PROJECT=true18ENV POETRY_VIRTUALENVS_CREATE=true19ENV POETRY_REQUESTS_TIMEOUT=1520 21FROM base AS packages22 23# if you located in China, you can use aliyun mirror to speed up24# RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources25 26RUN apt-get update \27 && apt-get install -y --no-install-recommends gcc g++ libc-dev libffi-dev libgmp-dev libmpfr-dev libmpc-dev28 29# Install Python dependencies30COPY pyproject.toml poetry.lock ./31RUN poetry install --sync --no-cache --no-root32 33# production stage34FROM base AS production35 36ENV FLASK_APP=app.py37ENV EDITION=SELF_HOSTED38ENV DEPLOY_ENV=PRODUCTION39ENV CONSOLE_API_URL=http://127.0.0.1:500140ENV CONSOLE_WEB_URL=http://127.0.0.1:300041ENV SERVICE_API_URL=http://127.0.0.1:500142ENV APP_WEB_URL=http://127.0.0.1:300043 44EXPOSE 500145 46# set timezone47ENV TZ=UTC48 49WORKDIR /app/api50 51RUN apt-get update \52 && apt-get install -y --no-install-recommends curl nodejs libgmp-dev libmpfr-dev libmpc-dev \53 # if you located in China, you can use aliyun mirror to speed up54 # && echo "deb http://mirrors.aliyun.com/debian testing main" > /etc/apt/sources.list \55 && echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list \56 && apt-get update \57 # For Security58 && apt-get install -y --no-install-recommends expat=2.6.3-2 libldap-2.5-0=2.5.18+dfsg-3+b1 perl=5.40.0-6 libsqlite3-0=3.46.1-1 zlib1g=1:1.3.dfsg+really1.3.1-1+b1 \59 # install a chinese font to support the use of tools like matplotlib60 && apt-get install -y fonts-noto-cjk \61 && apt-get autoremove -y \62 && rm -rf /var/lib/apt/lists/*63 64# Copy Python environment and packages65ENV VIRTUAL_ENV=/app/api/.venv66COPY --from=packages ${VIRTUAL_ENV} ${VIRTUAL_ENV}67ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"68 69# Download nltk data70RUN python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"71 72# Copy source code73COPY . /app/api/74 75# Copy entrypoint76COPY docker/entrypoint.sh /entrypoint.sh77RUN chmod +x /entrypoint.sh78 79 80ARG COMMIT_SHA81ENV COMMIT_SHA=${COMMIT_SHA}82 83ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]84 