Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
75cdfa7d
W
wechaty
项目概览
weixin_46011646
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
75cdfa7d
编写于
7月 06, 2020
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix docker deployg
上级
42320f76
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
103 addition
and
105 deletion
+103
-105
.github/workflows/docker.yml
.github/workflows/docker.yml
+4
-4
IMAGE
IMAGE
+0
-1
scripts/deploy-docker.sh
scripts/deploy-docker.sh
+0
-48
scripts/docker.sh
scripts/docker.sh
+99
-52
未找到文件。
.github/workflows/docker.yml
浏览文件 @
75cdfa7d
...
...
@@ -30,10 +30,10 @@ jobs:
steps
:
-
uses
:
actions/checkout@v2
-
name
:
Install Dependencies
run
:
make install
run
:
npm install
-
name
:
Build the Docker image
run
:
./scripts/docker.sh build
-
name
:
Login to DockerHub Registry
run
:
echo ${{ secrets.DOCKER_PERSONAL_ACCESS_TOKEN }} | docker login -u zixia --password-stdin
-
name
:
Build the Docker image
run
:
docker build -t artifact_image .
-
name
:
Deploy to Docker Hub
run
:
bash -x ./scripts/deploy-docker.sh artifact_image
run
:
./scripts/docker.sh deploy
IMAGE
已删除
100644 → 0
浏览文件 @
42320f76
zixia/wechaty
scripts/deploy-docker.sh
已删除
100644 → 0
浏览文件 @
42320f76
#!/usr/bin/env bash
set
-eo
pipefail
function
deployVersion
()
{
SEMVER_MAJOR
=
$(
node
-e
"console.log(require('semver').major('
$VERSION
'))"
)
SEMVER_MINOR
=
$(
node
-e
"console.log(require('semver').minor('
$VERSION
'))"
)
TAG
=
"
$SEMVER_MAJOR
.
$SEMVER_MINOR
"
echo
"Deploying TAG=
$TAG
"
docker tag
"
${
ARTIFACT_IMAGE
}
"
"
${
IMAGE
}
:
${
TAG
}
"
docker push
"
${
IMAGE
}
:
${
TAG
}
"
}
function
deployLatest
()
{
echo
"Deploying IMAGE=
$IMAGE
latest"
docker tag
"
${
ARTIFACT_IMAGE
}
"
"
${
IMAGE
}
:latest"
docker push
"
${
IMAGE
}
:latest"
}
function
deployNext
()
{
echo
"Deploying IMAGE=
$IMAGE
next"
docker tag
"
${
ARTIFACT_IMAGE
}
"
"
${
IMAGE
}
:next"
docker push
"
${
IMAGE
}
:next"
}
function
main
()
{
if
[
-z
"
$1
"
]
;
then
>
&2
echo
-e
"Missing argument.
\n
Usage:
$0
ARTIFACT_IMAGE"
exit
1
fi
ARTIFACT_IMAGE
=
$1
IMAGE
=
$(
cat
IMAGE
)
VERSION
=
$(
cat
VERSION
)
deployVersion
if
npx
--package
@chatie/semver semver-is-prod
"
$VERSION
"
;
then
deployLatest
else
deployLatest
fi
}
main
"
$@
"
scripts/docker.sh
浏览文件 @
75cdfa7d
#!/bin/bash
#
# 1. CircleCI with `Btrfs volume error`
# https://circleci.com/docs/docker-btrfs-error/
#
set
-e
imageName
=
'wechaty:test'
set
-eo
pipefail
# Shellcheck - https://github.com/koalaman/shellcheck/wiki/SC2086
options
=(
'--rm'
)
[
-n
"
$CIRCLECI
"
]
&&
options
=(
'--rm=false'
)
[
-n
"
$NO_CACHE
"
]
&&
options+
=(
'--no-cache'
)
function
deployVersion
()
{
ARTIFACT_IMAGE
=
$1
IMAGE
=
$2
VERSION
=
$3
declare
-i
ret
=
0
SEMVER_MAJOR
=
$(
node
-e
"console.log(require('semver').major('
$VERSION
'))"
)
SEMVER_MINOR
=
$(
node
-e
"console.log(require('semver').minor('
$VERSION
'))"
)
case
"
$1
"
in
TAG
=
"
$SEMVER_MAJOR
.
$SEMVER_MINOR
"
echo
"Deploying TAG=
$TAG
"
docker tag
"
${
ARTIFACT_IMAGE
}
"
"
${
IMAGE
}
:
${
TAG
}
"
docker push
"
${
IMAGE
}
:
${
TAG
}
"
}
function
deployLatest
()
{
ARTIFACT_IMAGE
=
$1
IMAGE
=
$2
echo
"Deploying IMAGE=
$IMAGE
latest"
docker tag
"
${
ARTIFACT_IMAGE
}
"
"
${
IMAGE
}
:latest"
docker push
"
${
IMAGE
}
:latest"
}
function
deployNext
()
{
ARTIFACT_IMAGE
=
$1
IMAGE
=
$2
echo
"Deploying IMAGE=
$IMAGE
next"
docker tag
"
${
ARTIFACT_IMAGE
}
"
"
${
IMAGE
}
:next"
docker push
"
${
IMAGE
}
:next"
}
function
main
()
{
artifactImage
=
'wechaty:test'
dockerImage
=
'zixia/wechaty'
# Shellcheck - https://github.com/koalaman/shellcheck/wiki/SC2086
options
=(
'--rm'
)
[
-n
"
$NO_CACHE
"
]
&&
options+
=(
'--no-cache'
)
declare
-i
ret
=
0
case
"
$1
"
in
build
|
''
)
echo
docker build
"
${
options
[@]
}
"
-t
"
$imageNam
e
"
.
exec
docker build
"
${
options
[@]
}
"
-t
"
$imageNam
e
"
.
echo
docker build
"
${
options
[@]
}
"
-t
"
$artifactImag
e
"
.
exec
docker build
"
${
options
[@]
}
"
-t
"
$artifactImag
e
"
.
# echo docker build "${options[@]}" -t "${imageNam
e}:onbuild" -f Dockerfile.onbuild .
# exec docker build "${options[@]}" -t "${imageNam
e}:onbuild" -f Dockerfile.onbuild .
# echo docker build "${options[@]}" -t "${artifactImag
e}:onbuild" -f Dockerfile.onbuild .
# exec docker build "${options[@]}" -t "${artifactImag
e}:onbuild" -f Dockerfile.onbuild .
ret
=
$?
;;
...
...
@@ -28,27 +59,43 @@ case "$1" in
test
)
echo
"Testing the docker image behaviors to make sure it works as expected..."
echo
"bats tests/"
IMAGE_NAME
=
"
$imageNam
e
"
bats tests/
IMAGE_NAME
=
"
$artifactImag
e
"
bats tests/
echo
echo
echo
docker run
-i
"
${
options
[@]
}
"
-v
/dev/shm:/dev/shm
"
$imageNam
e
"
test
exec
docker run
-i
"
${
options
[@]
}
"
-v
/dev/shm:/dev/shm
"
$imageNam
e
"
test
echo
docker run
-i
"
${
options
[@]
}
"
-v
/dev/shm:/dev/shm
"
$artifactImag
e
"
test
exec
docker run
-i
"
${
options
[@]
}
"
-v
/dev/shm:/dev/shm
"
$artifactImag
e
"
test
ret
=
$?
;;
deploy
)
version
=
$(
npx pkg-jq
-r
.version
)
deployVersion
"
$artifactImage
"
"
$dockerImage
"
"
$version
"
if
npx
--package
@chatie/semver semver-is-prod
"
$VERSION
"
;
then
deployLatest
"
$artifactImage
"
"
$dockerImage
"
else
deployNext
"
$artifactImage
"
"
$dockerImage
"
fi
;;
clean
)
docker ps
-a
|
grep
Exited |
awk
'{print $1}'
| xargs docker
rm
||
true
docker images |
grep
none |
awk
'{print $3}'
| xargs docker rmi
;;
*
)
echo
docker run
-ti
"
${
options
[@]
}
"
-v
/dev/shm:/dev/shm
"
$imageNam
e
"
"
$@
"
exec
docker run
-ti
"
${
options
[@]
}
"
-v
/dev/shm:/dev/shm
"
$imageNam
e
"
"
$@
"
echo
docker run
-ti
"
${
options
[@]
}
"
-v
/dev/shm:/dev/shm
"
$artifactImag
e
"
"
$@
"
exec
docker run
-ti
"
${
options
[@]
}
"
-v
/dev/shm:/dev/shm
"
$artifactImag
e
"
"
$@
"
;;
esac
esac
[
"
$ret
"
-ne
0
]
&&
{
[
"
$ret
"
-ne
0
]
&&
{
echo
"ERROR: exec return
$ret
???"
exit
$ret
}
return
$ret
}
main
"
$@
"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录