Skip to content
This repository has been archived by the owner on May 14, 2023. It is now read-only.

Commit

Permalink
Add zappa deploy to travis
Browse files Browse the repository at this point in the history
- Using path mode for s3 url
  • Loading branch information
thenav56 committed Jul 7, 2020
1 parent a105459 commit a753ce4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
28 changes: 16 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,30 @@ script:
after_success:
- docker-compose push
# TODO: IF and migrate
- docker pull $ZAPPA_IMG || true
- docker build -t $ZAPPA_IMG --cache-from $ZAPPA_IMG -f ./server/zappa.dockerfile ./server/
- |
docker run --rm \
-e AWS_ACCESS_KEY_ID=$ZAPPA_AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$ZAPPA_AWS_SECRET_ACCESS_KEY \
-e AWS_DEFAULT_REGION=$ZAPPA_AWS_DEFAULT_REGION \
$ZAPPA_IMG \
bash -c 'source /venv/bin/activate && zappa update prod'
if [[ "$TRAVIS_BRANCH" = "release" ]] ; then
docker pull $ZAPPA_IMG || true
docker build -t $ZAPPA_IMG --cache-from $ZAPPA_IMG -f ./server/zappa.dockerfile ./server/
docker run --rm \
-e AWS_ACCESS_KEY_ID=$ZAPPA_AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$ZAPPA_AWS_SECRET_ACCESS_KEY \
-e AWS_DEFAULT_REGION=$ZAPPA_AWS_DEFAULT_REGION \
-v `pwd`/server/=/code/ \
$ZAPPA_IMG \
bash -c 'source /venv/bin/activate && cd /code/ && zappa update prod && zappa manage prod migrate'
docker push $ZAPPA_IMG
fi

deploy:
provider: s3
access_key_id: $S3_AWS_ACCESS_KEY_ID
secret_access_key: $S3_AWS_SECRET_ACCESS_KEY
access_key_id: $ZAPPA_AWS_ACCESS_KEY_ID
secret_access_key: $ZAPPA_AWS_SECRET_ACCESS_KEY
bucket: $TOGGLECORP_S3_BUCKET
skip_cleanup: true
local_dir: ./client/build
acl: public_read
region: $DEPLOYMENT_REGION
region: $ZAPPA_AWS_DEFAULT_REGION
edge: true # opt in to dpl v2
on:
branch: release

Expand Down
8 changes: 8 additions & 0 deletions server/togglecorp/s3_storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ class StaticStorage(S3Boto3Storage):
bucket_name = settings.AWS_STORAGE_BUCKET_NAME_STATIC
querystring_auth = False

# Don't use token provided by AWS environment (use custom defiend tokens)
def _get_security_token(self):
return None


class MediaStorage(S3Boto3Storage):
location = settings.MEDIAFILES_LOCATION
bucket_name = settings.AWS_STORAGE_BUCKET_NAME_MEDIA

# Don't use token provided by AWS environment (use custom defiend tokens)
def _get_security_token(self):
return None
1 change: 1 addition & 0 deletions server/togglecorp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
AWS_SECRET_ACCESS_KEY = os.environ['S3_AWS_SECRET_ACCESS_KEY']
AWS_S3_REGION_NAME = os.environ['S3_AWS_REGION_NAME']

AWS_S3_ADDRESSING_STYLE = 'path'
AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = 'private'
AWS_QUERYSTRING_AUTH = False
Expand Down
1 change: 1 addition & 0 deletions server/zappa_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"s3_bucket": "zappa-togglecorp",
"certificate_arn": "arn:aws:acm:us-east-1:182509255933:certificate/64de3375-63d6-4118-89e0-f1b08fab91b8",
"domain": "api.togglecorp.com",
"keep_warm": false,
"vpc_config" : {
"SubnetIds": ["subnet-930078d9", "subnet-5f9b3038"],
"SecurityGroupIds": [ "sg-00085d77439843e85" ]
Expand Down

0 comments on commit a753ce4

Please sign in to comment.