-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
59 lines (56 loc) · 2.82 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
49
50
51
52
53
54
55
56
57
58
59
---
version: 0.2
phases:
install:
runtime-versions:
python: 3.7
commands:
- echo 'about to call dockerd'
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2&
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
- curl -sS -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/aws-iam-authenticator
# Download the latest stable release kubectl
# - curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# You must use a kubectl version that is within one minor version difference of your Amazon EKS cluster control plane.
# For example, a 1.21 kubectl client works with Kubernetes 1.20, 1.21 and 1.22 clusters.
# Ref: https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html OR https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
# To download a specific version v1.22.0 on Linux, use:
- curl -LO https://dl.k8s.io/release/v1.23.6/bin/linux/amd64/kubectl
# Download the kubectl checksum file
- curl -LO "https://dl.k8s.io/v1.23.6/bin/linux/amd64/kubectl.sha256"
# Validate the kubectl binary against the checksum file
- echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
# Install kubectl
- chmod +x ./kubectl ./aws-iam-authenticator
# - mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin
- export PATH=$PWD/:$PATH
- python --version
- echo 'export PATH=$PWD/:$PATH' >> $HOME/.bashrc
- echo `kubectl version --short --client`
- python -m pip install --upgrade --force pip
- apt-get update && apt-get -y install jq && pip install --upgrade awscli
pre_build:
commands:
- python3 -m pip install -r requirements.txt
- python3 -m pytest test_main.py
- TAG="$REPOSITORY_NAME.$REPOSITORY_BRANCH.$ENVIRONMENT_NAME.$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
- sed -i 's@CONTAINER_IMAGE@'"$REPOSITORY_URI:$TAG"'@' simple_jwt_api.yml
- $(aws ecr get-login --no-include-email)
- export KUBECONFIG=$HOME/.kube/config
- echo `ls -l`
build:
commands:
- docker build --tag $REPOSITORY_URI:$TAG .
post_build:
commands:
- docker push $REPOSITORY_URI:$TAG
- echo $EKS_CLUSTER_NAME
- echo $EKS_KUBECTL_ROLE_ARN
- aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --role-arn $EKS_KUBECTL_ROLE_ARN
- kubectl apply -f simple_jwt_api.yml
- printf '[{"name":"simple_jwt_api","imageUri":"%s"}]' $REPOSITORY_URI:$TAG > build.json
artifacts:
files: build.json
env:
parameter-store:
JWT_SECRET: JWT_SECRET