Speed up build/deployment by using symlinked image

This commit is contained in:
Andrew Miner
2016-04-04 20:07:34 -07:00
parent 046c0eb204
commit 0b273b4d9d
4 changed files with 21 additions and 21 deletions
+10 -17
View File
@@ -21,18 +21,7 @@ module.exports = (grunt)->
{expand: true, cwd:'./data', src:'**/*.cg', dest:'./dist/data'} {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: clean:
build: ['./build']
dist: ['./dist'] dist: ['./dist']
mochaTest: mochaTest:
@@ -47,6 +36,13 @@ module.exports = (grunt)->
verbose: true verbose: true
src: ['./test/**/*.test.coffee'] src: ['./test/**/*.test.coffee']
symlink:
images:
files: [
{expand:true, cwd:'./data', src:'**/*.png', dest:'./dist/data'}
]
watch: watch:
data_files: data_files:
files: ['./data/**/*.cg'] files: ['./data/**/*.cg']
@@ -54,23 +50,20 @@ module.exports = (grunt)->
# Compound Tasks ################################################################################################### # 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', grunt.registerTask 'default', 'run tests to verify data files',
['test'] ['test']
grunt.registerTask 'dist', 'build the project to be run from Amazon S3', 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', grunt.registerTask 'test', 'run unit tests',
['mochaTest'] ['mochaTest']
grunt.registerTask 'upload:prod', 'upload the project to the production Amazon S3 environment', 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', grunt.registerTask 'upload:staging', 'upload the project the staging Amazon S3 environment',
['dist', 'script:s3_upload:staging'] ['script:s3_upload:staging']
# Code Tasks ####################################################################################################### # Code Tasks #######################################################################################################
+1
View File
@@ -6,5 +6,6 @@ deployment:
all: all:
branch: master branch: master
commands: commands:
- grunt dist
- grunt upload:prod - grunt upload:prod
- grunt upload:staging - grunt upload:staging
+1
View File
@@ -34,6 +34,7 @@
"grunt-contrib-clean": "^1.0.0", "grunt-contrib-clean": "^1.0.0",
"grunt-contrib-compress": "^1.2.0", "grunt-contrib-compress": "^1.2.0",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
"grunt-contrib-symlink": "^1.0.0",
"grunt-contrib-watch": "^0.6.1", "grunt-contrib-watch": "^0.6.1",
"grunt-mocha-test": "^0.12.7", "grunt-mocha-test": "^0.12.7",
"mocha": "^2.2.4", "mocha": "^2.2.4",
+9 -4
View File
@@ -1,5 +1,10 @@
#!/bin/bash #!/bin/bash
function die {
echo $*
exit 1
}
if [[ -e "./aws.config" ]]; then if [[ -e "./aws.config" ]]; then
export AWS_CONFIG_FILE="./aws.config" export AWS_CONFIG_FILE="./aws.config"
else else
@@ -10,15 +15,15 @@ ENVIRONMENT=""
while [[ "$1" != "" ]]; do while [[ "$1" != "" ]]; do
case "$1" in case "$1" in
"--staging") ENVIRONMENT="staging";; "--staging") ENVIRONMENT="staging";;
"--production") ENVIRONMENT="production";; "--prod") ENVIRONMENT="prod";;
*) die "Please specify environment: --staging or --production";; *) die "Please specify environment: --staging or --prod";;
esac esac
shift shift
done done
SOURCE_DIR="./dist/" SOURCE_DIR="./dist/"
SITE="staging.crafting-guide.com" SITE="staging.crafting-guide.com"
[[ "$ENVIRONMENT" == "production" ]] && SITE="crafting-guide.com" [[ "$ENVIRONMENT" == "prod" ]] && SITE="crafting-guide.com"
TARGET_DIR="s3://$SITE/" TARGET_DIR="s3://$SITE/"
S3CMD_CFG="$HOME/.s3cfg" 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" HEADERS="--add-header=cache-control:max-age=1800"
GZIP="--add-header=content-encoding:gzip" 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..." echo "Preparing to upload to S3..."
s3cmd $CMD -m 'image/png' --include="*.png" || exit 1 s3cmd $CMD -m 'image/png' --include="*.png" || exit 1