forked from Aggregate-Intellect/sherpa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.prod.yml
32 lines (30 loc) · 1.42 KB
/
buildspec.prod.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
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
- SECRET_STRING=$(aws secretsmanager get-secret-value --secret-id docker_creds --query 'SecretString' --output text)
- USERNAME=$(echo $SECRET_STRING | jq -r '.docker_username')
- PASSWORD=$(echo $SECRET_STRING | jq -r '.password')
- REPOSITORY_URI=387065515315.dkr.ecr.us-east-1.amazonaws.com/ai/slackbot
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=build-$(echo $CODEBUILD_BUILD_ID | awk -F":" '{print $2}')
- aws s3 sync s3://ai-config-one/slackbot ./
- mv env-prod.properties production.env
- cp production.env ./src/.env
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker login --username $USERNAME --password $PASSWORD
- docker build --cache-from $REPOSITORY_URI:latest -t $REPOSITORY_URI:latest -f ./src/apps/slackapp/Dockerfile ./src
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- aws ecs update-service --cluster slackbot --service RunSlackApp --force-new-deployment