我在Heroku上运行了一个应用程序,需要在上传到外部存储之前进行处理。我的工作目录是/usr/src/app/,程序无法再找到文件。下面是我的Dockerfile的样子:
FROM ubuntu
RUN apt-get update && apt-get -y install poppler-utils && apt-get clean
FROM python:alpine3.7
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY upload.py /usr/src/app/
COPY index.html /usr/src/app/
COPY success.html /usr/src/app/
COPY requirements.txt /usr/src/app/
CMD gunicorn --bind 0.0.0.0:$PORT wsgi
RUN pip install -r requirements.txt
CMD python ./upload.py我就是这么叫波普勒的
commandCall = 'pdftohtml -c -s "' + newPath + '" "' + htmlPath + '"'
subprocess.call(commandCall, shell=True)它应该保存在工作目录中,但当我使用由它创建的文件时,它无法找到它。我使用Tornado作为我的HTTP处理程序,我想知道问题是否与在容器中使用子进程调用有关。
发布于 2020-06-19 23:20:14
当前的Dockerfile是不可构建的。
首先,启动gunicorn的命令需要一个wsgi模块,该模块在作为参数传递给gunicorn可执行文件之前从未被复制过。
此外,Dockerfile中还列出了多个命令。Docker only respects the last command as the entrypoint command to run。
您的dockerfile可以按如下方式进行清理:
文档文件
FROM ubuntu
RUN apt-get update && apt-get -y install poppler-utils && apt-get clean
FROM python:alpine3.7
WORKDIR /usr/src/app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
RUN adduser -D myuser
USER myuser
CMD gunicorn --user myuser --bind 0.0.0.0:$PORT wsgi:app上面的文件假设在将执行docker build命令的文件夹中有一个wsgi.py模块,并且在该文件中声明了一个app名称,该名称绑定到实现WSGI应用程序接口的对象。
测试一下,您可以通过运行docker build -t poppler .在本地构建它。
还要注意,即使对于docker图像,the filesystem is ephemeral也是如此。所以file is only persisted for the lifetime of your dynos。
如果您需要在入口点命令中运行多个进程,请考虑使用supervisord。
https://stackoverflow.com/questions/62304878
复制相似问题