Skip to content

Commit 80abde2

Browse files
zijun726911Zijun Wang
andauthored
- Shift from buildah to docker build so that people could release image in macOS (#569)
Co-authored-by: Zijun Wang <zijunw@amazon.com>
1 parent 9d6525a commit 80abde2

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ go.work*
1515
.idea/
1616

1717
# gomock generated prog.go
18-
pkg/aws/services/gomock_reflect_*
18+
pkg/aws/services/gomock_reflect_*
19+
20+
# Image build tarballed bundles
21+
*.tgz

scripts/lib/login.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
# helm.sh, because those files ensure binaries(ex: kind) that are not
66
# really needed for simple actions like repository login.
77
# A future refactor can make those files more modular and then login
8-
# functions can be refactored in tool specific file like buildah.sh
8+
# functions can be refactored in tool specific file like docker.sh
99
# and helm.sh
1010

11-
perform_buildah_and_helm_login() {
11+
perform_docker_and_helm_login() {
1212
#ecr-public only exists in us-east-1 so use that region specifically
1313
local __pw=$(aws ecr-public get-login-password --region us-east-1)
14-
echo "$__pw" | buildah login -u AWS --password-stdin public.ecr.aws
14+
echo "$__pw" | docker login -u AWS --password-stdin public.ecr.aws
1515
export HELM_EXPERIMENTAL_OCI=1
1616
echo "$__pw" | helm registry login -u AWS --password-stdin public.ecr.aws
1717
}
1818

1919
ensure_binaries() {
2020
check_is_installed "aws"
21-
check_is_installed "buildah" "See https://github.com/containers/buildah/blob/main/install.md"
21+
check_is_installed "docker"
2222
check_is_installed "helm"
2323
}
2424

scripts/release-controller.sh

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ Environment variables:
3333
Default: $DEFAULT_CHART_REPOSITORY
3434
CHART_TAG: Controller Helm Chart tag
3535
Default: Based on \$PULL_BASE_REF
36-
ECR_PUBLISH_ROLE_ARN IAM Role ARN for the Role that has permission to
37-
publish to the image and Helm chart repositories on ECR Public. This role is
38-
assumed by this script in order to upload artifacts.
3936
"
4037

4138
# find out the service name and semver tag from the CI environment variable if not specified
@@ -97,34 +94,17 @@ IMAGE_TAG=${IMAGE_TAG:-$VERSION}
9794
CHART_REPOSITORY=${CHART_REPOSITORY:-$DEFAULT_CHART_REPOSITORY}
9895
CHART_REGISTRY=${CHART_REGISTRY:-$DEFAULT_CHART_REGISTRY}
9996

100-
ECR_PUBLISH_ROLE_ARN=${ECR_PUBLISH_ROLE_ARN:-"undefined"}
101-
102-
if [[ "$ECR_PUBLISH_ROLE_ARN" = undefined ]]; then
103-
error_msg "Please set the ECR_PUBLISH_ROLE_ARN environment variable to the IAM Role ARN"
104-
error_msg "that has permissions to upload artifacts to the ECR Public registry for"
105-
error_msg "$IMAGE_REPOSITORY"
106-
exit 2
107-
fi
108-
10997
echo "VERSION is $VERSION"
11098

111-
# TODO(jaypipes): If we move to Prow setup like ACK, uncomment this. For now,
112-
# just pass in ECR_PUBLISH_ROLE_ARN manually.
113-
# ASSUME_EXIT_VALUE=0
114-
# ECR_PUBLISH_ROLE_ARN=$(aws ssm get-parameter --name /ack/prow/cd/public_ecr/publish_role --query Parameter.Value --output text 2>/dev/null) || ASSUME_EXIT_VALUE=$?
115-
# if [ "$ASSUME_EXIT_VALUE" -ne 0 ]; then
116-
# echo "release-controller.sh] [SETUP] Could not find the iam role to publish images to public ecr repository"
117-
# exit 1
118-
# fi
119-
export ECR_PUBLISH_ROLE_ARN
120-
echo "release-controller.sh] [SETUP] exported ECR_PUBLISH_ROLE_ARN"
121-
99+
# This Role has permission to publish to the image and Helm chart repositories on ECR public registry in 606627242267 account.
100+
# Make sure the aws principal you use to run this script has permission to assume this role
101+
ECR_PUBLISH_ROLE_ARN=arn:aws:iam::606627242267:role/ECRPublisher
122102
ASSUME_COMMAND=$(aws --output json sts assume-role --role-arn $ECR_PUBLISH_ROLE_ARN --role-session-name 'publish-images' --duration-seconds 3600 | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId)\nexport AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey)\nexport AWS_SESSION_TOKEN=\(.SessionToken)\n"')
123103
eval $ASSUME_COMMAND
124104
echo "release-controller.sh] [SETUP] Assumed ECR_PUBLISH_ROLE_ARN"
125105

126-
# Setup the destination repository for buildah and helm
127-
perform_buildah_and_helm_login
106+
# Setup the destination repository for docker and helm
107+
perform_docker_and_helm_login
128108

129109
# Do not rebuild controller image for stable releases
130110
if [[ "$SKIP_IMAGE_BUILD" != "1" ]]; then
@@ -147,9 +127,7 @@ if [[ "$SKIP_IMAGE_BUILD" != "1" ]]; then
147127
fi
148128

149129
# build controller image
150-
buildah bud \
151-
--quiet="$QUIET" \
152-
-t "$IMG" \
130+
docker build -t "$IMG" \
153131
-f "$CONTROLLER_IMAGE_DOCKERFILE_PATH" \
154132
--build-arg service_controller_git_version="$VERSION" \
155133
--build-arg service_controller_git_commit="$CONTROLLER_GIT_COMMIT" \
@@ -162,7 +140,7 @@ if [[ "$SKIP_IMAGE_BUILD" != "1" ]]; then
162140

163141
echo "Pushing aws-gateway-controller image with tag: ${IMG}"
164142

165-
buildah push "${IMG}"
143+
docker push "${IMG}"
166144

167145
if [ $? -ne 0 ]; then
168146
exit 2

0 commit comments

Comments
 (0)