FROM base-dm # 升级pip RUN pip install --upgrade pip # 创建一个用户运行flask RUN adduser flask RUN chown -R flask:flask /home/flask RUN mkdir -p /var/log/flask-app && touch /var/log/flask-app/flask-app.err.log && touch /var/log/flask-app/flask-app.out.log RUN chown -R flask:flask /var/log/flask-app WORKDIR /home/flask USER flask # 复制 COPY --chown=flask:flask . . # venv ENV VIRTUAL_ENV=/home/flask/venv # 安装包 RUN python3 -m venv "$VIRTUAL_ENV" ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN export FLASK_APP=main.py COPY --from=build-dmpython --chown=flask:flask /home/dmdba/build_artifacts/dmPython-2.5.5-cp310-cp310-linux_x86_64.whl . COPY --from=build-dmpython /home/dmdba/build_artifacts/libdmdpi.so /usr/lib/ COPY --from=build-frontend /usr/src/app/build/ /home/flask/public/ RUN pip3 install dmPython-2.5.5-cp310-cp310-linux_x86_64.whl && rm dmPython-2.5.5-cp310-cp310-linux_x86_64.whl RUN MAKEFLAGS="-j$(nproc)" pip install -r requirements.txt USER root # 暴露端口 EXPOSE 5000 CMD ["python", "main.py"]