Skip to content

Commit

Permalink
Use aws-cli from base image
Browse files Browse the repository at this point in the history
  • Loading branch information
whoan committed Oct 28, 2023
1 parent a133284 commit 4c8c3fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ FROM docker:24.0.7
LABEL "maintainer"="whoan <[email protected]>"
LABEL "repository"="https://github.com/whoan/docker-build-with-cache-action"

RUN apk add --no-cache bash grep jq yq aws-cli

COPY docker-build.sh /docker-build.sh
COPY entrypoint.sh /entrypoint.sh

RUN apk add --no-cache bash grep jq yq

ENTRYPOINT ["/entrypoint.sh"]
16 changes: 9 additions & 7 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,12 @@ _push_image_stages() {
docker push "$stage_image"
}

_aws() {
docker run --rm \
--env AWS_ACCESS_KEY_ID="$INPUT_USERNAME" \
--env AWS_SECRET_ACCESS_KEY="$INPUT_PASSWORD" \
--env AWS_SESSION_TOKEN="$INPUT_SESSION" \
amazon/aws-cli:2.1.14 --region "$(_get_aws_region)" "$@"
}
_aws() (
export AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY
export AWS_SESSION_TOKEN
aws --region "$(_get_aws_region)" "$@"
)

_aws_get_public_ecr_registry_name() {
_aws ecr-public describe-registries --output=text --query 'registries[0].aliases[0].name'
Expand Down Expand Up @@ -294,6 +293,9 @@ init_variables() {
if [ -z "$INPUT_SESSION" ]; then
INPUT_SESSION=$AWS_SESSION_TOKEN
fi
AWS_ACCESS_KEY_ID=$INPUT_USERNAME
AWS_SECRET_ACCESS_KEY=$INPUT_PASSWORD
AWS_SESSION_TOKEN=$INPUT_SESSION
fi

# split tags (to allow multiple comma-separated tags)
Expand Down

0 comments on commit 4c8c3fc

Please sign in to comment.