• Members 1 post
    Jan. 8, 2019, 8:15 p.m.

    Ok. I starting learning Django six months ago and I really really loved it.
    I learnt how to deploy the django projects to EC2 instances.
    Basically 1st time when the django project is deployed to EC2, the instance will be configured with httpd.conf, wsgi, change permissions on files and folders and other stuff and the project will be cloned to the EC2 instance and server is restarted.
    My question is how do they do future deployments? They in this context is anyone who deploys Django on EC2 instances.
    Do they login to EC2 instances and manually clone the repository from VCS site and restart the server?
    Does they have any other automated mechanism to pull the code and restarting the apache server etc.
    How is it done basically every time they go for a release?

    Someone please help me understand this.

  • Jan. 8, 2019, 8:39 p.m.

    Hey,

    There's no single way to deploy Django (or any software) to EC2, and as such there is no single answer to this question ;)

    One way to do it would be to ssh to the instance, pull current code from VCS and run update script that will only update things that need updating. For example update script could only run database update. Django already implements mechanism for versioning and updating database structure and contents between software versions.

    Other way is to keep your database and user-created files on different services (RDS and S3), and simply create new EC2 instance running new code but using database and files from same RDS and S3 previous instance used. If new instance fails to initialize, you can wake up previous instance.

    Or you can isolate your app in Docker or other containerization technology and replace old containers with new ones, while application's data is kept outside of containers and shared between them.

    Checking if database/file/data existings before attempting to create it is simple and solved problem ;)