First pass at Elastic Beanstalk integration

This commit is contained in:
Daniel Roy Greenfeld 2016-09-21 15:58:54 -07:00
parent a950eb82f6
commit 9d30f24888
5 changed files with 51 additions and 2 deletions

View File

@ -21,5 +21,6 @@
"postgresql_version": ["9.5", "9.4", "9.3", "9.2"], "postgresql_version": ["9.5", "9.4", "9.3", "9.2"],
"js_task_runner": ["Gulp", "Grunt", "None"], "js_task_runner": ["Gulp", "Grunt", "None"],
"use_lets_encrypt": "n", "use_lets_encrypt": "n",
"open_source_license": ["MIT", "BSD", "GPLv3", "Apache Software License 2.0", "Not open source"] "open_source_license": ["MIT", "BSD", "GPLv3", "Apache Software License 2.0", "Not open source"],
"use_elasticbeanstalk": "y"
} }

View File

@ -0,0 +1,5 @@
packages:
yum:
git: []
postgresql94-devel: []
libjpeg-turbo-devel: []

View File

@ -0,0 +1,13 @@
container_commands:
01_migrate:
command: "source /opt/python/run/venv/bin/activate && python manage.py migrate"
leader_only: True
02_collectstatic:
command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput"
option_settings:
"aws:elasticbeanstalk:container:python":
WSGIPath: "config/wsgi.py"
NumProcesses: 3
NumThreads: 20
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "www/static/"

View File

@ -0,0 +1,29 @@
"""Converts a .env file to Elastic Beanstalk environment variables"""
from sys import exit
from subprocess import check_call
try:
import dotenv
except ImportError:
print("Please install the 'dotenv' library: 'pip install dotenv'")
exit()
def main():
command = ['eb', 'setenv']
failures = []
for key, value in dotenv.Dotenv('.env').items():
if value:
command.append("{}={}".format(key, value))
else:
failures.append(key)
if failures:
for failure in failures:
print("{} requires a value".format(failure))
else:
print(' '.join(command))
check_call(command)
if __name__ == '__main__':
main()

View File

@ -1,3 +1,4 @@
# PostgreSQL # PostgreSQL
POSTGRES_PASSWORD=mysecretpass POSTGRES_PASSWORD=mysecretpass
POSTGRES_USER=postgresuser POSTGRES_USER=postgresuser
@ -33,4 +34,4 @@ DJANGO_OPBEAT_SECRET_TOKEN
{% endif %} {% endif %}
{% if cookiecutter.use_compressor == 'y' -%} {% if cookiecutter.use_compressor == 'y' -%}
COMPRESS_ENABLED= COMPRESS_ENABLED=
{% endif %} {% endif %}