Skip to content

Commit

Permalink
Increment mirror to avoid DockerHub rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
fagianijunior committed Dec 5, 2024
1 parent 3caca84 commit 4d66a50
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ RUN curl -sS -o /usr/local/bin/aws-iam-authenticator https://amazon-eks.s3.us-we
&& curl -sS -L https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz | tar xz -C /usr/local/bin \
&& 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 ARCH=$(uname -m) \
&& if [ "$ARCH" = "aarch64" ]; then \
yum install -y https://s3.amazonaws.com/amazon-ssm-us-east-1/latest/linux_arm64/amazon-ssm-agent.rpm; \
elif [ "$ARCH" = "x86_64" ]; then \
yum install -y https://s3.amazonaws.com/amazon-ssm-us-east-1/latest/linux_amd64/amazon-ssm-agent.rpm; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi \
&& unzip awscliv2.zip \
&& ./aws/install

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ Variable | Description | Examples/Values | Default
`MAESTRO_DEBUG` | Amplify verbosity of the build <br><br> **Choose only one of the example values** | `true` <br> `false`
`MAESTRO_NO_CACHE` | If the cache layer shouldn't be used in the pack build <br><br> **Choose only one of the example values** | `true` <br> `false`
`MAESTRO_ONLY_BUILD` | Stops after build if `true`, leave empty otherwise | `true`
`MAESTRO_SKIP_BUILD` | Skips build and process following steps if true, leave empty otherwise | `true`
`MAESTRO_SKIP_BUILD` | Skips build and process following steps if true, leave empty otherwise | `true`
`MAESTRO_RUN_IMAGE` | Provides the base image for application images. | `123456789.dkr.ecr.us-east-1.amazonaws.com/base_image:latest` | null
`NEW_RELIC_API_KEY` | A user API key from NewRelic for registering deploys | `NRAK-XXXXXXXXXXXXXXXXXXXXXXXXX`
`NEW_RELIC_APP_ID` | NewRelic APM's application identifier | `123456789`
`NEW_RELIC_DESCRIPTION` | Git source's deploys description to NewRelic. (Reference: https://git-scm.com/docs/git-log) | `The author of %h was %an, %ar%nThe title was >>%s<<%n`
Expand Down Expand Up @@ -120,6 +121,11 @@ Maestro allows you to register a deploy with a custom webhook using a standard `
- `{{REPO_LINK}}` for the repository's link
- `{{BUILD_LINK}}` for the build's log link

### Troubleshooting
1. DockerHub hate limit
If you are esperiencing DockerHub rate limits, clone the `heroku/heroku:xx-cnb` image to your ECR repository. Edit the `buildspec` section on your `Codebuild`, and add the following instruction inside the `commands:` session, at the first line.
<br>
`- pack config run-image-mirrors add heroku/heroku:20-cnb --mirror public.ecr.aws/x1o4r4n3/maestro-builder-20:runimage`

### Contributing
Feel free to suggest improvements by opening pull requests.
6 changes: 4 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

set -eo pipefail
set -x

VALID_ARGS=$(getopt -o i: --long image-name: -n 'build.sh' -- "$@")
if [[ $? -ne 0 ]]; then
Expand Down Expand Up @@ -38,6 +37,7 @@ 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

pack build ${build_image_name%:*}:latest \
--tag $build_image_name \
--env-file .env \
Expand All @@ -46,7 +46,9 @@ else
$( [[ -n $REPO_SUB_FOLDER ]] && echo "--path ${REPO_SUB_FOLDER}") \
$( [[ -z $MAESTRO_NO_CACHE || $MAESTRO_NO_CACHE = "false" ]] && echo "--pull-policy if-not-present --cache-image ${build_image_name%:*}:cache") \
$( [ $MAESTRO_NO_CACHE = "true" ] && echo "--pull-policy always --clear-cache --env USE_YARN_CACHE=false --env NODE_MODULES_CACHE=false") \
$( [ $MAESTRO_DEBUG = "true" ] && echo "--env NPM_CONFIG_LOGLEVEL=debug --env NODE_VERBOSE=true --verbose")
$( [ $MAESTRO_DEBUG = "true" ] && echo "--env NPM_CONFIG_LOGLEVEL=debug --env NODE_VERBOSE=true --verbose") \
$( [[ -z $MAESTRO_RUN_IMAGE ]] && echo "--run-image $MAESTRO_RUN_IMAGE")

docker tag $build_builder_name ${build_image_name%:*}:$build_builder_tag
docker push ${build_image_name%:*}:$build_builder_tag 2> /dev/null
fi

0 comments on commit 4d66a50

Please sign in to comment.