This repository has been archived by the owner on Jul 20, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
buildspec.yml
61 lines (59 loc) · 2.72 KB
/
buildspec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
version: 0.2
env:
variables:
NODE_VERSION: "8.1.4"
phases:
install:
commands:
- echo Installing Node...
# - wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
- wget -qO- https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz | tar xJ --directory /usr/local
- ln -s /usr/local/node-v${NODE_VERSION}-linux-x64 /usr/local/node
- export PATH=/usr/local/node/bin/:${PATH}
# Permission settings for npm
- mkdir ~/.npm-global
- npm config set prefix '~/.npm-global'
- export PATH=~/.npm-global/bin/:${PATH}
- echo Upgrading AWS CLI...
# - apt-get install python-pip -y
- pip install awscli --upgrade --user
- echo Logging into AWS ECR
- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
pre_build:
commands:
- cd $CODEBUILD_SRC_DIR # move to code buil root directory, in case that previous script cd into a different directory
- echo Define build version
- IMAGE_TAG=`date +%s%3N`
- echo Installing dependencies
- cd frontend-v2
- npm install
# TODO Remove this when we frontend is configured to read BASE_PATH from env
# - echo TEMP FIX - Replacing http://localhost with actual API URL
# - find ./ -type f -print0 | xargs -0 sed -i'' -e 's|http://localhost:50050|'https://$API_URL'|'
# - npm test
build:
commands:
- cd $CODEBUILD_SRC_DIR # move to code buil root directory, in case that previous script cd into a different directory
- echo Building Frontend
- cd frontend-v2
- npm run build --prod
- echo Building API containers
- cd $CODEBUILD_SRC_DIR/backend
- docker build --build-arg MONGO_HOST=$MONGO_HOST --build-arg MONGO_PORT=$MONGO_PORT --build-arg MONGO_USERNAME=$MONGO_USERNAME --build-arg MONGO_PASSWORD=$MONGO_PASSWORD --build-arg MONGO_DBNAME=$MONGO_DBNAME -t $IMAGES_REPO_URL:$IMAGE_TAG .
- echo Remove `latest` tag from previous image
- aws ecr batch-delete-image --repository-name $IMAGES_REPO_NAME --image-ids imageTag=latest
- docker tag $IMAGES_REPO_URL:$IMAGE_TAG $IMAGES_REPO_URL:latest
post_build:
commands:
- cd $CODEBUILD_SRC_DIR # move to code buil root directory, in case that previous script cd into a different directory
- echo Updating site in s3
- aws s3 sync ./frontend-v2/dist s3://$FRONTEND_BUCKET --acl public-read --delete --region $AWS_DEFAULT_REGION
- echo Pushing docker API container to AWS ECR
- docker push $IMAGES_REPO_URL:$IMAGE_TAG
- echo adding latest tag
- docker push $IMAGES_REPO_URL:latest
artifacts:
files:
- frontend-v2/dist/**/*
#discard-paths: yes
#base-directory: location