From f992b569679dbe72dc4b01e978a52221dbbe9677 Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 09:00:08 +0800 Subject: [PATCH 01/16] add build.sh && build-web.sh --- .gitignore | 1 + build-web.sh | 8 ++++++ build.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 build-web.sh create mode 100644 build.sh diff --git a/.gitignore b/.gitignore index 43174571..f1d63e6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /logs/ +web npm-debug.log yarn-error.log node_modules diff --git a/build-web.sh b/build-web.sh new file mode 100644 index 00000000..249584b5 --- /dev/null +++ b/build-web.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +WORKBASE=/home/jenkins/go/src/infini.sh/console +if [ ! -d $WORKBASE/web ]; then + git clone ssh://git@git.infini.ltd:64221/infini/console-ui.git web +fi +cd $WORKBASE/web && git pull origin master && git stash +cnpm install && cnpm run build diff --git a/build.sh b/build.sh new file mode 100644 index 00000000..3581bcd4 --- /dev/null +++ b/build.sh @@ -0,0 +1,77 @@ + #!/bin/bash + +#init +PNAME=console +WORKBASE=/home/jenkins/go/src/infini.sh +WORKDIR=$WORKBASE/$PNAME +export DOCKER_CLI_EXPERIMENTAL=enabled + +#clean all +cd $WORKSPACE && git clean -fxd + +#pull code +cd $WORKDIR && git clean -fxd +git stash && git pull origin master + + #build +make clean config build-linux +make config build-arm +make config build-darwin +make config build-win +GOROOT="/infini/go-pkgs/go-loongarch" GOPATH="/home/jenkins/go" make build-linux-loong64 + +#copy-configs +cp -rf $WORKBASE/framework/LICENSE $WORKDIR/bin && cat $WORKBASE/framework/NOTICE $WORKDIR/NOTICE > $WORKDIR/bin/NOTICE + +cd $WORKDIR/bin +for t in 386 amd64 arm64 armv5 armv6 armv7 loong64 mips mips64 mips64le mipsle riscv64 ; do + echo "package-linux-$t" + tar zcf ${WORKSPACE}/$PNAME-$VERSION-$BUILD_NUMBER-linux-$t.tar.gz "${PNAME}-linux-$t" $PNAME.yml LICENSE NOTICE +done + +for t in mac-amd64 mac-arm64 windows-amd64 windows-386 ; do + echo "package-$t" + cd $WORKDIR/bin && zip -qr ${WORKSPACE}/$PNAME-$VERSION-$BUILD_NUMBER-$t.zip $PNAME-$t $PNAME.yml LICENSE NOTICE +done + +#build image & push +for t in amd64 arm64 ; do + + cat <Dockerfile +FROM --platform=linux/$t alpine:3.16.5 +MAINTAINER "hardy " +ARG APP_NAME=$PNAME +ARG APP_HOME=/opt/\${APP_NAME} +ENV APP=\${APP_NAME} +WORKDIR \${APP_HOME} + +COPY ["$PNAME-linux-$t", "$PNAME.yml", "\${APP_HOME}/"] + +CMD ["/opt/$PNAME/${PNAME}-linux-$t"] +EOF + + docker buildx build -t infinilabs/$PNAME-$t:latest --platform=linux/$t -o type=docker . + + docker tag infinilabs/$PNAME-$t:latest infinilabs/$PNAME-t:$VERSION-$BUILD_NUMBE + docker push infinilabs/$PNAME-$t:latest + docker push infinilabs/$PNAME-$t:$VERSION-$BUILD_NUMBER +done + +#composite tag +docker buildx imagetools create -t infinilabs/$PNAME:latest \ + infinilabs/$PNAME-arm64:latest \ + infinilabs/$PNAME-amd64:latest + +docker buildx imagetools create -t infinilabs/$PNAME:$VERSION-$BUILD_NUMBER \ + infinilabs/$PNAME-arm64:$VERSION-$BUILD_NUMBER \ + infinilabs/$PNAME-amd64:$VERSION-$BUILD_NUMBER + +#git reset +cd $WORKSPACE && git reset --hard +cd $WORKDIR && git reset --hard + +#clean weeks ago image +NEEDCLEN=$(docker images |grep "$PNAME" |grep "weeks ago") +if [ ! -z "$NEEDCLEN" ]; then + docker images |grep "$PNAME" |grep "weeks ago" |awk '{print $3}' |xargs docker rmi +fi From 6fbd5a04a322a3ff3504e24adcfce5280cbf4510 Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 11:05:51 +0800 Subject: [PATCH 02/16] fix build number --- build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.sh b/build.sh index 3581bcd4..22277b46 100644 --- a/build.sh +++ b/build.sh @@ -4,6 +4,10 @@ PNAME=console WORKBASE=/home/jenkins/go/src/infini.sh WORKDIR=$WORKBASE/$PNAME + +if [[ $VERSION =~ NIGHTLY ]]; then + BUILD_NUMBER=$BUILD_DAY +fi export DOCKER_CLI_EXPERIMENTAL=enabled #clean all From 3a99ae0d731db720d7d44d46d9965dcc992e4576 Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 12:19:31 +0800 Subject: [PATCH 03/16] fix docker build tag --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 22277b46..b69c58f5 100644 --- a/build.sh +++ b/build.sh @@ -56,7 +56,7 @@ EOF docker buildx build -t infinilabs/$PNAME-$t:latest --platform=linux/$t -o type=docker . - docker tag infinilabs/$PNAME-$t:latest infinilabs/$PNAME-t:$VERSION-$BUILD_NUMBE + docker tag infinilabs/$PNAME-$t:latest infinilabs/$PNAME-$t:$VERSION-$BUILD_NUMBE docker push infinilabs/$PNAME-$t:latest docker push infinilabs/$PNAME-$t:$VERSION-$BUILD_NUMBER done From e4a47d2f0d3d92d40c1137dfdce93b2ce6bed6d8 Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 21:29:27 +0800 Subject: [PATCH 04/16] fix .public path --- build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.sh b/build.sh index b69c58f5..8579c4dc 100644 --- a/build.sh +++ b/build.sh @@ -8,6 +8,12 @@ WORKDIR=$WORKBASE/$PNAME if [[ $VERSION =~ NIGHTLY ]]; then BUILD_NUMBER=$BUILD_DAY fi +if [[ -d $WORKBASE/.public ]]; then + rm -rf $WORKBASE/.public +fi +if [[ -d $WORKDIR/.public ]]; then + mv $WORKDIR/.public $WORKBASE +fi export DOCKER_CLI_EXPERIMENTAL=enabled #clean all From 517659ae3d811af0b8ce4cd2d0aa9a036b0e4d80 Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 21:43:26 +0800 Subject: [PATCH 05/16] fix docker tag --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 8579c4dc..7c8fb232 100644 --- a/build.sh +++ b/build.sh @@ -62,7 +62,7 @@ EOF docker buildx build -t infinilabs/$PNAME-$t:latest --platform=linux/$t -o type=docker . - docker tag infinilabs/$PNAME-$t:latest infinilabs/$PNAME-$t:$VERSION-$BUILD_NUMBE + docker tag infinilabs/$PNAME-$t:latest infinilabs/$PNAME-$t:$VERSION-$BUILD_NUMBER docker push infinilabs/$PNAME-$t:latest docker push infinilabs/$PNAME-$t:$VERSION-$BUILD_NUMBER done From 64ce84c731fdcd9e8dca2d07fba201388ca04b7c Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 22:32:51 +0800 Subject: [PATCH 06/16] fix .public --- build-web.sh | 14 ++++++++++++-- build.sh | 12 +----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build-web.sh b/build-web.sh index 249584b5..e5c33105 100644 --- a/build-web.sh +++ b/build-web.sh @@ -1,8 +1,18 @@ #!/bin/bash WORKBASE=/home/jenkins/go/src/infini.sh/console + +if [ -d $WORKBASE/.public ]; then + rm -rf $WORKBASE/.public +fi + if [ ! -d $WORKBASE/web ]; then git clone ssh://git@git.infini.ltd:64221/infini/console-ui.git web fi -cd $WORKBASE/web && git pull origin master && git stash -cnpm install && cnpm run build + +cd $WORKBASE/web +git pull origin master + +cnpm install + +cnpm run build diff --git a/build.sh b/build.sh index 7c8fb232..834c6b7e 100644 --- a/build.sh +++ b/build.sh @@ -8,12 +8,6 @@ WORKDIR=$WORKBASE/$PNAME if [[ $VERSION =~ NIGHTLY ]]; then BUILD_NUMBER=$BUILD_DAY fi -if [[ -d $WORKBASE/.public ]]; then - rm -rf $WORKBASE/.public -fi -if [[ -d $WORKDIR/.public ]]; then - mv $WORKDIR/.public $WORKBASE -fi export DOCKER_CLI_EXPERIMENTAL=enabled #clean all @@ -35,18 +29,15 @@ cp -rf $WORKBASE/framework/LICENSE $WORKDIR/bin && cat $WORKBASE/framework/NOTIC cd $WORKDIR/bin for t in 386 amd64 arm64 armv5 armv6 armv7 loong64 mips mips64 mips64le mipsle riscv64 ; do - echo "package-linux-$t" tar zcf ${WORKSPACE}/$PNAME-$VERSION-$BUILD_NUMBER-linux-$t.tar.gz "${PNAME}-linux-$t" $PNAME.yml LICENSE NOTICE done for t in mac-amd64 mac-arm64 windows-amd64 windows-386 ; do - echo "package-$t" cd $WORKDIR/bin && zip -qr ${WORKSPACE}/$PNAME-$VERSION-$BUILD_NUMBER-$t.zip $PNAME-$t $PNAME.yml LICENSE NOTICE done #build image & push for t in amd64 arm64 ; do - cat <Dockerfile FROM --platform=linux/$t alpine:3.16.5 MAINTAINER "hardy " @@ -61,9 +52,8 @@ CMD ["/opt/$PNAME/${PNAME}-linux-$t"] EOF docker buildx build -t infinilabs/$PNAME-$t:latest --platform=linux/$t -o type=docker . - - docker tag infinilabs/$PNAME-$t:latest infinilabs/$PNAME-$t:$VERSION-$BUILD_NUMBER docker push infinilabs/$PNAME-$t:latest + docker tag infinilabs/$PNAME-$t:latest infinilabs/$PNAME-$t:$VERSION-$BUILD_NUMBER docker push infinilabs/$PNAME-$t:$VERSION-$BUILD_NUMBER done From ea27bffbc73d9612c783ffa38f3722a373ee1a6a Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 22:39:41 +0800 Subject: [PATCH 07/16] fix .public --- build-web.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-web.sh b/build-web.sh index e5c33105..2d97639b 100644 --- a/build-web.sh +++ b/build-web.sh @@ -15,4 +15,6 @@ git pull origin master cnpm install -cnpm run build +cnpm run build >/dev/null + +mv $WORKBASE/web/.public $WORKBASE From 1923341f9a31cc1871d75bb6b74f201537eaaa2a Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 22:42:39 +0800 Subject: [PATCH 08/16] fix .public --- build-web.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-web.sh b/build-web.sh index 2d97639b..982ea448 100644 --- a/build-web.sh +++ b/build-web.sh @@ -15,6 +15,6 @@ git pull origin master cnpm install -cnpm run build >/dev/null +cnpm run --silent build mv $WORKBASE/web/.public $WORKBASE From 5ab35df3d8e80744fff97d0312db6f617c68b274 Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 22:47:45 +0800 Subject: [PATCH 09/16] fix .public --- build-web.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build-web.sh b/build-web.sh index 982ea448..6614a4a4 100644 --- a/build-web.sh +++ b/build-web.sh @@ -3,6 +3,7 @@ WORKBASE=/home/jenkins/go/src/infini.sh/console if [ -d $WORKBASE/.public ]; then + echo "clean exists .pulbic folder." rm -rf $WORKBASE/.public fi @@ -11,10 +12,11 @@ if [ ! -d $WORKBASE/web ]; then fi cd $WORKBASE/web +echo "build console ui to .public." git pull origin master -cnpm install +cnpm install --quiet -cnpm run --silent build +cnpm run build --silent mv $WORKBASE/web/.public $WORKBASE From efd909efe63d7c317eea85d02c95d42ac6897907 Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 22:55:05 +0800 Subject: [PATCH 10/16] fix .public --- build-web.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build-web.sh b/build-web.sh index 6614a4a4..435d608f 100644 --- a/build-web.sh +++ b/build-web.sh @@ -15,8 +15,11 @@ cd $WORKBASE/web echo "build console ui to .public." git pull origin master -cnpm install --quiet +echo "loglevel=silent" > .npmrc -cnpm run build --silent +cnpm install --quiet --no-progress +cnpm run -s build + +echo "move .public to $WORKBAS" mv $WORKBASE/web/.public $WORKBASE From 552807ab77f3565b5a384b10a62a81c7cdcab4bf Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 23:05:14 +0800 Subject: [PATCH 11/16] fix .public clean by git --- .gitignore | 1 + build-web.sh | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index f1d63e6a..67b2654d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /logs/ +.public web npm-debug.log yarn-error.log diff --git a/build-web.sh b/build-web.sh index 435d608f..728f9fd7 100644 --- a/build-web.sh +++ b/build-web.sh @@ -12,14 +12,8 @@ if [ ! -d $WORKBASE/web ]; then fi cd $WORKBASE/web -echo "build console ui to .public." git pull origin master -echo "loglevel=silent" > .npmrc - cnpm install --quiet --no-progress -cnpm run -s build - -echo "move .public to $WORKBAS" -mv $WORKBASE/web/.public $WORKBASE +cnpm run build --quiet From 8a91b8e9f42ec570bb9fc6ae4ecade0e265881fe Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 23:22:48 +0800 Subject: [PATCH 12/16] fix .public clean by git --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 67b2654d..0205ca66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /logs/ .public +.public/ web npm-debug.log yarn-error.log From 32573649b570272444d6ff76ecc3281e9b42c5de Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 23:23:08 +0800 Subject: [PATCH 13/16] fix .public clean by git --- build-web.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-web.sh b/build-web.sh index 728f9fd7..49fb7fdc 100644 --- a/build-web.sh +++ b/build-web.sh @@ -16,4 +16,4 @@ git pull origin master cnpm install --quiet --no-progress -cnpm run build --quiet +cnpm run build --quiet &>/dev/null From 33c58de538ee97d1be688325b8ed97378ef8fe4c Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 23:29:48 +0800 Subject: [PATCH 14/16] fix .public clean by git --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0205ca66..83b28af1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ /logs/ -.public .public/ -web +.public/static npm-debug.log yarn-error.log node_modules From dd9dae398ff92ebdadc12d3851c307fdf073296b Mon Sep 17 00:00:00 2001 From: hardy Date: Sat, 3 Jun 2023 23:46:19 +0800 Subject: [PATCH 15/16] fix .public clean by git --- .gitignore | 2 -- build.sh | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 83b28af1..43174571 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ /logs/ -.public/ -.public/static npm-debug.log yarn-error.log node_modules diff --git a/build.sh b/build.sh index 834c6b7e..9ab1189a 100644 --- a/build.sh +++ b/build.sh @@ -14,7 +14,7 @@ export DOCKER_CLI_EXPERIMENTAL=enabled cd $WORKSPACE && git clean -fxd #pull code -cd $WORKDIR && git clean -fxd +cd $WORKDIR && git clean -fxd -e ".public" git stash && git pull origin master #build From 7f01be8bbec1f09b067897737b95a41ae7f563cf Mon Sep 17 00:00:00 2001 From: hardy Date: Sun, 4 Jun 2023 23:05:57 +0800 Subject: [PATCH 16/16] add sw_64 arch --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 9ab1189a..02170ade 100644 --- a/build.sh +++ b/build.sh @@ -22,7 +22,8 @@ make clean config build-linux make config build-arm make config build-darwin make config build-win -GOROOT="/infini/go-pkgs/go-loongarch" GOPATH="/home/jenkins/go" make build-linux-loong64 +GOROOT="/infini/go-pkgs/go-loongarch" PATH=$GOROOT/bin:$PATH make build-linux-loong64 +#GOROOT="/infini/go-pkgs/go-swarch" PATH=$GOROOT/bin:$PATH make build-linux-sw64 #copy-configs cp -rf $WORKBASE/framework/LICENSE $WORKDIR/bin && cat $WORKBASE/framework/NOTICE $WORKDIR/NOTICE > $WORKDIR/bin/NOTICE