I am using docker 17.05.0-cs edge on Ubuntu 17.04 Zesty. I have a gunicorn/Django app that I built here. It runs fine before being dockerized, but gunicorn can't see the staticfiles after docker build
. Here is the Dockerfile
:
# 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!
The app runs and displays the page, funny, it even applies the css
templates while saying it can't find bootstrap.css
or bootstrap.js
. It does not execute the script to toggle the menu though. The current templates are just an artifact of my initial build, the new ones won't even use bootstrap.js
I'm pretty sure. It runs but the toggle doesn't work which I know is a feature of bootstrap.js
. This is the out from 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
I appended the static file url pattern to urls.py
, I am pretty sure this has to do with the container build, or perhaps settings.py
. Perhaps I need to add an environment directory for the static files? Any help is, of course, appreciated.