Code Monkey home page Code Monkey logo

Comments (16)

GrahamDumpleton avatar GrahamDumpleton commented on July 2, 2024 1

Create an executable shell script at .whiskey/action_hooks/deploy in the repository and add the command in there. That script is run after the container is started, but before your application is started.

from mod_wsgi-docker.

GrahamDumpleton avatar GrahamDumpleton commented on July 2, 2024 1

There is no caching setup in Apache when used with mod_wsgi-express. Static files are always served direct off disk, so a restart/reload of Apache should not be required for changes to existing static files, or new files, to be visible.

from mod_wsgi-docker.

GrahamDumpleton avatar GrahamDumpleton commented on July 2, 2024

More information is required.

What do you have in your Dockerfile?

Have you added a build action hook? As what path in the source code? Is the file executable? What is in the file?

Has Django settings module had STATIC_ROOT set up and to what?

The output from doing the docker build would also be useful.

from mod_wsgi-docker.

evdel avatar evdel commented on July 2, 2024

Here is the content of my Dockerfile :

FROM grahamdumpleton/mod-wsgi-docker:python-2.7-onbuild
CMD [ "stcypvacances/wsgi.py" ]

stcypvacances is the name of my Django project.

I don't know what a build action hook is.

In my Django settings.py I have :

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

The output of the build is :

Sending build context to Docker daemon 18.34 MB
Step 1 : FROM grahamdumpleton/mod-wsgi-docker:python-2.7-onbuild
Executing 2 build triggers...
Step 1 : COPY . /app
Step 1 : RUN mod_wsgi-docker-build
---> Running in b05a68794e50
-----> Installing dependencies with pip
Collecting Django (from -r requirements.txt (line 1))
Downloading Django-1.10.4-py2.py3-none-any.whl (6.8MB)
Collecting psycopg2 (from -r requirements.txt (line 2))
Downloading psycopg2-2.6.2.tar.gz (376kB)
Installing collected packages: Django, psycopg2
Running setup.py install for psycopg2: started
Running setup.py install for psycopg2: finished with status 'done'
Successfully installed Django-1.10.4 psycopg2-2.6.2
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
---> a18c895ddd31
Removing intermediate container 24a166ac2567
Removing intermediate container b05a68794e50
Step 2 : CMD stcypvacances/wsgi.py
---> Running in 17240ba24686
---> 056efb6a34a3
Removing intermediate container 17240ba24686
Successfully built 056efb6a34a3

from mod_wsgi-docker.

GrahamDumpleton avatar GrahamDumpleton commented on July 2, 2024

If you haven't already, look at:

This shows what you would need for Django. The primary things are:

Just note that I have the Django project pushed down into a sub directory. You would need to adjust some of the values to match what you have.

Now the question is whether you want to still use mod_wsgi-docker image as I have a newer image which is superseding this one. There isn't an official 1.0 version yet, but you still may be interested in it. Suggest you watch:

I have also posted about it on my blog and there is:

I will be ramping up documentation and getting a 1.0 release done in the next month or so.

from mod_wsgi-docker.

evdel avatar evdel commented on July 2, 2024

I cloned the github.com/GrahamDumpleton/mod_wsgi-docker repo.
Then I went to mod_wsgi-docker/demos/django-1.7
I ran sudo docker build . -t grahamdumpleton
Docker said :
Sending build context to Docker daemon 567.3 kB
Step 1 : FROM grahamdumpleton/mod-wsgi-docker:python-2.7-onbuild
Executing 2 build triggers...
Step 1 : COPY . /app
---> Using cache
Step 1 : RUN mod_wsgi-docker-build
---> Using cache
---> 9cdcd6d9c6fa
Step 2 : USER $MOD_WSGI_USER:$MOD_WSGI_GROUP
---> Using cache
---> 2e073303b49c
Successfully built 2e073303b49c
Then I ran sudo docker run -it --rm -p 8001:80 --name grahamdumpletontest grahamdumpleton
And Docker said :
Server URL : http://localhost/
Server Root : /tmp/mod_wsgi-localhost:80:1001
Server Conf : /tmp/mod_wsgi-localhost:80:1001/httpd.conf
Error Log File : /dev/stderr (warn)
Startup Log File : /dev/stderr
Request Capacity : 5 (1 process * 5 threads)
Request Timeout : 60 (seconds)
Startup Timeout : 15 (seconds)
Queue Backlog : 100 (connections)
Queue Timeout : 45 (seconds)
Server Capacity : 20 (event/worker), 20 (prefork)
Server Backlog : 500 (connections)
Locale Setting : en_US.UTF-8
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs

from mod_wsgi-docker.

GrahamDumpleton avatar GrahamDumpleton commented on July 2, 2024

Take out:

USER $MOD_WSGI_USER:$MOD_WSGI_GROUP

from mod_wsgi-docker.

evdel avatar evdel commented on July 2, 2024

Nice ! It worked ! I am happy.

from mod_wsgi-docker.

evdel avatar evdel commented on July 2, 2024

I think this has to be in the documentation.

from mod_wsgi-docker.

GrahamDumpleton avatar GrahamDumpleton commented on July 2, 2024

As I said already, this image is being superseded. So am investing time in the replacement instead.

I also don't understand why it didn't work with the USER statement at this point. The only thing I can think of right now is that your Docker system was set up to disallow certain Linux capabilities for images when run.

from mod_wsgi-docker.

defmikekoh avatar defmikekoh commented on July 2, 2024

Is there a clean way to run collectstatic when the container starts (not at build)? I would like to have a single image that has multiple django settings files (e.g. dev, qa, prod). The result of collectstatic is going to be slightly different depending on the settings file (i.e CDN location). Right now, I can run collectstatic with specified settings file with "docker exec" after the container starts, but wondering if there's a better way.

from mod_wsgi-docker.

jayenashar avatar jayenashar commented on July 2, 2024

Hi Graham,

Is the new version in docker hub?

I'm having trouble figuring out where to put static files for / so that they are served from apache directly. I tried adding a second --url-alias / frontend/ but then nothing goes to django. What I want to do is roughly:

  • if frontend$path is a file, serve it
  • else, send to django

i know how to do this with a .htaccess file but i'm a bit lost going through /tmp/mod_wsgi-localhost:80:0 . I found MOD_WSGI_STATIC_ONLY but I'm not sure how to use it.

Thanks,
Jayen

from mod_wsgi-docker.

GrahamDumpleton avatar GrahamDumpleton commented on July 2, 2024

Use --document-root frontend.

This will set DocumentRoot to be that directory and it will be checked first for static files before routing anything else through to Django.

from mod_wsgi-docker.

GrahamDumpleton avatar GrahamDumpleton commented on July 2, 2024

Note that when running Django, you would only use this for things like favicon.ico etc where they have to be at root. Usually Django static files are at a sub directory set separately using --url-alias /static some/path/static.

from mod_wsgi-docker.

jayenashar avatar jayenashar commented on July 2, 2024

I've used react to build /, and I'm using django only for /rest and /admin (though both of those use /static). Looks like I need to move the /static react is using to something else, though otherwise --document-root does what I want. Thanks.

from mod_wsgi-docker.

wgwz avatar wgwz commented on July 2, 2024

Hi Graham, thanks for these docker images. I know this is an old thread but I have a somewhat related question.

Suppose you have --document-root frontend in .whiskey/server_args and the frontend directory has a directory called static. Let's say you have the mod_wsgi container running, and then you change those static assets (within frontend/static/), will the server reload those? AFAICT this requires restarting the container.

how can we specify that mod_wsgi reloads the static assets if they change or disable the caching of those static assets (if they are cached..)? (this is for development)

from mod_wsgi-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.