Skip to content

Commit

Permalink
Merge pull request #5 from goodrain/dev
Browse files Browse the repository at this point in the history
add drone CI
  • Loading branch information
dazuimao1990 authored Jan 27, 2022
2 parents ac458b9 + 14a81ae commit 517e5b9
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 4 deletions.
115 changes: 115 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
kind: pipeline
type: docker
name: build arm64
platform:
os: linux
arch: arm64
trigger:
event:
include:
- custom
node:
city: sydney
steps:
- name: build&push runner image
image: rainbond/docker:dind
volumes:
- name: dockersock
path: /var/run/docker.sock
privileged: true
environment:
RELEASE_VERSION: dev
DOMESTIC_DOCKER_USERNAME:
from_secret: domestic_docker_username
DOMESTIC_DOCKER_PASSWORD:
from_secret: domestic_docker_password
commands:
- ./release.sh
volumes:
- name: dockersock
host:
path: /var/run/docker.sock

---
kind: pipeline
type: docker
name: build amd64
platform:
os: linux
arch: amd64
trigger:
event:
include:
- custom
node:
city: shanghai
clone:
disable: true
steps:
- name: clone
image: alpine/git
commands:
- git clone -b $DRONE_BRANCH --depth 1 https://ghproxy.com/https://github.com/goodrain/runner.git .
- name: build&push runner image
image: registry.cn-hangzhou.aliyuncs.com/goodrain/docker:dind-amd64
volumes:
- name: dockersock
path: /var/run/docker.sock
privileged: true
environment:
RELEASE_VERSION: dev
DOMESTIC_DOCKER_USERNAME:
from_secret: domestic_docker_username
DOMESTIC_DOCKER_PASSWORD:
from_secret: domestic_docker_password
commands:
- ./release.sh
volumes:
- name: dockersock
host:
path: /var/run/docker.sock

---
kind: pipeline
type: docker
name: push manifest
platform:
os: linux
arch: amd64
trigger:
event:
include:
- custom
node:
city: shanghai
clone:
disable: true
steps:
- name: clone
image: alpine/git
environment:
RELEASE_VERSION: dev
commands:
- git clone -b $RELEASE_VERSION --depth 1 https://ghproxy.com/https://github.com/goodrain/runner.git .
- name: push manifest
image: registry.cn-hangzhou.aliyuncs.com/goodrain/docker:dind-amd64
volumes:
- name: dockersock
path: /var/run/docker.sock
privileged: true
environment:
RELEASE_VERSION: dev
DOMESTIC_DOCKER_USERNAME:
from_secret: domestic_docker_username
DOMESTIC_DOCKER_PASSWORD:
from_secret: domestic_docker_password
DOCKER_CLI_EXPERIMENTAL: enabled
commands:
- ./release.sh manifest
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
depends_on:
- build arm64
- build amd64
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN mkdir /app \
WORKDIR /app

# download webapp-runner for java-war
RUN wget http://buildpack.oss-cn-shanghai.aliyuncs.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

# add default port to expose (can be overridden)
ENV PORT 5000
Expand Down
7 changes: 4 additions & 3 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -xe

release_version=v5.5.0-release
release_version=${RELEASE_VERSION:-"v5.5.0-release"}
git_commit=$(git log -n 1 --pretty --format=%h)

release_desc=${release_version}-${git_commit}
Expand Down Expand Up @@ -30,7 +30,7 @@ build::public() {
# for amd64 and arm64
if [ $(arch) == "x86_64" ]; then
new_tag=${new_tag}
elif [ $(arch) == "arm64" ]; then
elif [ $(arch) == "arm64" ] || [ $(arch) == "aarch64" ]; then
new_tag=${new_tag}-arm64
fi
docker tag goodrain.me/runner "$new_tag"
Expand All @@ -47,11 +47,12 @@ build::public() {
# 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 manifest rm $new_tag
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
}

case $1 in
Expand Down

0 comments on commit 517e5b9

Please sign in to comment.