Docker [SOLVED]: Configuring a uwsgi.ini file so that a DJango project will work within a Docker container

Docker [SOLVED]: Configuring a uwsgi.ini file so that a DJango project will work within a Docker container

Home Forums Automation Tools Docker Tutorials Docker [SOLVED]: Configuring a uwsgi.ini file so that a DJango project will work within a Docker container

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #245032

    Cloudy Point
    Keymaster

    QuestionQuestion

    I am trying to set the uwsgi.ini file so that it will work with a docker container.

    In the Dockerfile, I have exposed port 8888. Below are the pieces of the Dockerfile that are related to this problem:

    Dockerfile

    EXPOSE 8888
    
    ENV DOCKER_CONTAINER=1
    
    #CMD ["uwsgi", "--ini", "/code/uwsgi.ini"]  <<< right now, this is commented out
    
    CMD ["/bin/bash"]
    

    Above, the CMD to run the uwsgi.ini file is commented out because, for me, it did not work initially. I changed the CMD to “/bin/bash” so that I could log in to the OS level of the container. After doing so, I then ran the code below:

    uwsgi --http 923b235d270e:8888 --chdir=/code/backendworkproj --module=backendworkproj.wsgi:application --env DJANGO_SETTINGS_MODULE=backendworkproj.settings --master --pidfile=/tmp/backendworkproj-master.pid --socket=127.0.0.1:49152 --processes=5 --uid=1000 --gid=2000 --harakiri=20 --max-requests=5000 --vacuum  
    

    Once complete, I was able to go to port 8888 on the machine and see the website.

    So, in short, everything worked.

    The problem I am facing now is to convert the command above to something that will work in the uwgsi.ini file

    If you look at part of the command above, I used :

    –http 923b235d270e:8888

    to specify a port. The 923b235d270e is associated with the container (since 127.0.0.1 did not work)

    How can I represent this (and env variables like DJANGO_SETTINGS_MODULE ) properly in the uwsgi file so that the server will work? Below is the .ini file I have.

    TIA

    uwsgi.ini

    [uwsgi] 
    --http 923b235d270e:8888 
    chdir=/code/backendworkproj 
    module=backendworkproj.wsgi:application 
    --env DJANGO_SETTINGS_MODULE=backendworkproj.settings 
    master=True 
    pidfile=/tmp/backendworkproj-master.pid 
    socket=127.0.0.1:49152 
    processes=5 
    uid=1000 
    gid=2000 
    harakiri=20 
    max-requests=5000 
    vacuum=True
    

    #245033

    Cloudy Point
    Keymaster

    Accepted AnswerAnswer

    Never mind. This configuration worked.

    [uwsgi]
    http-socket = :8888
    chdir = /code/backendworkproj
    module = backendworkproj.wsgi:application
    env = DJANGO_SETTINGS_MODULE=backendworkproj.settings
    master = True
    pidfile = /tmp/backendworkproj-master.pid
    socket = 127.0.0.1:49152
    processes = 5
    uid = 1000
    gid = 2000
    harakiri = 20
    max-requests = 5000
    vacuum = True
    

    Source: https://stackoverflow.com/questions/47953956/configuring-a-uwsgi-ini-file-so-that-a-django-project-will-work-within-a-docker
    Author: Casey Harrils
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.