Skip to content

Commit a227591

Browse files
authored
Merge pull request #298 from APIParkLab/feature/1.7-liujian
update docker build script
2 parents 9c4590d + b8ebbac commit a227591

File tree

6 files changed

+343
-14
lines changed

6 files changed

+343
-14
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
/.vscode/
88
.air.toml
99
/tmp/
10-
/work
10+
/work
11+
/cmd/

module/service/iml.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,9 @@ func (i *imlServiceModule) Delete(ctx context.Context, id string) error {
746746
Id: id,
747747
})
748748
if err != nil {
749-
return err
749+
if err.Error() != "nil" {
750+
return err
751+
}
750752
}
751753
err = client.Subscribe().Offline(ctx, &gateway.SubscribeRelease{
752754
Service: id,

scripts/Dockerfile

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# 名称:apipark通用镜像
2-
# 创建时间:2022-10-25
3-
FROM centos:7.9.2009
4-
MAINTAINER liujian
2+
FROM alpine:latest
3+
4+
RUN sed -i 's|https://dl-cdn.alpinelinux.org/alpine|https://mirrors.aliyun.com/alpine|g' /etc/apk/repositories \
5+
&& apk update \
6+
&& apk add --no-cache curl tzdata bind-tools
57

68
ENV TZ=Asia/Shanghai
7-
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
9+
10+
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
11+
&& echo "Asia/Shanghai" > /etc/timezone
812

913
ARG APP
1014

scripts/docker_build.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ BuildMode=$3
1010
if [[ "${BuildMode}" == "" ]];then
1111
BuildMode="all"
1212
fi
13+
14+
if [[ "${ARCH}" == "" ]];then
15+
ARCH="amd64"
16+
fi
17+
1318
# 编译可执行文件
1419
./scripts/build.sh "cmd" "" "${BuildMode}" ${ARCH}
1520

@@ -22,12 +27,11 @@ mkdir -p scripts/cmd/ && cp cmd/${APP} scripts/cmd/ && cp cmd/apipark_ai_event_l
2227
VERSION=$(gen_version)
2328

2429

25-
if [[ "${ARCH}" == "" ]];then
26-
ARCH="amd64"
27-
fi
2830

29-
OPTIONS=""
30-
if [[ "${ARCH}" == "arm" ]];then
31+
SYS_ARCH=$(arch)
32+
if [[ (${SYS_ARCH} == "aarch64" || ${SYS_ARCH} == "arm64") && $ARCH == "amd64" ]];then
33+
OPTIONS="--platform=linux/amd64"
34+
elif [[ ${SYS_ARCH} == "amd64" && $ARCH == "arm64" ]];then
3135
OPTIONS="--platform=linux/arm64"
3236
fi
3337

scripts/resource/docker_run.sh

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/bin/sh
22

33
set -e
4-
4+
source ./init_config.sh
55

66
OLD_IFS="$IFS"
77
IFS=","
8-
arr=(${REDIS_ADDR})
98
IFS="$OLD_IFS"
109

1110

@@ -21,10 +20,11 @@ echo -e "redis:" >> config.yml
2120
echo -e " user_name: ${REDIS_USER_NAME}" >> config.yml
2221
echo -e " password: ${REDIS_PWD}" >> config.yml
2322
echo -e " addr: " >> config.yml
24-
for s in ${arr[@]}
23+
for s in $REDIS_ADDR
2524
do
2625
echo -e " - $s" >> config.yml
2726
done
27+
2828
echo -e "nsq:" >> config.yml
2929
echo -e " addr: ${NSQ_ADDR}" >> config.yml
3030
echo -e " topic_prefix: ${NSQ_TOPIC_PREFIX}" >> config.yml
@@ -38,5 +38,31 @@ echo -e " log_period: ${ERROR_PERIOD}" >> config.yml
3838

3939
cat config.yml
4040
nohup ./apipark >> run.log 2>&1 &
41+
wait_for_apipark
42+
4143
nohup ./apipark_ai_event_listen >> run.log 2>&1 &
44+
45+
if [[ ${Init} == "true" ]];then
46+
login_apipark
47+
r=$(is_init)
48+
if [[ $r == "true" ]];then
49+
echo "Already initialized, skipping initialization."
50+
exit 0
51+
fi
52+
wait_for_influxdb
53+
54+
wait_for_apinto
55+
set_cluster
56+
57+
wait_for_influxdb
58+
set_influxdb
59+
60+
set_loki
61+
set_nsq
62+
set_openapi_config
63+
# 重启apipark
64+
kill -9 $(pgrep apipark)
65+
nohup ./apipark >> run.log 2>&1 &
66+
fi
67+
4268
tail -F run.log

0 commit comments

Comments
 (0)