-
Notifications
You must be signed in to change notification settings - Fork 5
/
buildspec.yml
28 lines (28 loc) · 1.2 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
# This is the buildspec used by CodeBuild to generate the image
#
version: 0.2
phases:
pre_build:
commands:
- $(aws ecr get-login --no-include-email )
- TAG="$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
- IMAGEURI="${REPOSITORY_URI}:${TAG}"
- apt-get update
- apt-get install jq
- DOCKERHUB=$( aws secretsmanager get-secret-value --secret-id websites-webrouter/dockerhub-credentials --query SecretString )
- DOCKERHUB_PASSWORD=$(echo "$DOCKERHUB" | jq --raw-output . | jq -r .password )
- DOCKERHUB_USERNAME=$(echo "$DOCKERHUB" | jq --raw-output . | jq -r .user )
- echo "user=$DOCKERHUB_USERNAME"
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
build:
commands:
- docker build --build-arg "landscape=$LANDSCAPE" --tag "$IMAGEURI" .
- docker run -e "LANDSCAPE=$LANDSCAPE" "$IMAGEURI" /usr/sbin/run-nginx.sh -t
post_build:
commands:
- docker push "$IMAGEURI"
- docker tag "$IMAGEURI" "${REPOSITORY_URI}:latest"
- docker push "${REPOSITORY_URI}:latest"
- printf '[{"name":"bu-webrouter", "imageUri":"%s"}]' "$IMAGEURI" >build.json
artifacts:
files: build.json