我有一个flask应用程序,可以在运行以下命令时在本地运行:
export FLASK_APP=app/prometheus/__init__.py
flask run
我的普罗米修斯烧瓶应用程序位于名为app
的文件夹中。
然后我可以在locahost:5000/metrics
看到我的页面
我想将此部署到使用docker的服务器上,但我不知道如何在dockerFile中设置这些环境变量。我的旧Dockerfile:
FROM python:3.7
WORKDIR /var/some_project
ENV PYTHONPATH "${PYTHONPATH}:/var/some_project"
COPY sources ./sources
COPY *.py ./
COPY requirements.txt ./
RUN pip3 install -r requirements.txt
ENTRYPOINT ["python", "sources/passport/main.py"]
我的新dockerfile:
FROM python:3.7
WORKDIR /var/dsys-2uid-extract
ENV PYTHONPATH "${PYTHONPATH}:/var/some_project"
ENV FLASK_APP "app/prometheus/__init__.py"
COPY app ./app
COPY sources ./sources
COPY *.py ./
COPY requirements.txt ./
RUN pip3 install -r requirements.txt
CMD ["flask", "run", "--host=0.0.0.0"]
ENTRYPOINT ["python", "sources/passport/main.py"]
这应该在我的dockerfile或k8配置中完成吗?