Skip to content

Commit

Permalink
Login to dockerhub before pack build
Browse files Browse the repository at this point in the history
  • Loading branch information
fagianijunior committed Nov 29, 2024
1 parent 3caca84 commit 528b5d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,20 @@ RUN curl -sS -o /usr/local/bin/aws-iam-authenticator https://amazon-eks.s3.us-we
&& chmod +x /usr/local/bin/kubectl /usr/local/bin/aws-iam-authenticator /usr/local/bin/ecs-cli /usr/local/bin/eksctl

# Configure SSM & AWS CLI
RUN set -ex \
&& yum install -y https://s3.amazonaws.com/amazon-ssm-us-east-1/2.3.1644.0/linux_amd64/amazon-ssm-agent.rpm \
# RUN set -ex \
# && yum install -y https://s3.amazonaws.com/amazon-ssm-us-east-1/2.3.1644.0/linux_amd64/amazon-ssm-agent.rpm \
# && unzip awscliv2.zip \
# && ./aws/install


RUN ARCH=$(uname -m) \
&& if [ "$ARCH" = "aarch64" ]; then \
yum install -y https://s3.amazonaws.com/amazon-ssm-region-name/latest/linux_arm64/amazon-ssm-agent.rpm; \
elif [ "$ARCH" = "x86_64" ]; then \
yum install -y https://s3.amazonaws.com/amazon-ssm-region-name/latest/linux_amd64/amazon-ssm-agent.rpm; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi \
&& unzip awscliv2.zip \
&& ./aws/install

Expand Down
6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ else
echo "AWS_ACCESS_KEY_ID=$(jq -r '.AccessKeyId' <<<$build_assume_role)" >> .env
echo "AWS_SECRET_ACCESS_KEY=$(jq -r '.SecretAccessKey' <<<$build_assume_role)" >> .env
echo "AWS_SESSION_TOKEN=$(jq -r '.Token' <<<$build_assume_role)" >> .env

# Login to DockerHub if credentials are provided
if [ -n "$DOCKERHUB_USERNAME" ]; then
echo $DOCKERHUB_PASS | docker login --username $DOCKERHUB_USERNAME --password-stdin
fi

pack build ${build_image_name%:*}:latest \
--tag $build_image_name \
--env-file .env \
Expand Down

0 comments on commit 528b5d5

Please sign in to comment.