Skip to content

Instantly share code, notes, and snippets.

@ferociouself
Last active February 8, 2018 22:32
Show Gist options
  • Save ferociouself/900ffa1ca22561d7351644bd5823aafd to your computer and use it in GitHub Desktop.
Save ferociouself/900ffa1ca22561d7351644bd5823aafd to your computer and use it in GitHub Desktop.
Scripts that allow CodeDeploy to deploy Django code. Replace "project" with your project name, and "app_name" with the name of your app.
#!/usr/bin/env bash
rm -rf /var/www/html/*
rm -rf /home/ec2-user/www/*
rm -rf /home/ec2-user/installation
#!/usr/bin/env bash
yum install -y python34
yum install -y python-psycopg2 postgresql libncurses5-dev libffi libffi-devel libxml2-devel libxslt-devel libxslt1-dev
yum install -y postgresql-libs postgresql-devel python-lxml python-devel gcc patch python-setuptools
#!/usr/bin/env bash
source /home/ec2-user/www/venv/bin/activate
/home/ec2-user/www/venv/bin/pip3 install -r /var/www/html/requirements.txt
/home/ec2-user/www/venv/bin/pip3 install psycopg2
#!/usr/bin/env bash
python3 -m venv /home/ec2-user/www/venv --without-pip
source /home/ec2-user/www/venv/bin/activate
mkdir /home/ec2-user/installation/
cd /home/ec2-user/installation/
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
#!/usr/bin/env bash
cd /var/www/html/project/
source /home/ec2-user/www/venv/bin/activate
python3 ./manage.py makemigrations
python3 ./manage.py makemigrations app_name
python3 ./manage.py migrate
python3 ./manage.py migrate app_name
#!/usr/bin/env bash
cd /var/www/html/project/
source /home/ec2-user/www/venv/bin/activate
python3 ./manage.py collectstatic --noinput --clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment