-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
39 lines (38 loc) · 2.59 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
version: 0.2
phases:
pre_build:
commands:
- echo Assigning variables...
- DOCKERHUB_PASSWORD=$(aws ssm get-parameter --name "/live-rap-center/prod/DOCKERHUB_PASSWORD" --with-decryption --query "Parameter.Value" --output text --region $AWS_DEFAULT_REGION)
- DOCKERHUB_USERNAME=$(aws ssm get-parameter --name "/live-rap-center/prod/DOCKERHUB_USERNAME" --with-decryption --query "Parameter.Value" --output text --region $AWS_DEFAULT_REGION)
- REACT_APP_SERVER_URL=$(aws ssm get-parameter --name "/live-rap-center/prod/REACT_APP_SERVER_URL" --with-decryption --query "Parameter.Value" --output text --region $AWS_DEFAULT_REGION)
- REACT_APP_GOOGLE_CLIENT_ID=$(aws ssm get-parameter --name "/live-rap-center/prod/REACT_APP_GOOGLE_CLIENT_ID" --with-decryption --query "Parameter.Value" --output text --region $AWS_DEFAULT_REGION)
- REACT_APP_GATEWAY_SOCKET_URL=$(aws ssm get-parameter --name "/live-rap-center/prod/REACT_APP_GATEWAY_SOCKET_URL" --with-decryption --query "Parameter.Value" --output text --region $AWS_DEFAULT_REGION)
- echo "$DOCKERHUB_PASSWORD" | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
- REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
build:
commands:
- echo updating clientside changes
- cd $CODEBUILD_SRC_DIR/client
- echo REACT_APP_SERVER_URL=${REACT_APP_SERVER_URL} >> .env.production
- echo REACT_APP_GOOGLE_CLIENT_ID=${REACT_APP_GOOGLE_CLIENT_ID} >> .env.production
- echo REACT_APP_GATEWAY_SOCKET_URL=${REACT_APP_GATEWAY_SOCKET_URL} >> .env.production
- echo AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} >> .env.production
- echo S3_BUCKET_NAME=${S3_BUCKET_NAME} >> .env.production
- echo CLOUDFRONT_ID=${CLOUDFRONT_ID} >> .env.production
- yarn install
- yarn update
- cd $CODEBUILD_SRC_DIR
- echo Building the Docker image...
- docker build --platform linux/amd64 --tag $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- printf '[{"name":"%s","imageUri":"%s"}]' "$IMAGE_REPO_NAME" "$REPOSITORY_URI:$IMAGE_TAG" > imagedefinitions.json
artifacts:
files: imagedefinitions.json