hi-ogawa / wordCollector

https://chrome.google.com/webstore/detail/word-collector/jfeinpeakgoblpcelmhdhajmdoeoifap
0 stars 0 forks source link

put angular assets on S3 #59

Closed hi-ogawa closed 9 years ago

hi-ogawa commented 9 years ago
hi-ogawa commented 9 years ago

bucket security policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::word-collector.xyz/*"
            ]
        }
    ]
}
hi-ogawa commented 9 years ago

these could be useful.

hi-ogawa commented 9 years ago

it turns out putting cors configuration on rails is not enough on production

hi-ogawa commented 9 years ago

https://github.com/hi-ogawa/wordCollector/compare/ad5e64b1f14309ebd5234b227c53e9fc5420caa5...9101bd14e38a02840ecaae4e5a45aab9f8f281f6

hi-ogawa commented 9 years ago

on production, it seems headers setting for CORS must be same in nginx config https://github.com/hi-ogawa/wordCollector/compare/ad5e64b1f14309ebd5234b227c53e9fc5420caa5...9101bd14e38a02840ecaae4e5a45aab9f8f281f6#diff-40966e418411980a49913f0054bb041eR196 and in rails config https://github.com/hi-ogawa/wordCollector/compare/ad5e64b1f14309ebd5234b227c53e9fc5420caa5...9101bd14e38a02840ecaae4e5a45aab9f8f281f6#diff-8946e605a710e650eb51f58efe58b829R13

hi-ogawa commented 9 years ago
$ # launch new ec2 instance (from my custom ruby image)
$ ssh aws
$ git clone https://github.com/hi-ogawa/wordCollector.git
$ cd wordCollector/railsAPI
$ bundle install
$ echo "SECRET_KEY_BASE=$(rake secret)" >> ~/.rbenv/vars
$ cat >> ~/.rbenv/vars
AWS_ACCESS_KEY_ID=...                 # see `~/.aws/credentials` on local
AWS_SECRET_ACCESS_KEY=...
RAILS_ENV=production
$ (rake db:migrate) # in case need schema update on db
$ nohup rbenv sudo passenger start -p80 --nginx-config-template config/nginx.conf.erb &> /dev/null &
$ ssh aws
$ cd wordCollector/railsAPI
$ git pull
$ rbenv sudo passenger-config list-instances   # check the name of a passenger instance
$ rbenv sudo passenger-config restart-app . --instance <name>