-
Notifications
You must be signed in to change notification settings - Fork 2
/
buildspec.yml
48 lines (44 loc) · 1.96 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
version: 0.2
env:
git-credential-helper: yes
phases:
pre_build:
commands:
- git submodule update --init --recursive
- echo Logging in to Amazon ECR...
- ECR_PASSWORD=$(aws ecr get-login-password --region $AWS_DEFAULT_REGION)
- echo $ECR_PASSWORD | docker login --username AWS --password-stdin $AWS_ACCCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
- echo Logging in to Docker Hub...
- echo $DOCKERHUB_PASSWORD | docker login --username $DOCKERHUB_USERNAME --password-stdin
- touch .env_local
build:
commands:
- echo Build started on `date`
- docker compose build
- echo Running tests...
- scripts/lint.sh
- scripts/django-checks.sh
- scripts/js_dependencies.py --verify
- scripts/check-migrations.sh
- scripts/unit-tests.sh
- scripts/end2end-tests.sh
- export GIT_TAG="$(echo $GIT_COMMIT_ID | cut -c1-8)"
- export IMAGE_TAG=$GIT_TAG
- echo "Building image from commit ${GIT_COMMIT_ID} ${GIT_COMMIT_URL}"
- docker build -f docker/production/Dockerfile --label "release-id=${RELEASE_ID}" -t "${IMAGE_REPO}:${GIT_TAG}" -t "${IMAGE_REPO}:${GIT_BRANCH_NAME}" .
# docker push used to be in post_build, but post_build is executed even on build failure.
# We don't want to push the docker image if the build failed for any reason, so we can't do the docker push in post_build.
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker push "${IMAGE_REPO}:${GIT_TAG}"
- docker push "${IMAGE_REPO}:${GIT_BRANCH_NAME}"
- ./infra/deploy_longitudinal_followup_stack.sh
post_build:
commands:
- aws ssm put-parameter --overwrite --type String --name /app/$ENVIRONMENT_NAME/$APPLICATION_NAME/RELEASE_ID --value $IMAGE_TAG
- envsubst < taskdef.json > out && mv out taskdef.json
- envsubst < appspec.yaml > out && mv out appspec.yaml
artifacts:
files:
- 'taskdef.json'
- 'appspec.yaml'