Skip to content

Commit

Permalink
feat: use tini as init process (#9)
Browse files Browse the repository at this point in the history
Signed-off-by: Qi Zhang <[email protected]>
  • Loading branch information
zzzhangqi authored Oct 31, 2023
1 parent 9e8ba99 commit 0239fc9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 76 deletions.
11 changes: 8 additions & 3 deletions Dockerfile
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

Expand All @@ -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

Expand Down
81 changes: 9 additions & 72 deletions release.sh
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
2 changes: 1 addition & 1 deletion runner/init
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ start)
esac

## Run!
exec bash -c "$command"
exec /bin/tini -- bash -c "$command"

0 comments on commit 0239fc9

Please sign in to comment.