-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This copies the docker build script from dockernetes, and changes the name of the docker image from flytetools to just swagger-codegen-cli.
- Loading branch information
1 parent
673100c
commit 48cdd0e
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export REPOSITORY=swagger-codegen-cli | ||
|
||
.PHONY: docker_build | ||
docker_build: | ||
@docker build -f swagger-codegen-cli/Dockerfile --tag docker.io/lyft/flytetools:swagger-codegen-cli swagger-codegen-cli | ||
|
||
IMAGE_NAME=$$REPOSITORY ./docker_build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
set -e | ||
|
||
echo "" | ||
echo "------------------------------------" | ||
echo " DOCKER BUILD" | ||
echo "------------------------------------" | ||
echo "" | ||
|
||
GIT_SHA=$(git rev-parse HEAD) | ||
RELEASE_SEMVER=$(git describe --tags --exact-match "$GIT_SHA" 2>/dev/null) || true | ||
|
||
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" | ||
|
||
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" | ||
fi | ||
|
||
fi | ||
|
||
echo "" | ||
echo "success" |