Skip to content
Snippets Groups Projects
Commit aad780fc authored by Marc Burnie [AWS]'s avatar Marc Burnie [AWS]
Browse files

Fixing Build Due to Docker Rate Limiting

parent 9c9126ab
No related branches found
No related tags found
3 merge requests!299Update Dev branch,!298Securityfix,!237Adding Scaling to AWS OPA Deployment
......@@ -3,7 +3,7 @@ variables:
PYTHONPATH: app
PYTEST_DIR: app/tests/unit
AWS_BUILD_SUBDIR: app
AWS_BUILD_SUBDIR: build/aws/build-aws
# AWS_TEST_SUBDIR: testing/storage-test-aws
AWS_SERVICE: policy
AWS_SERVICE_NAMESPACE: osdu-services
......
# This Dockerfile assumes you used "make build" to convert the AdminUI to static files in frontend/adminui/dist/policyservice
FROM python:3.9-slim-buster
FROM public.ecr.aws/docker/library/python:3.9-slim-buster
# set environment variables
# PYTHONDONTWRITEBYTECODE - Prevents Python from writing pyc files to disc (equivalent to python -B option)
ENV PYTHONDONTWRITEBYTECODE 1
# PYTHONUNBUFFERED - Prevents Python from buffering stdout and stderr (equivalent to python -u option)
ENV PYTHONUNBUFFERED 1
EXPOSE 8080/tcp
WORKDIR /opt
COPY ./app /opt
......
......@@ -22,23 +22,26 @@ env:
DOCKER_PASSWORD: /osdu/devops/docker_credentials:password
phases:
install:
runtime-versions:
nodejs: 12
commands:
- if [ $(echo $CODEBUILD_SOURCE_VERSION | grep -c ^refs/heads.*) -eq 1 ]; then echo "Branch name found"; else echo "This build only supports branch builds" && exit 1; fi
- apt-get update -y
# Install git secrets
#TODO temporarily adding hotfix, due to https://github.com/awslabs/git-secrets/issues/220
- export SAY_LOCATION=`ln -s "$(which echo)" say`
- export PATH="$PATH:$SAY_LOCATION"
- git clone https://github.com/awslabs/git-secrets.git
- cd git-secrets && make install && cd ..
- git secrets --install && git secrets --register-aws
- npm cache clean -f
- n stable
- npm --version
- n 16
- npm install -g @angular/cli
pre_build:
commands:
- echo "Logging in to Amazon ECR..."
- $(aws ecr get-login --no-include-email --region $AWS_REGION) # authenticate with ECR via the AWS CLI
build:
commands:
- export AWS_ACCOUNT_ID=`aws sts get-caller-identity --query Account --output text`
- export REPO_NAME=${PWD##*/}
- export OUTPUT_DIR="dist"
- export BRANCH_NAME=`echo ${CODEBUILD_SOURCE_VERSION} | awk '{gsub("refs/heads/","");gsub("\\.","-");gsub("[[:space:]]","-")}1' | sed 's/\//-/g' | awk '{print tolower($0)}'`
......@@ -57,7 +60,7 @@ phases:
- printenv
- cd app
- make build
- make build_adminui
- cd ..
- GIT_SECRETS_SCAN_RESULT=$(git secrets --scan 2> ${OUTPUT_DIR}/git_secrets.out.txt && echo OK || echo FAILED)
......@@ -69,10 +72,10 @@ phases:
- echo "--Copying Helm Charts to ${OUTPUT_DIR:-dist}--"
- rsync -r devops/aws/* "${OUTPUT_DIR:-dist}"
- echo "Logging into Docker Hub..."
- docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
- echo "Logging in to Amazon ECR..."
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com # authenticate with ECR via the AWS CLI
- echo "Building docker image..."
- docker build -f app/Dockerfile -t ${ECR_IMAGE} .
- docker build -f build/aws/build-aws/Dockerfile -t ${ECR_IMAGE} .
- docker tag ${ECR_IMAGE} ${ECR_IMAGE_BRANCH_LATEST}
- echo "Pushing docker image..."
- docker push ${ECR_IMAGE}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment