File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# syntax=docker/dockerfile:1
22
3- # ECR and base image configuration
4- ARG ECR_ACCOUNT_ID=1234567890123
5- ARG ECR_REGION=us-east-999
6- ARG BASE_IMAGE_NAME=ubuntu-fips
3+ # ECR and base image configuration - extracted from CodeBuild environment
4+ ARG ECR_ACCOUNT_ID
5+ ARG ECR_REGION
6+ ARG BASE_IMAGE_NAME=civis- ubuntu-fips
77ARG BASE_IMAGE_TAG=22.04
8- ARG ECR_URI=${ECR_ACCOUNT_ID}.dkr.ecr-fips.${ECR_REGION}.amazonaws.com/${BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}
8+ ARG ECR_URI=${ECR_ACCOUNT_ID}.dkr.ecr-fips.${ECR_REGION}.amazonaws.com/${BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}
99
1010FROM ${ECR_URI} as ubuntu-fips-s6
1111# set version labels
Original file line number Diff line number Diff line change @@ -4,10 +4,15 @@ phases:
44 commands :
55 - echo Logging in to Amazon ECR...
66 - aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${FIPS_REPOSITORY_URI}
7+ # Extract ECR account ID and region from FIPS_REPOSITORY_URI
8+ - export ECR_ACCOUNT_ID="$(echo $FIPS_REPOSITORY_URI | cut -d'.' -f1)"
9+ - export ECR_REGION="$(echo $FIPS_REPOSITORY_URI | cut -d'.' -f4)"
10+ - echo "ECR Account ID : $ECR_ACCOUNT_ID"
11+ - echo "ECR Region : $ECR_REGION"
712 build :
813 commands :
914 - echo Building the Docker image...
10- - docker build -t ${FIPS_REPOSITORY_URI}:latest .
15+ - docker build --build-arg ECR_ACCOUNT_ID=${ECR_ACCOUNT_ID} --build-arg ECR_REGION=${ECR_REGION} - t ${FIPS_REPOSITORY_URI}:latest .
1116 - docker image push --all-tags ${FIPS_REPOSITORY_URI}
1217 post_build :
1318 commands :
Original file line number Diff line number Diff line change @@ -5,11 +5,16 @@ phases:
55 - echo Logging in to Amazon ECR...
66 - aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${FIPS_REPOSITORY_URI}
77 - export COMMIT_HASH_SHORT="$(echo $COMMIT_HASH | cut -c 1-7)"
8+ # Extract ECR account ID and region from FIPS_REPOSITORY_URI
9+ - export ECR_ACCOUNT_ID="$(echo $FIPS_REPOSITORY_URI | cut -d'.' -f1)"
10+ - export ECR_REGION="$(echo $FIPS_REPOSITORY_URI | cut -d'.' -f4)"
811 - echo Building the Docker image...
912 - echo $FIPS_REPOSITORY_URI
1013 - echo $COMMIT_HASH_SHORT
1114 - echo $BRANCH_NAME
12- - docker build --tag ${FIPS_REPOSITORY_URI}:${COMMIT_HASH_SHORT} --tag ${FIPS_REPOSITORY_URI}:${BRANCH_NAME} .
15+ - echo "ECR Account ID : $ECR_ACCOUNT_ID"
16+ - echo "ECR Region : $ECR_REGION"
17+ - docker build --build-arg ECR_ACCOUNT_ID=${ECR_ACCOUNT_ID} --build-arg ECR_REGION=${ECR_REGION} --tag ${FIPS_REPOSITORY_URI}:${COMMIT_HASH_SHORT} --tag ${FIPS_REPOSITORY_URI}:${BRANCH_NAME} .
1318 # We have a life cycle policy in place to expire and delete images from dev branches,
1419 # so there are no issues with pushing as many of these images as there may be.
1520 - docker image push --all-tags ${FIPS_REPOSITORY_URI}
Original file line number Diff line number Diff line change @@ -5,11 +5,16 @@ phases:
55 commands :
66 - echo Logging in to Amazon ECR...
77 - aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${FIPS_REPOSITORY_URI}
8+ # Extract ECR account ID and region from FIPS_REPOSITORY_URI
9+ - export ECR_ACCOUNT_ID="$(echo $FIPS_REPOSITORY_URI | cut -d'.' -f1)"
10+ - export ECR_REGION="$(echo $FIPS_REPOSITORY_URI | cut -d'.' -f4)"
11+ - echo "ECR Account ID : $ECR_ACCOUNT_ID"
12+ - echo "ECR Region : $ECR_REGION"
813 - echo Building the Docker image...
914 - PATCH_TAG=${TAG_NAME#"v"} # major.minor.patch
1015 - MINOR_TAG=${PATCH_TAG%.*} # major.minor
1116 - MAJOR_TAG=${MINOR_TAG%.*} # major
12- - docker build -t ${FIPS_REPOSITORY_URI}:${PATCH_TAG} -t ${FIPS_REPOSITORY_URI}:${MINOR_TAG} -t ${FIPS_REPOSITORY_URI}:${MAJOR_TAG} .
17+ - docker build --build-arg ECR_ACCOUNT_ID=${ECR_ACCOUNT_ID} --build-arg ECR_REGION=${ECR_REGION} - t ${FIPS_REPOSITORY_URI}:${PATCH_TAG} -t ${FIPS_REPOSITORY_URI}:${MINOR_TAG} -t ${FIPS_REPOSITORY_URI}:${MAJOR_TAG} .
1318 - docker image push --all-tags ${FIPS_REPOSITORY_URI}
1419 post_build :
1520 commands :
Original file line number Diff line number Diff line change 11---
22services :
33 docker-linux-server-ubuntu-fips :
4- image : gabemendoza1/docker-linuxserver-ubuntu-fips:${VERSION:-jammy-22.04}
54 build :
65 context : .
76 dockerfile : Dockerfile
You can’t perform that action at this time.
0 commit comments