2
votes

I am trying to deploy a django app to elastic beanstalk. I am deploying using amazon's preconfigured Python 3.4 docker container and the new Awsebcli v3 command line tools. When I run eb deploy I get the message ERROR: Timed out while waiting for command to Complete, but I can't see any signs of errors being encountered when I run eb logs. When I navigate to the CNAME provided for the environment it just says Internal Server Error

In the example Amazon gives for deploying to EB using docker preconfigured python containers they use a flask application and run the application with a file called application.py... I don't have such an application.py file, which I think may be causing the issue. What would I put in the application.py file to run my django app, with any commands necessary for the application (collectstatic, syncdb if DB needs syncing, else makemigrations and migrate, etc)

I'm using Django 1.7 and Python 3.4

Thank you

1

1 Answers

2
votes

Do you have your container(s) successfully running locally? If not, I would do that before you try to deploy to Elastic Beanstalk. I'm also in the middle of this process, and not finding it particularly easy! I have, however, got past the problem you mention.

My application.py file looks like this:

import os
import sys

sys.path.insert(0, '/var/app')

os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Where I then have:

/var/app
    |
    | project/
        settings.py
    | myapp/
        views/
        templates/
        ...

This then leaves me with an application that's working, but not serving my static files unless I run in development mode. I think this means that the container'ed Apache (or is it Nginx) instance isn't serving my /var/app/static directory, but I've not figured that out yet.

As for collectstatic and syncdb - thus far, I'm just running those manually. I was thinking that they could be added to the Dockerfile as CMD entries, but Docker will only execute the last of those entries, so it won't work.

The other question I have is whether it's going to be possible to run two containers on Beanstalk (I have Postgres in one, Django in another). I'm not sure if eb deploy can cope with this or not.