Code Monkey home page Code Monkey logo

django-tutorial-docker-nginx-postgres's People

Contributors

andrecp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-tutorial-docker-nginx-postgres's Issues

Unable to run project

Hi, n00b here. I just followed the tutorial but failed to run the project. Please can you help?

$ sh rebuild_docker.sh
postgres uses an image, skipping
Building django...
Step 0 : FROM python:2.7-onbuild
# Executing 3 build triggers
Trigger 0, COPY requirements.txt /usr/src/app/
Step 0 : COPY requirements.txt /usr/src/app/
 ---> Using cache
Trigger 1, RUN pip install --no-cache-dir -r requirements.txt
Step 0 : RUN pip install --no-cache-dir -r requirements.txt
 ---> Using cache
Trigger 2, COPY . /usr/src/app
Step 0 : COPY . /usr/src/app
 ---> Using cache
 ---> 69e2dca77370
Step 1 : ENV DJANGO_CONFIGURATION Docker
 ---> Using cache
 ---> 270fbc19c045
Step 2 : CMD gunicorn -c gunicorn_conf.py --chdir mysite mysite.wsgi:application --reload
 ---> Using cache
 ---> 625f575074fe
Successfully built 625f575074fe
Building nginx...
Step 0 : FROM nginx
 ---> 6886fb5a9b8d
Step 1 : MAINTAINER Andre Prado
 ---> Using cache
 ---> 4fe6f1f20017
Step 2 : COPY nginx.conf /etc/nginx/nginx.conf
 ---> Using cache
 ---> 2173090fed54
Successfully built 2173090fed54
Recreating djangotutorialdockernginxpostgres_postgres_1...
Recreating djangotutorialdockernginxpostgres_django_1...
Recreating djangotutorialdockernginxpostgres_nginx_1...
      Name             Command             State              Ports       
-------------------------------------------------------------------------
djangotutorialdo   gunicorn -c        Exit 1                              
ckernginxpostgre   gunicorn_conf.                                         
s_django_1         ...                                                    
djangotutorialdo   nginx -g daemon    Up                 443/tcp, 0.0.0.0 
ckernginxpostgre   off;                                  :80->80/tcp      
s_nginx_1                                                                 
djangotutorialdo   /docker-           Up                 5432/tcp         
ckernginxpostgre   entrypoint.sh                                          
s_postgres_1       postgres

$ docker-compose run django /bin/sh -c 'cd mysite;python manage.py migrate'
/bin/sh: 1: cd: can't cd to mysite
python: can't open file 'manage.py': [Errno 2] No such file or directory

what tutorial were you following?

Hello,

Nice repo. Thanks for sharing. I want to learn docker in the context of django too. So I was curious. Did you follow the basic django tutorial or a more specific "django + docker" tutorial? It would be nice if you could add the link in the README.

Thanks,

Loic

Staticfiles are not loaded

Hey,

So I modified this project to work with my own Django app. I got it to work, except for the static files. All the requests end in a 403 error. Your project worked out of the box (including the static files) so it's probably my configuration that messed it up.

This is my folder structure:
djangostack
│ docker-compose.yml
│ Dockerfile
│ gunicorn_conf.py
│ README.md
│ rebuild_docker.sh
│ requirements.txt

└───nginx
│ │ Dockerfile
│ │ nginx.conf
│ │
└───vms
│ manage.py

├───static (This is where the staticfiles are collected)
│ └───admin
│ └───website

└───vms
│ │ init.py
│ │ settings.py
│ │ urls.py
│ │ wsgi.py

└───website
│ └───static
│ │ └───website
│ │ │ └───css
│ │ │ └───img
│ │ │ └───js
│ │
│ └───templates
│ │ └───website
│ │
│ │ admin.py
│ │ forms.py
│ │ init.py
│ │ models.py
│ │ tests.py
│ │ views.py

This is my nginx.conf:

worker_processes 1;

events {

    worker_connections 1024;

}

http {

    server {
        listen 80;
        server_name example.org;

        access_log /dev/stdout;
        error_log /dev/stdout info;

        location /static {
            alias /usr/src/app/vms/static;
        }

        location / {
            proxy_pass http://django:8000;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
        }
    }
}

This is the static files section in my settings.py:
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'

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

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.