-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Qi Zhang <[email protected]>
- Loading branch information
Showing
3 changed files
with
18 additions
and
76 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,5 +1,5 @@ | ||
FROM registry.cn-hangzhou.aliyuncs.com/goodrain/stack-image:22 | ||
LABEL MAINTAINER ="guox <[email protected]>" | ||
ARG RELEASE_DESC | ||
|
||
ENV TZ=Asia/Shanghai | ||
|
||
|
@@ -18,11 +18,16 @@ RUN mkdir /app \ | |
WORKDIR /app | ||
|
||
# download webapp-runner for java-war | ||
RUN wget http://buildpack.rainbond.com/java/webapp-runner/webapp-runner-8.5.38.0.jar -O /opt/webapp-runner.jar | ||
RUN wget http://buildpack.rainbond.com/java/webapp-runner/webapp-runner-8.5.38.0.jar -O /opt/webapp-runner.jar && \ | ||
if [ $(arch) = "arm64" ] || [ $(arch) = "aarch64" ]; then \ | ||
wget https://pkg.goodrain.com/pkg/tini/v0.19.0/tini-arm -O /bin/tini && chmod +x /bin/tini; \ | ||
else \ | ||
wget https://pkg.goodrain.com/pkg/tini/v0.19.0/tini -O /bin/tini && chmod +x /bin/tini; \ | ||
fi | ||
|
||
# add default port to expose (can be overridden) | ||
ENV PORT 5000 | ||
ENV RELEASE_DESC=__RELEASE_DESC__ | ||
ENV RELEASE_DESC=${RELEASE_DESC} | ||
|
||
EXPOSE 5000 | ||
|
||
|
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,79 +1,16 @@ | ||
#!/bin/bash | ||
set -xe | ||
|
||
# get current branch | ||
# the tag of image, will be selected from : | ||
# 1. custom $RELEASE_VERSION | ||
# 2. $brach_name | ||
# 3. current version like "v5.6.0-release" | ||
brach_name=$(git symbolic-ref --short -q HEAD) | ||
if [ $brach_name == "master" ]; then | ||
release_version=${RELEASE_VERSION:-"v5.7.0-release"} | ||
else | ||
release_version=${RELEASE_VERSION:-${brach_name}} | ||
fi | ||
|
||
build_time=$(date +%F-%H) | ||
git_commit=$(git log -n 1 --pretty --format=%h) | ||
release_desc=${VERSION}-${git_commit}-${build_time} | ||
|
||
release_desc=${release_version}-${git_commit} | ||
DOMESTIC_BASE_NAME=${DOMESTIC_BASE_NAME:-'registry.cn-hangzhou.aliyuncs.com'} | ||
DOMESTIC_NAMESPACE=${DOMESTIC_NAMESPACE:-'goodrain'} | ||
|
||
build::local() { | ||
sed "s/__RELEASE_DESC__/${release_desc}/" Dockerfile >Dockerfile.release | ||
docker build -t goodrain.me/runner -f Dockerfile.release . | ||
rm -rf Dockerfile.release | ||
if [ "$1" == "push" ]; then | ||
docker push goodrain.me/runner | ||
fi | ||
} | ||
|
||
build::public() { | ||
docker tag goodrain.me/runner rainbond/runner:${release_version} | ||
docker tag goodrain.me/runner rainbond/runner | ||
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then | ||
docker push rainbond/runner:${release_version} | ||
docker push rainbond/runner | ||
fi | ||
if [ "${DOMESTIC_BASE_NAME}" ]; then | ||
new_tag="${DOMESTIC_BASE_NAME}/${DOMESTIC_NAMESPACE}/runner:${release_version}" | ||
# for amd64 and arm64 | ||
if [ $(arch) == "x86_64" ]; then | ||
new_tag=${new_tag} | ||
elif [ $(arch) == "arm64" ] || [ $(arch) == "aarch64" ]; then | ||
new_tag=${new_tag}-arm64 | ||
fi | ||
docker tag goodrain.me/runner "$new_tag" | ||
docker login -u "$DOMESTIC_DOCKER_USERNAME" -p "$DOMESTIC_DOCKER_PASSWORD" "${DOMESTIC_BASE_NAME}" | ||
docker push "$new_tag" | ||
fi | ||
} | ||
PUSH_IMAGE=${PUSH_IMAGE:-'true'} | ||
IMAGE_NAMESPACE=${IMAGE_NAMESPACE:-'rainbond'} | ||
|
||
# create manifest for amd64 and arm64 with same name, push them to aliyun registry. | ||
# this function should run after image pushed. | ||
# manifest will be named like example/runner:v5.5.0-release | ||
# amd64 images will be named like example/runner:v5.5.0-release | ||
# arm64 images will be named like example/runner:v5.5.0-release-arm64 | ||
# manifest list can not be recreated except the image example/runner:v5.5.0-release has been re-pushed. | ||
build::manifest() { | ||
new_tag="${DOMESTIC_BASE_NAME}/${DOMESTIC_NAMESPACE}/runner:${release_version}" | ||
docker login -u "$DOMESTIC_DOCKER_USERNAME" -p "$DOMESTIC_DOCKER_PASSWORD" "${DOMESTIC_BASE_NAME}" | ||
docker manifest create $new_tag $new_tag $new_tag-arm64 | ||
docker manifest annotate $new_tag $new_tag --os linux --arch amd64 | ||
docker manifest annotate $new_tag $new_tag-arm64 --os linux --arch arm64 --variant v8 | ||
docker manifest push $new_tag | ||
docker manifest rm $new_tag | ||
} | ||
docker build --build-arg RELEASE_DESC="${release_desc}" -t "$IMAGE_NAMESPACE"/runner:"$VERSION" . | ||
|
||
case $1 in | ||
local) | ||
build::local ${@:2} | ||
;; | ||
manifest) | ||
build::manifest | ||
;; | ||
*) | ||
build::local | ||
build::public | ||
;; | ||
esac | ||
if [ "$PUSH_IMAGE" == "true" ]; then | ||
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" | ||
docker push "$IMAGE_NAMESPACE"/runner:"$VERSION" | ||
fi |
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 |
---|---|---|
|
@@ -94,4 +94,4 @@ start) | |
esac | ||
|
||
## Run! | ||
exec bash -c "$command" | ||
exec /bin/tini -- bash -c "$command" |