我在Ubuntu 17.04 Zesty上使用docker 17.05.0-cs edge。我有一个我建立的gunicorn/Django应用程序here。在docker化之前它运行良好,但gunistorn在docker build
之后无法看到静态文件。这里是Dockerfile
:dockerization后,Gunicorn找不到staticfiles
# Dockerfile
# FROM base image to build upon
FROM phusion/baseimage
# RUN install python and pip
RUN apt-get update
RUN apt-get install -y python python-pip python-dev
# ENV set environment directory tree
ENV PROJECT=mysite
ENV CONTAINER_HOME=/opt
ENV CONTAINER_PROJECT=$CONTAINER_HOME/$PROJECT
# move to project WORKDIR
WORKDIR $CONTAINER_PROJECT
# COPY project to container directory
COPY . $CONTAINER_PROJECT
# RUN pip and install requirements
RUN pip install -r requirements.txt
# COPY start.sh into known container location
COPY start.sh /start.sh
# EXPOSE port 8000 to allow communication to/from server
EXPOSE 8000
# CMD execute start.sh to start the server running.
CMD ["/start.sh"]
# done!
的应用程序运行并显示页面,滑稽,甚至一边说无法找到bootstrap.css
或bootstrap.js
应用css
模板。它不会执行脚本来切换菜单。目前的模板只是我最初构建的工件,新的模板甚至不会使用bootstrap.js
我很确定。它运行,但切换不起作用,我知道是bootstrap.js
的功能。这是sudo docker run -it -p 8000:8000 dockerized_site
了出来:
Starting Gunicorn.
[2017-06-07 00:38:56 +0000] [1] [INFO] Starting gunicorn 19.6.0
[2017-06-07 00:38:56 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2017-06-07 00:38:56 +0000] [1] [INFO] Using worker: sync
[2017-06-07 00:38:56 +0000] [9] [INFO] Booting worker with pid: 9
[2017-06-07 00:38:56 +0000] [10] [INFO] Booting worker with pid: 10
[2017-06-07 00:38:56 +0000] [11] [INFO] Booting worker with pid: 11
Not Found: /js/bootstrap.min.js
Not Found: /js/jquery.js
Not Found: /js/bootstrap.min.js
Not Found: /favicon.ico
我追加静态文件的URL模式urls.py
,我敢肯定,这与集装箱打造,或者是settings.py
做。也许我需要为静态文件添加一个环境目录?当然,任何帮助都是值得赞赏的。
请问您可以发布gunicorn引发的错误吗? – Robert