-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
41 lines (41 loc) · 1.63 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
version: 0.2
run-as: root
env:
variables:
"CONTAINER_REPO": "843407916570.dkr.ecr.ap-southeast-2.amazonaws.com"
"CONTAINER_NAME": "cttso-ica-to-pieriandx"
"REGION": "ap-southeast-2"
phases:
install:
runtime-versions:
docker: 19
python: 3.9
pre_build:
commands:
# Set DEBIAN_FRONTEND env var to noninteractive
- export DEBIAN_FRONTEND=noninteractive
# Update
- apt-get update -y -qq
# Install git, unzip and wget
- apt-get install -y -qq git unzip wget
# Install aws v2
- wget --quiet --output-document "awscliv2.zip" "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"
- unzip -qq awscliv2.zip
- ./aws/install
- rm "awscliv2.zip"
build:
commands:
# Convenience CODEBUILD VARS, need more? Check https://github.com/thii/aws-codebuild-extras
- export CTTSO_ICA_TO_PIERIANDX_GIT_TAG="$(git describe --tags --exact-match 2>/dev/null)"
# Single brackets since running in shell
- if [ -z "${CTTSO_ICA_TO_PIERIANDX_GIT_TAG}" ]; then export CTTSO_ICA_TO_PIERIANDX_GIT_TAG="NOTAG"; fi
- CONTAINER_VERSION="${CTTSO_ICA_TO_PIERIANDX_GIT_TAG}"
- export CONTAINER_VERSION
- echo "Container version is ${CONTAINER_VERSION}" 1>&2
# Build and tag (-t) image
- docker build --tag "${CONTAINER_REPO}/${CONTAINER_NAME}:${CONTAINER_VERSION}" .
post_build:
commands:
# Login to aws and push Docker image to ECR
- aws ecr get-login-password --region "${REGION}" | docker login --username AWS --password-stdin "${CONTAINER_REPO}"
- docker push "${CONTAINER_REPO}/${CONTAINER_NAME}:${CONTAINER_VERSION}"