diff --git a/.gitignore b/.gitignore index e4a101aa37..7d77255ab5 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ venv/ idea_town/frontend/static/ idea_town/frontend/static-src/vendor/ idea_town/frontend/static-src/styles/vendor/ +docker-compose-s3.yml diff --git a/README.md b/README.md index 36d60b100a..e81343bd53 100644 --- a/README.md +++ b/README.md @@ -89,11 +89,20 @@ Idea Town is not intended to replace trains for most features, nor is it a test `docker exec -t -i ideatown_client_build_1 touch gulpfile.js` * Want to run Python linting and Django tests on file changes? Try this: - ``` + ```bash sudo gem install kicker - kicker -c -e'docker exec -t -i ideatown_server_1 flake8 ./idea_town && \ - docker exec -t -i ideatown_server_1 ./manage.py test -v2' ./idea_town` + kicker -c -e'docker exec -t -i ideatown_server_1 flake8 ./idea_town && docker exec -t -i ideatown_server_1 ./manage.py test -v2' ./idea_town` + ``` + +* You can customize settings for special development cases. For example, to + switch to using S3 for media uploads: + ```bash + cp docker-compose-s3.yml-dist docker-compose-s3.yml + # Edit docker-compose-s3.yml to include your AWS credentials + docker-compose -f docker-compose-s3.yml build + docker-compose -f docker-compose-s3.yml up ``` + Testing ------------- diff --git a/docker-compose-base.yml b/docker-compose-base.yml new file mode 100644 index 0000000000..868eefa83d --- /dev/null +++ b/docker-compose-base.yml @@ -0,0 +1,30 @@ +client_build: + build: . + dockerfile: Dockerfile-client_build + ports: + - "9988:9988" + volumes: + - .:/app + environment: + - NODE_ENV=development + command: + ./bin/run-client-build.sh +server: + build: . + dockerfile: Dockerfile-server + ports: + - "8000:8000" + volumes: + - .:/app + command: + ./bin/run-dev.sh + environment: + - PYTHONUNBUFFERED=1 + - PYTHONDONTWRITEBYTECODE=1 + - DATABASE_URL=postgres://postgres@db/postgres + - DEBUG=True + - ALLOWED_HOSTS=localhost,127.0.0.1, + - SECRET_KEY=59114b6a-2858-4caf-8878-482a24ee9542 + - FXA_ACCESS_TOKEN_URL=https://oauth-stable.dev.lcip.org/v1/token + - FXA_AUTHORIZE_URL=https://oauth-stable.dev.lcip.org/v1/authorization + - FXA_PROFILE_URL=https://stable.dev.lcip.org/profile/v1/profile diff --git a/docker-compose-s3.yml-dist b/docker-compose-s3.yml-dist new file mode 100644 index 0000000000..df6cdb1584 --- /dev/null +++ b/docker-compose-s3.yml-dist @@ -0,0 +1,18 @@ +db: + image: postgres:9.3 +client_build: + extends: + file: docker-compose-base.yml + service: client_build +server: + extends: + file: docker-compose-base.yml + service: server + links: + - db + environment: + - DEFAULT_FILE_STORAGE=storages.backends.s3boto.S3BotoStorage + - AWS_ACCESS_KEY_ID={your access key id goes here} + - AWS_SECRET_ACCESS_KEY={your secret access key goes here} + - AWS_STORAGE_BUCKET_NAME={your bucket name here} + - MEDIA_URL=http://{your bucket name here}.s3.amazonaws.com/ diff --git a/docker-compose.yml b/docker-compose.yml index 2227ce90e7..4f2a85994e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,36 +1,13 @@ db: image: postgres:9.3 client_build: - build: . - dockerfile: Dockerfile-client_build - ports: - - "9988:9988" - volumes: - - .:/app - environment: - - NODE_ENV=development - command: - ./bin/run-client-build.sh + extends: + file: docker-compose-base.yml + service: client_build server: - build: . - dockerfile: Dockerfile-server - ports: - - "8000:8000" - volumes: - - .:/app + extends: + file: docker-compose-base.yml + service: server links: - db - client_build - environment: - - PYTHONUNBUFFERED=1 - - PYTHONDONTWRITEBYTECODE=1 - - DATABASE_URL=postgres://postgres@db/postgres - - DEBUG=True - - ALLOWED_HOSTS=localhost,127.0.0.1, - - SECRET_KEY=59114b6a-2858-4caf-8878-482a24ee9542 - - ADDON_URL=https://github.com/mozilla/idea-town-addon/blob/master/dist/idea-town-addon-0.0.1.xpi?raw=true - - FXA_ACCESS_TOKEN_URL=https://oauth-stable.dev.lcip.org/v1/token - - FXA_AUTHORIZE_URL=https://oauth-stable.dev.lcip.org/v1/authorization - - FXA_PROFILE_URL=https://stable.dev.lcip.org/profile/v1/profile - command: - ./bin/run-dev.sh diff --git a/idea_town/settings.py b/idea_town/settings.py index d1177e2348..7c2a859513 100644 --- a/idea_town/settings.py +++ b/idea_town/settings.py @@ -48,6 +48,7 @@ 'django_cleanup', 'rest_framework', + 'storages', # FxA auth handling 'allauth', @@ -159,6 +160,14 @@ MEDIA_ROOT = config('MEDIA_ROOT', default=os.path.join(BASE_DIR, 'media')) MEDIA_URL = config('MEDIA_URL', '/media/') +DEFAULT_FILE_STORAGE = config( + 'DEFAULT_FILE_STORAGE', + default='django.core.files.storage.FileSystemStorage') + +AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID', default=None) +AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY', default=None) +AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME', default=None) + SESSION_COOKIE_SECURE = config('SESSION_COOKIE_SECURE', default=not DEBUG, cast=bool) FIVE_YEARS_IN_SECONDS = 60 * 60 * 24 * 365 * 5 diff --git a/requirements.txt b/requirements.txt index d7e3687d58..4327aeb56c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -149,3 +149,9 @@ datadog==0.9.0 # sha256: IX5Hl9o6mkqfvmci4NuYBwuEQ6iCEtes29JBp2aBQdk simplejson==3.8.0 + +# sha256: dYSYx38W4muLYa8m-NDbsRm3E_LY0WZoHsiSMR81IMQ +boto==2.38.0 + +# sha256: 3gT6WE26Z7tSel6olB0v9HEoXLD5d8hjRP8oJ8OZgeI +django-storages-redux==1.3