python dockerfile
一种:
## 使用一个官方Python运行时作为父镜像
#FROM python:3.11
#
#RUN apt-get update && apt-get install -y python3-pip
FROM registry.cn-hangzhou.aliyuncs.com/kattgatt-base/python-smart-home-plugins:v4
# 设置工作目录
WORKDIR /app
ENV PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
ENV PIP_TRUSTED_HOST=mirrors.aliyun.com
## 安装依赖
COPY requirements.txt .
RUN pip install -r requirements.txt
# 复制当前目录内容到容器的/app内
WORKDIR /app
COPY . .
# 声明服务运行在5000端口
EXPOSE 5800
# 声明其他变量
#ENV ENVIRONMENT=dev
#ENV ENVIRONMENT=prod_k8s
ENV ENVIRONMENT=uat_k8s
# 启动flask服务
CMD gunicorn -w 4 -b 0.0.0.0:5800 "flaskr:create_app('$ENVIRONMENT')" --timeout 300 --log-level debug --access-logfile /var/log/app.log --capture-output
2种:
## 使用一个官方Python运行时作为父镜像
FROM registry.cn-hangzhou.aliyuncs.com/baimeidashu-k8s/condaffmpeg:v1.3
#python3.19.9
#ENV PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
#ENV PIP_TRUSTED_HOST=mirrors.aliyun.com
#RUN conda activate suno
ENV PATH /root/miniconda3/envs/suno/bin:$PATH
RUN echo "conda activate suno" >> ~/.bashrc
## 安装依赖
COPY requirements.txt .
RUN pip3 install -r requirements.txt
# 复制当前目录内容到容器的/app内
WORKDIR /app
COPY . .
# 声明服务运行在5000端口
EXPOSE 8130
# 声明其他变量
#ENV ENVIRONMENT=dev
#ENV ENVIRONMENT=prod_k8s
ENV ENVIRONMENT=uat_k8s
CMD ["python", "api_v2.py", "&&", "python", "create_task.py"]
#CMD python create_task.py &
# 启动flask服务
#CMD gunicorn -w 4 -b 0.0.0.0:5800 "flaskr:create_app('$ENVIRONMENT')" --timeout 300 --log-level debug --access-logfile /var/log/app.log --capture-output
springboot dockerfile : 连接
tomcat dockerfile文件 : 连接
node dockerfile (nginx) :连接
python dockerfile : 连接