From 754cb568fb9bb6672624ef67abfb6e702e2e42df Mon Sep 17 00:00:00 2001 From: Kai Hendry Date: Thu, 7 Mar 2019 13:58:10 +0800 Subject: [PATCH 1/2] Cache node_modules to make build faster --- buildspec.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/buildspec.yml b/buildspec.yml index 9bf5b691..184c4686 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -27,3 +27,8 @@ phases: commands: - docker push ${ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/${APP}:$CODEBUILD_RESOLVED_SOURCE_VERSION - docker push ${ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/${APP}:latest + +# https://aws.amazon.com/blogs/devops/improve-build-performance-and-save-time-using-local-caching-in-aws-codebuild/ +cache: + paths: + - 'node_modules/**/*' \ No newline at end of file From 427719b3e72306bd77fd0978c709d28f97e195ce Mon Sep 17 00:00:00 2001 From: Kai Hendry Date: Thu, 7 Mar 2019 15:22:32 +0800 Subject: [PATCH 2/2] Defer to multistage Dockerfile --- buildspec.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 184c4686..4287f8cd 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -9,26 +9,14 @@ phases: pre_build: commands: - $(aws ecr get-login --no-include-email --region ${AWS_REGION}) - install: - commands: - - echo Installing Meteor - - curl https://install.meteor.com/ | sh build: commands: - - meteor npm install - - 'sed -i "s,<\!-- COMMIT: -->,<\!-- COMMIT: $CODEBUILD_SOURCE_VERSION $CODEBUILD_RESOLVED_SOURCE_VERSION -->,g" client/main.html' - - meteor build --directory /tmp/export-meteor/build --allow-superuser - - printf "FROM ulexus/meteor:build\nCOPY build /home/meteor/www\nRUN chown -R meteor:meteor /home/meteor/\n" >/tmp/export-meteor/Dockerfile - - cd /tmp/export-meteor - docker build -t ${APP} -t ${APP}:$CODEBUILD_RESOLVED_SOURCE_VERSION . - - docker tag ${APP}:$CODEBUILD_RESOLVED_SOURCE_VERSION ${ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/${APP}:$CODEBUILD_RESOLVED_SOURCE_VERSION - - docker tag ${APP}:latest ${ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/${APP}:latest + - docker tag ${APP}:$CODEBUILD_RESOLVED_SOURCE_VERSION + ${ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/${APP}:$CODEBUILD_RESOLVED_SOURCE_VERSION + - docker tag ${APP}:latest + ${ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/${APP}:latest post_build: commands: - docker push ${ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/${APP}:$CODEBUILD_RESOLVED_SOURCE_VERSION - docker push ${ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/${APP}:latest - -# https://aws.amazon.com/blogs/devops/improve-build-performance-and-save-time-using-local-caching-in-aws-codebuild/ -cache: - paths: - - 'node_modules/**/*' \ No newline at end of file