From e94955ea481a2a4d1ad8b596f6b1b571943c2bea Mon Sep 17 00:00:00 2001 From: abdurawoof Date: Fri, 13 Dec 2024 22:25:08 +0530 Subject: [PATCH] passed aws config arguments in docker build --- .github/workflows/catalog.yml | 5 +++-- docker/Dockerfile | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/catalog.yml b/.github/workflows/catalog.yml index bd52b28..2500dba 100644 --- a/.github/workflows/catalog.yml +++ b/.github/workflows/catalog.yml @@ -81,7 +81,8 @@ jobs: - name: Log in to Amazon ECR run: | aws ecr get-login-password --region us-east-2 --profile tf_user | docker login --username AWS --password-stdin 583275065488.dkr.ecr.us-east-2.amazonaws.com - + + # ADDED aws credentials so that during docker build the s3 objacet can be accessed - name: Build Docker image with unique tag run: | export IMAGE_TAG=$(date +%Y%m%d%H%M%S) @@ -89,7 +90,7 @@ jobs: export NEW_IMAGE_URI="583275065488.dkr.ecr.us-east-2.amazonaws.com/catalog:$IMAGE_TAG" echo "NEW_IMAGE_URI=$NEW_IMAGE_URI" >> $GITHUB_ENV - sudo docker build --build-arg TOKEN=${{ secrets.TOKEN }} -f docker/Dockerfile -t test-catalog:$IMAGE_TAG . + sudo docker build --build-arg TOKEN=${{ secrets.TOKEN }} --build-arg AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_ACCOUNT_ACCESS_KEY_ID }} --build-arg AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCOUNT_SECRET_ACCESS_KEY }} -f docker/Dockerfile -t test-catalog:$IMAGE_TAG . sudo docker tag test-catalog:$IMAGE_TAG $NEW_IMAGE_URI - name: Push Docker image to Amazon ECR diff --git a/docker/Dockerfile b/docker/Dockerfile index e567275..7d02c1c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -49,10 +49,17 @@ FROM alpine:3.18.3 as package ARG SCHEMA_VERSION="1.138.3-SNAPSHOT" ARG S3_PATH_PRIVATE=s3://ghactions-workflow/usage-schema-${SCHEMA_VERSION}-schema.tar.gz +ARG AWS_ACCESS_KEY_ID +ARG AWS_SECRET_ACCESS_KEY +ARG AWS_REGION="us-east-2" #RUN apk add --update --no-cache curl tar ca-certificates && \ -# added usage-schema to s3 bucket and from bucket the usaage schema is used in dockef build -RUN apk add --update --no-cache curl tar && \ +# added usage-schema to s3 bucket and from bucket the usaage schema is used in dockef build & passed arguments to aws configure +RUN apk add --update --no-cache curl tar unzip && \ + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ + unzip awscliv2.zip && \ + ./aws/install && \ + rm -rf awscliv2.zip aws && \ aws s3 cp ${S3_PATH_PRIVATE} /tmp/usage-schema.tar.gz && \ tar -xzf /tmp/usage-schema.tar.gz #curl https://artifacts.rackspace.net/artifactory/cloudfeeds-maven-local/com/rackspace/usage/usage-schema/${SCHEMA_VERSION}/usage-schema-${SCHEMA_VERSION}-schema.tar.gz | tar xz