Skip to content

Commit

Permalink
Build swagger-codegen-cli image for arm64 (#65)
Browse files Browse the repository at this point in the history
* Build swagger-codegen-cli for arm64

Signed-off-by: Andrew Dye <[email protected]>

* Refactor tagging

Signed-off-by: Andrew Dye <[email protected]>

* Fix tag args

Signed-off-by: Andrew Dye <[email protected]>

Signed-off-by: Andrew Dye <[email protected]>
  • Loading branch information
andrewwdye authored Sep 23, 2022
1 parent 07f593e commit 7138bf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion flytetools/swagger-codegen-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/maven:3.6.1-jdk-8 AS builder
FROM docker.io/maven:3.8.6-jdk-8 AS builder
WORKDIR /tmp
RUN git clone https://github.com/swagger-api/swagger-codegen.git
WORKDIR /tmp/swagger-codegen
Expand Down
34 changes: 14 additions & 20 deletions flytetools/swagger-codegen-cli/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,36 @@ echo ""
GIT_SHA=$(git rev-parse HEAD)
RELEASE_SEMVER=$(git describe --tags --exact-match "$GIT_SHA" 2>/dev/null) || true

TAG_ARGS="-t $IMAGE_NAME:latest"
PUSH_ARG=""

if [ -n "$REGISTRY" ]; then
# Do not push if there are unstaged git changes
CHANGED=$(git status --porcelain)
if [ -n "$CHANGED" ]; then
echo "Please commit git changes before pushing to a registry"
exit 1
fi
fi

docker build -t "$IMAGE_NAME:latest" .
echo "$IMAGE_NAME:latest built locally."


if [ -n "$REGISTRY" ]; then

if [ -n "${DOCKER_REGISTRY_PASSWORD}" ]; then
docker login --username="$DOCKER_REGISTRY_USERNAME" --password="$DOCKER_REGISTRY_PASSWORD"
fi

SHA_IMAGE_TAG="${REGISTRY}/${IMAGE_NAME}:${GIT_SHA}"

docker tag "${IMAGE_NAME}:latest" "$SHA_IMAGE_TAG"

docker push "$SHA_IMAGE_TAG"
echo "${SHA_IMAGE_TAG} pushed to remote"
TAG_ARGS="$TAG_ARGS -t $SHA_IMAGE_TAG"
PUSH_ARG="--push"

if [ -n "$RELEASE_SEMVER" ]; then

SEMVER_IMAGE_TAG="${REGISTRY}/${IMAGE_NAME}:${RELEASE_SEMVER}"

docker tag "${IMAGE_NAME}:latest" "$SEMVER_IMAGE_TAG"
docker push "$SEMVER_IMAGE_TAG"
echo "${SEMVER_IMAGE_TAG} pushed to remote"
TAG_ARGS="$TAG_ARGS -t $SEMVER_IMAGE_TAG"
fi

fi

echo ""
echo "success"
docker buildx create --name swagger-codegen-cli-builder --driver docker-container --bootstrap --use
docker buildx build --platform=linux/amd64,linux/arm64 $TAG_ARGS $PUSH_ARG .
docker buildx rm swagger-codegen-cli-builder

echo "Built images"
if [ -n "$PUSH_ARG" ]; then
echo "Pushed images to repository '${REGISTRY}'"
fi

0 comments on commit 7138bf5

Please sign in to comment.