-
Notifications
You must be signed in to change notification settings - Fork 678
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add production build setup and aws CICD config files
- Loading branch information
1 parent
ffe2734
commit 3853363
Showing
18 changed files
with
701 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env sh | ||
|
||
# used for script output | ||
message () { | ||
echo "" | ||
echo "===========================================================================" | ||
echo "" | ||
echo " " "$1" | ||
echo "" | ||
echo "===========================================================================" | ||
echo "" | ||
} | ||
STATUS=0 | ||
|
||
message "Installing dependencies with yarn..." | ||
yarn install --frozen-lockfile | ||
|
||
# production build - needed for some of the subsequent checks, like storybook | ||
message "Running production build..." | ||
cp ./docker/.env.docker.prod ./packages/venia-concept/.env | ||
yarn run build | ||
|
||
# jest tests - does not fail ci, failures are evaluated by danger check below | ||
message "Running unit tests with Jest..." | ||
yarn run test:ci | ||
|
||
message "Running Coveralls..." | ||
yarn run coveralls | ||
|
||
message "Running Storybook..." | ||
yarn workspace @magento/venia-concept run storybook:build | ||
|
||
message "Running Bundlesize..." | ||
yarn run bundlesize | ||
|
||
# danger ci - eslint, prettier:validate, unit test evaluation, etc. | ||
message "Running Danger..." | ||
yarn run danger || STATUS=$? | ||
|
||
echo "Exit Status: $STATUS" | ||
exit $STATUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# buildspec for deploying latest changes to main development branch | ||
version: 0.2 | ||
phases: | ||
install: | ||
commands: | ||
- echo install step... | ||
pre_build: | ||
commands: | ||
- echo logging in to AWS ECR... | ||
- $(aws ecr get-login --no-include-email --region us-east-1) | ||
build: | ||
commands: | ||
- echo build Docker image on `date` | ||
- docker build -f Dockerfile.prod -t pwa-demo:latest . | ||
- docker tag pwa-demo:latest 276375911640.dkr.ecr.us-east-1.amazonaws.com/pwa-demo | ||
post_build: | ||
commands: | ||
- echo build Docker image complete `date` | ||
- echo push latest Docker images to ECR... | ||
- docker push 276375911640.dkr.ecr.us-east-1.amazonaws.com/pwa-demo | ||
artifacts: | ||
files: | ||
- Dockerrun.aws.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version: 0.2 | ||
phases: | ||
pre_build: | ||
commands: | ||
# get the PR number from version env var, originally in the format "pr/2" | ||
- PR_ID_TAG=$(echo $CODEBUILD_SOURCE_VERSION | cut -d'/' -f 2) | ||
- echo getting PR ID... PR_ID_TAG = $PR_ID_TAG | ||
- echo logging in to AWS ECR... | ||
- $(aws ecr get-login --no-include-email --region us-east-1) | ||
build: | ||
commands: | ||
- echo build Docker image on `date` for github branch $CODEBUILD_SOURCE_VERSION | ||
- docker build -f Dockerfile.prod -t pwa-pr-build:$PR_ID_TAG . | ||
- docker tag pwa-pr-build:$PR_ID_TAG 276375911640.dkr.ecr.us-east-1.amazonaws.com/pwa-pr-build:$PR_ID_TAG | ||
post_build: | ||
commands: | ||
- echo build Docker image complete `date` for github branch $CODEBUILD_SOURCE_VERSION | ||
- echo push latest Docker images to ECR... | ||
- docker push 276375911640.dkr.ecr.us-east-1.amazonaws.com/pwa-pr-build:$PR_ID_TAG | ||
# change the Dockerrun.aws.json to use the pwa-pr-build registry address pointing at this pr image build | ||
- sed -i "s/pwa-demo:latest/pwa-pr-build:${PR_ID_TAG}/g" Dockerrun.aws.json | ||
artifacts: | ||
files: | ||
- Dockerrun.aws.json | ||
name: pr-$(echo $CODEBUILD_SOURCE_VERSION | cut -d'/' -f 2) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: 0.2 | ||
phases: | ||
install: | ||
commands: | ||
- echo entering install step... | ||
# for yarn | ||
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | ||
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | ||
- apt-get update -y | ||
- apt-get install -y yarn | ||
build: | ||
commands: | ||
- echo running pr-checks script `date` | ||
# contains all the pr check task scripts | ||
- yarn run ci:pr-checks | ||
post_build: | ||
commands: | ||
- echo pr test tasks complete `date` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM node:10.14.1-alpine as build | ||
# working directory | ||
WORKDIR /usr/src/app | ||
|
||
# global environment setup : yarn + dependencies needed to support node-gyp | ||
RUN apk --no-cache --virtual add \ | ||
python \ | ||
make \ | ||
g++ \ | ||
yarn | ||
|
||
# copy just the dependency files and configs needed for install | ||
COPY packages/peregrine/package.json ./packages/peregrine/package.json | ||
COPY packages/pwa-buildpack/package.json ./packages/pwa-buildpack/package.json | ||
COPY packages/upward-js/package.json ./packages/upward-js/package.json | ||
COPY packages/upward-spec/package.json ./packages/upward-spec/package.json | ||
COPY packages/venia-concept/package.json ./packages/venia-concept/package.json | ||
COPY package.json yarn.lock babel.config.js browserslist.js magento-compatibility.js ./ | ||
|
||
# install dependencies with yarn | ||
RUN yarn install --frozen-lockfile | ||
|
||
# copy over the rest of the package files | ||
COPY packages ./packages | ||
|
||
# copy configuration env file from host file system to venia-concept .env for build | ||
COPY ./docker/.env.docker.prod ./packages/venia-concept/.env | ||
|
||
ENV NODE_ENV=production | ||
# build the app | ||
RUN yarn run build | ||
|
||
|
||
# MULTI-STAGE BUILD | ||
FROM node:10.14.1-alpine | ||
# working directory | ||
WORKDIR /usr/src/app | ||
# node:alpine comes with a configured user and group | ||
RUN chown -R node:node /usr/src/app | ||
# copy build from previous stage | ||
COPY --from=build /usr/src/app . | ||
USER node | ||
EXPOSE 8080 | ||
ENV NODE_ENV=production | ||
# command to run application | ||
CMD [ "yarn", "stage:venia" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"AWSEBDockerrunVersion": "1", | ||
"Image": { | ||
"Name": "276375911640.dkr.ecr.us-east-1.amazonaws.com/pwa-demo:latest", | ||
"Update": "true" | ||
}, | ||
"Ports": [ | ||
{ | ||
"ContainerPort": "8080" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
########## .env.docker ######################################################## | ||
# | ||
# See packages/venia-concept/.env.dist file for full option details | ||
# | ||
############################################################################### | ||
|
||
NODE_ENV=production | ||
PORT=8080 | ||
PWA_STUDIO_HOST=localhost | ||
# magento enterprise edition - in production mode | ||
MAGENTO_BACKEND_URL=https://m231-pwa-ent-1.testsonfire.com/ | ||
MAGENTO_BUILDPACK_PROVIDE_SECURE_HOST=0 | ||
UPWARD_JS_UPWARD_PATH=venia-upward.yml | ||
UPWARD_JS_BIND_LOCAL=1 | ||
UPWARD_JS_LOG_URL=1 | ||
BRAINTREE_TOKEN=sandbox_8yrzsvtm_s2bg8fs563crhqzk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.