dm/python/Dockerfile

42 lines
1.4 KiB
Docker
Raw Normal View History

2024-07-02 13:00:00 +08:00
#flask-app
2024-06-20 14:55:36 +08:00
FROM base
2024-06-19 19:23:01 +08:00
# 创建一个用户运行flask
2024-07-06 18:32:09 +08:00
RUN useradd -m -s /bin/bash flask && \
2024-07-02 13:00:00 +08:00
chown -R flask:flask /home/flask && \
mkdir -p /var/log/flask-app && touch /var/log/flask-app/flask-app.err.log && touch /var/log/flask-app/flask-app.out.log && \
chown -R flask:flask /var/log/flask-app \
2024-07-06 18:32:09 +08:00
&& apt-get -y update \
2024-07-02 13:00:00 +08:00
&& apt-get install -y --no-install-recommends \
2024-07-03 19:02:42 +08:00
python3 python3-dev python3-pip python3-venv libssl-dev \
2024-07-02 13:00:00 +08:00
&& apt-get clean \
&& rm -rf /config/* /tmp/* /var/lib/apt/lists/* /var/tmp/* \
&& pip install --upgrade pip
2024-06-19 19:23:01 +08:00
WORKDIR /home/flask
USER flask
# 复制
COPY --chown=flask:flask . .
# venv
ENV VIRTUAL_ENV=/home/flask/venv
2024-06-20 14:55:36 +08:00
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
2024-06-19 19:23:01 +08:00
# 安装包
COPY --from=build-dmpython --chown=flask:flask /home/dmdba/build_artifacts/dmPython-2.5.5-cp310-cp310-linux_x86_64.whl .
2024-07-03 13:37:39 +08:00
2024-06-20 14:55:36 +08:00
RUN python3 -m venv "$VIRTUAL_ENV" && \
2024-07-10 23:49:39 +08:00
pip3 config set global.index-url https://mirrors.bfsu.edu.cn/pypi/web/simple && \
2024-06-20 14:55:36 +08:00
export FLASK_APP=app.py && \
2024-07-06 18:32:09 +08:00
pip3 install dmPython-2.5.5-cp310-cp310-linux_x86_64.whl && rm dmPython-2.5.5-cp310-cp310-linux_x86_64.whl && \
2024-06-20 14:55:36 +08:00
MAKEFLAGS="-j$(nproc)" pip install -r requirements.txt
2024-07-01 10:43:22 +08:00
2024-06-19 19:23:01 +08:00
COPY --from=build-dmpython /home/dmdba/build_artifacts/libdmdpi.so /usr/lib/
COPY --from=build-frontend /usr/src/app/build/ /home/flask/public/
2024-06-20 14:55:36 +08:00
2024-06-19 19:23:01 +08:00
# 暴露端口
2024-07-01 10:43:22 +08:00
EXPOSE 8000 22 8765
USER root
2024-06-19 19:23:01 +08:00
2024-07-11 17:33:57 +08:00
CMD ["python", "app.py"]