Skip to content

Commit

Permalink
passed aws config arguments in docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
AbduRawoof committed Dec 13, 2024
1 parent 4cf74db commit e94955e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ 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)
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
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
Expand Down
11 changes: 9 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e94955e

Please sign in to comment.