Skip to content

Commit

Permalink
update: create server run script
Browse files Browse the repository at this point in the history
- fix ids_server curl missing error
  • Loading branch information
Medicean committed Apr 10, 2018
1 parent 83bc8bf commit ae427d3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Dockerfile-server
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ RUN go build -o ./server/server --ldflags='-w -s -linkmode external -extldflags
FROM alpine
MAINTAINER Jason Cooper "mrderek@protonmail.com"
COPY --from=builder /go/src/yulong-hids/server/server .
COPY --from=builder /go/src/yulong-hids/server/.dockerstart.sh /start.sh
RUN apk update
RUN apk upgrade
RUN apk add ca-certificates && update-ca-certificates
RUN apk add --update tzdata
RUN apk add curl
ENV TZ=Asia/Shanghai
RUN rm -rf /var/cache/apk/*
RUN chmod +x server
ENTRYPOINT for i in $(seq 1 5);do echo "Wait for ElasticSearch Start...$i"; curl -s http://$IDS_ELASTICSEARCH> /dev/null ; if [ $? = 0 ];then break; fi; sleep 1; if [ $i == 5 ];then echo "Too much retry, exit."; exit 1; fi; done; ./server -db $IDS_MONGODB -es $IDS_ELASTICSEARCH
RUN chmod +x /server /start.sh
ENTRYPOINT /start.sh
4 changes: 3 additions & 1 deletion docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$ git clone https://github.com/ysrc/yulong-hids.git
```

#### Step2. 初次运行
#### Step2. 初次编译并运行

```
$ cd yulong-hids/
Expand All @@ -33,6 +33,8 @@ $ docker-compose up

> 第一次启动时由于 Server 需要配置文件不存在会导致启动失败,不要慌,只要保证 web、mongo、es 正常启动即可
> 如果提示获取 docker image 失败,请检查网络并重试,或者给 docker pull 挂上 http/https 代理
#### Step3. 通过 Web 界面初始化

假定宿主机(物理机)的 IP 地址是: 192.168.1.101
Expand Down
23 changes: 23 additions & 0 deletions server/.dockerstart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

DIRNAME=`dirname $0`
if [ -z $IDS_ELASTICSEARCH ] || [ -z $IDS_MONGODB ]; then
echo "You need to specify IDS_MONGODB and IDS_ELASTICSEARCH"
exit 1
fi

for i in $(seq 1 10);
do
echo "Wait for ElasticSearch Start...$i"
curl -s http://$IDS_ELASTICSEARCH> /dev/null
if [ $? = 0 ];then
break;
fi
sleep 5
if [ $i -ge 10 ]; then
echo "Too much retry, exit."
exit 2
fi
done

$DIRNAME/server -db $IDS_MONGODB -es $IDS_ELASTICSEARCH

0 comments on commit ae427d3

Please sign in to comment.