Skip to content

Instantly share code, notes, and snippets.

@dolfelt
Last active September 28, 2016 02:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dolfelt/3fafa3cd89d5bd30c3c3 to your computer and use it in GitHub Desktop.
Save dolfelt/3fafa3cd89d5bd30c3c3 to your computer and use it in GitHub Desktop.
Code for deploying ember-cli applications with Gulp.js
Code for deploying ember-cli applications with Gulp.js
{
"key": "<AWS_KEY>",
"secret": "<AWS_SECRET>",
"bucket": "bucket-name",
"region": "us-east-1"
}
var app = new EmberApp({
fingerprint: {
prepend: 'https://s3.amazonaws.com/<bucket-name>/'
}
});
var fs = require('fs');
var gulp = require('gulp');
var shell = require('gulp-shell');
var s3 = require('gulp-s3');
var gzip = require('gulp-gzip');
var sftp = require('gulp-sftp');
// Build the project using ember-cli
gulp.task('build', shell.task([
'ember build --environment production'
]));
// Deploy all the assets to Amazon S3
gulp.task('deploy:assets', function() {
var aws = JSON.parse(fs.readFileSync('./aws.json'));
var options = { headers: {'Cache-Control': 'max-age=315360000, no-transform, public'} }
return gulp.src('./dist/**')
.pipe(gzip())
.pipe(s3(aws, options));
});
// Deploy the index.html file to a server of your choice
gulp.task('deploy:index', function() {
return gulp.src('./dist/index.html')
.pipe(sftp({
host: 'example.com',
user: 'deploy',
password: '<deploy-password>',
remotePath: '/var/www/example.com/'
}));
});
// Combine all these tasks into the deploy task
gulp.task('deploy', ['build', 'deploy:assets', 'deploy:index']);
// Default task will only build ember-cli
gulp.task('default', ['build']);
server {
listen 80;
server_name example.com;
root /var/www/example.com/;
location / {
index index.html;
try_files $uri $uri/ /index.html?/$request_uri;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment