1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-22 01:36:55 +01:00

deployment task & documentation for #3

This commit is contained in:
Matthias Kretschmann 2016-01-08 12:00:57 +01:00
parent 2106cf884b
commit 470ddae641
3 changed files with 88 additions and 3 deletions

View File

@ -30,10 +30,37 @@ gulp
## Deployment
### Production build
The site is hosted in an S3 bucket and gets deployed via a gulp task.
The following builds the site and runs a bunch of optimizations over everything, like assets optimizations, revisioning, CDN url injection etc.
### Prerequisite: Authentication
To deploy the site, you must authenticate yourself against the AWS API with your AWS credentials. Get your AWS access key and secret and add them to `~/.aws/credentials`:
```
[default]
aws_access_key_id = <YOUR_ACCESS_KEY_ID>
aws_secret_access_key = <YOUR_SECRET_ACCESS_KEY>
```
This is all that is needed to authenticate with AWS if you've setup your credentials as the default profile.
If you've set them up as another profile, say `[bigchain]` you can grab those credentials by using the `AWS_PROFILE` variable like so:
```bash
gulp build --production
AWS_PROFILE=bigchain gulp deploy:live
```
In case that you get authentication errors or need an alternative way to authenticate with AWS, check out the [AWS documentation](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html).
### Production build & live deployment
```bash
# make sure your local npm packages & gems are up to date
npm update && bundle update
# make production build in /_dist
gulp build --production
# deploy contents of /_dist to live
gulp deploy:live
```

View File

@ -7,6 +7,7 @@ var $ = require('gulp-load-plugins')();
var gulp = require('gulp'),
del = require('del'),
pkg = require('./package.json'),
parallelize = require('concurrent-transform'),
browser = require('browser-sync');
// Temporary solution until gulp 4
@ -53,6 +54,12 @@ var COMPATIBILITY = ['Chrome >= 30', 'Safari >= 6.1', 'Firefox >= 35', 'Opera >=
var SRC = '_src/',
DIST = '_dist/';
// deployment
var S3BUCKET = 'www.bigchain.io',
S3REGION = 'eu-central-1',
S3BUCKET_BETA = 'beta.bigchain.io',
S3REGION_BETA = 'eu-central-1';
// SVG sprite
var SPRITECONFIG = {
dest: DIST + 'assets/img/',
@ -302,3 +309,51 @@ gulp.task('build', function(done) {
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Deployment
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gulp.task('deploy:live', function() {
// create publisher, define config
var publisher = $.awspublish.create({
params: {
'Bucket': S3BUCKET
},
'accessKeyId': process.env.AWS_ACCESS_KEY,
'secretAccessKey': process.env.AWS_SECRET_KEY,
'region': S3REGION
});
return gulp.src(DIST + '**/*')
.pipe($.awspublishRouter({
cache: {
// cache for 5 minutes by default
cacheTime: 300
},
routes: {
// all static assets, cached & gzipped
'^assets/(?:.+)\\.(?:js|css|png|jpg|jpeg|gif|ico|svg|ttf)$': {
cacheTime: 2592000, // cache for 1 month
gzip: true
},
// every other asset, cached
'^assets/.+$': {
cacheTime: 2592000 // cache for 1 month
},
// all html files, not cached & gzipped
'^.+\\.html': {
cacheTime: 0,
gzip: true
},
// pass-through for anything that wasn't matched by routes above, to be uploaded with default options
"^.+$": "$&"
}
}))
.pipe(parallelize(publisher.publish(), 10))
.pipe(publisher.sync()) // delete files in bucket that are not in local folder
.pipe(publisher.cache())
.pipe($.awspublish.reporter({
states: ['create', 'update', 'delete']
}));
});

View File

@ -23,9 +23,12 @@
},
"devDependencies": {
"browser-sync": ">=2.10.0",
"concurrent-transform": "^1.0.0",
"del": "^2.0.2",
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.0.1",
"gulp-awspublish": "^3.0.0",
"gulp-awspublish-router": "^0.1.1",
"gulp-concat": "^2.6.0",
"gulp-cssmin": "^0.1.7",
"gulp-header": "^1.7.1",