Skip to content

Commit 8ab8dc7

Browse files
authored
Merge pull request #149 from whoan/use-aws-cli-from-base-image
Use aws-cli from base image
2 parents a133284 + 4c8c3fc commit 8ab8dc7

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ FROM docker:24.0.7
33
LABEL "maintainer"="whoan <juaneabadie@gmail.com>"
44
LABEL "repository"="https://github.com/whoan/docker-build-with-cache-action"
55

6+
RUN apk add --no-cache bash grep jq yq aws-cli
7+
68
COPY docker-build.sh /docker-build.sh
79
COPY entrypoint.sh /entrypoint.sh
810

9-
RUN apk add --no-cache bash grep jq yq
10-
1111
ENTRYPOINT ["/entrypoint.sh"]

docker-build.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,12 @@ _push_image_stages() {
180180
docker push "$stage_image"
181181
}
182182

183-
_aws() {
184-
docker run --rm \
185-
--env AWS_ACCESS_KEY_ID="$INPUT_USERNAME" \
186-
--env AWS_SECRET_ACCESS_KEY="$INPUT_PASSWORD" \
187-
--env AWS_SESSION_TOKEN="$INPUT_SESSION" \
188-
amazon/aws-cli:2.1.14 --region "$(_get_aws_region)" "$@"
189-
}
183+
_aws() (
184+
export AWS_ACCESS_KEY_ID
185+
export AWS_SECRET_ACCESS_KEY
186+
export AWS_SESSION_TOKEN
187+
aws --region "$(_get_aws_region)" "$@"
188+
)
190189

191190
_aws_get_public_ecr_registry_name() {
192191
_aws ecr-public describe-registries --output=text --query 'registries[0].aliases[0].name'
@@ -294,6 +293,9 @@ init_variables() {
294293
if [ -z "$INPUT_SESSION" ]; then
295294
INPUT_SESSION=$AWS_SESSION_TOKEN
296295
fi
296+
AWS_ACCESS_KEY_ID=$INPUT_USERNAME
297+
AWS_SECRET_ACCESS_KEY=$INPUT_PASSWORD
298+
AWS_SESSION_TOKEN=$INPUT_SESSION
297299
fi
298300

299301
# split tags (to allow multiple comma-separated tags)

0 commit comments

Comments
 (0)