
Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: KVOJJJin <jzongcode@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in>
88 lines
2.6 KiB
Docker
88 lines
2.6 KiB
Docker
# base image
|
|
FROM python:3.12-slim-bookworm AS base
|
|
|
|
WORKDIR /app/api
|
|
|
|
# Install Poetry
|
|
ENV POETRY_VERSION=2.0.1
|
|
|
|
# if you located in China, you can use aliyun mirror to speed up
|
|
# RUN pip install --no-cache-dir poetry==${POETRY_VERSION} -i https://mirrors.aliyun.com/pypi/simple/
|
|
|
|
RUN pip install --no-cache-dir 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
|
|
ENV POETRY_REQUESTS_TIMEOUT=15
|
|
|
|
FROM base AS packages
|
|
|
|
# if you located in China, you can use aliyun mirror to speed up
|
|
# RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources
|
|
|
|
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
|
|
|
|
EXPOSE 5001
|
|
|
|
# set timezone
|
|
ENV TZ=UTC
|
|
|
|
WORKDIR /app/api
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends curl nodejs libgmp-dev libmpfr-dev libmpc-dev \
|
|
# if you located in China, you can use aliyun mirror to speed up
|
|
# && echo "deb http://mirrors.aliyun.com/debian testing main" > /etc/apt/sources.list \
|
|
&& echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list \
|
|
&& apt-get update \
|
|
# For Security
|
|
&& apt-get install -y --no-install-recommends expat=2.6.4-1 libldap-2.5-0=2.5.19+dfsg-1 perl=5.40.0-8 libsqlite3-0=3.46.1-1 zlib1g=1:1.3.dfsg+really1.3.1-1+b1 \
|
|
# install a chinese font to support the use of tools like matplotlib
|
|
&& apt-get install -y fonts-noto-cjk \
|
|
&& apt-get autoremove -y \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy Python environment and packages
|
|
ENV VIRTUAL_ENV=/app/api/.venv
|
|
COPY --from=packages ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
|
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
|
|
|
# Download nltk data
|
|
RUN python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
|
|
|
|
ENV TIKTOKEN_CACHE_DIR=/app/api/.tiktoken_cache
|
|
|
|
RUN python -c "import tiktoken; tiktoken.encoding_for_model('gpt2')"
|
|
|
|
# Copy source code
|
|
COPY . /app/api/
|
|
|
|
# Copy entrypoint
|
|
COPY docker/entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
|
|
ARG COMMIT_SHA
|
|
ENV COMMIT_SHA=${COMMIT_SHA}
|
|
|
|
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
|