我在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