Speed up build/deployment by using symlinked image
This commit is contained in:
+10
-17
@@ -21,18 +21,7 @@ module.exports = (grunt)->
|
||||
{expand: true, cwd:'./data', src:'**/*.cg', dest:'./dist/data'}
|
||||
]
|
||||
|
||||
copy:
|
||||
data:
|
||||
files: [
|
||||
{expand:true, cwd:'./data', src:'**/*', dest:'./build/data'}
|
||||
]
|
||||
build_to_dist:
|
||||
files: [
|
||||
{expand:true, cwd:'./build', src:'**/*', dest:'./dist'}
|
||||
]
|
||||
|
||||
clean:
|
||||
build: ['./build']
|
||||
dist: ['./dist']
|
||||
|
||||
mochaTest:
|
||||
@@ -47,6 +36,13 @@ module.exports = (grunt)->
|
||||
verbose: true
|
||||
src: ['./test/**/*.test.coffee']
|
||||
|
||||
symlink:
|
||||
images:
|
||||
files: [
|
||||
{expand:true, cwd:'./data', src:'**/*.png', dest:'./dist/data'}
|
||||
]
|
||||
|
||||
|
||||
watch:
|
||||
data_files:
|
||||
files: ['./data/**/*.cg']
|
||||
@@ -54,23 +50,20 @@ module.exports = (grunt)->
|
||||
|
||||
# Compound Tasks ###################################################################################################
|
||||
|
||||
grunt.registerTask 'build', 'build the project to be run from a local server',
|
||||
['copy:data']
|
||||
|
||||
grunt.registerTask 'default', 'run tests to verify data files',
|
||||
['test']
|
||||
|
||||
grunt.registerTask 'dist', 'build the project to be run from Amazon S3',
|
||||
['build', 'copy:build_to_dist', 'compress']
|
||||
['clean', 'symlink:images', 'compress']
|
||||
|
||||
grunt.registerTask 'test', 'run unit tests',
|
||||
['mochaTest']
|
||||
|
||||
grunt.registerTask 'upload:prod', 'upload the project to the production Amazon S3 environment',
|
||||
['dist', 'script:s3_upload:prod']
|
||||
['script:s3_upload:prod']
|
||||
|
||||
grunt.registerTask 'upload:staging', 'upload the project the staging Amazon S3 environment',
|
||||
['dist', 'script:s3_upload:staging']
|
||||
['script:s3_upload:staging']
|
||||
|
||||
# Code Tasks #######################################################################################################
|
||||
|
||||
|
||||
@@ -6,5 +6,6 @@ deployment:
|
||||
all:
|
||||
branch: master
|
||||
commands:
|
||||
- grunt dist
|
||||
- grunt upload:prod
|
||||
- grunt upload:staging
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
"grunt-contrib-clean": "^1.0.0",
|
||||
"grunt-contrib-compress": "^1.2.0",
|
||||
"grunt-contrib-copy": "^1.0.0",
|
||||
"grunt-contrib-symlink": "^1.0.0",
|
||||
"grunt-contrib-watch": "^0.6.1",
|
||||
"grunt-mocha-test": "^0.12.7",
|
||||
"mocha": "^2.2.4",
|
||||
|
||||
+9
-4
@@ -1,5 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
function die {
|
||||
echo $*
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ -e "./aws.config" ]]; then
|
||||
export AWS_CONFIG_FILE="./aws.config"
|
||||
else
|
||||
@@ -10,15 +15,15 @@ ENVIRONMENT=""
|
||||
while [[ "$1" != "" ]]; do
|
||||
case "$1" in
|
||||
"--staging") ENVIRONMENT="staging";;
|
||||
"--production") ENVIRONMENT="production";;
|
||||
*) die "Please specify environment: --staging or --production";;
|
||||
"--prod") ENVIRONMENT="prod";;
|
||||
*) die "Please specify environment: --staging or --prod";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
SOURCE_DIR="./dist/"
|
||||
SITE="staging.crafting-guide.com"
|
||||
[[ "$ENVIRONMENT" == "production" ]] && SITE="crafting-guide.com"
|
||||
[[ "$ENVIRONMENT" == "prod" ]] && SITE="crafting-guide.com"
|
||||
TARGET_DIR="s3://$SITE/"
|
||||
|
||||
S3CMD_CFG="$HOME/.s3cfg"
|
||||
@@ -28,7 +33,7 @@ cat $AWS_CONFIG_FILE | grep "aws_secret_access_key" | sed "s/aws_secret_access_k
|
||||
|
||||
HEADERS="--add-header=cache-control:max-age=1800"
|
||||
GZIP="--add-header=content-encoding:gzip"
|
||||
CMD="sync $SOURCE_DIR $TARGET_DIR -r -P $HEADERS --stop-on-error --exclude=*"
|
||||
CMD="sync $SOURCE_DIR $TARGET_DIR -r -F -P $HEADERS --stop-on-error --exclude=*"
|
||||
|
||||
echo "Preparing to upload to S3..."
|
||||
s3cmd $CMD -m 'image/png' --include="*.png" || exit 1
|
||||
|
||||
Reference in New Issue
Block a user