diff --git a/Dockerfile b/Dockerfile index eb4757ba..b89cab9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,14 +9,18 @@ WORKDIR /app COPY . . ENV GOPROXY=https://mod.gokit.info -RUN ./control build +RUN ./control build docker FROM buildpack-deps:buster-curl LABEL maintainer="llitfkitfk@gmail.com" WORKDIR /app -COPY --from=builder /app/docker/etc /app/etc +COPY --from=builder /app/docker/scripts /app/scripts +COPY --from=builder /app/etc /app/etc +# Change default address (hard code) +RUN ./scripts/sed.sh + COPY --from=builder /app/bin /usr/local/bin diff --git a/control b/control index da36d118..95c87583 100755 --- a/control +++ b/control @@ -134,6 +134,12 @@ status() } build_one() +{ + mod=$1 + go build -o n9e-${mod} --tags "md5" src/modules/${mod}/${mod}.go +} + +build_docker() { mod=$1 go build -o bin/n9e-${mod} --tags "md5" src/modules/${mod}/${mod}.go @@ -141,7 +147,7 @@ build_one() build() { - export GO111MODULE=on + export GO111MODULE=on mod=$1 if [ "x${mod}" = "x" ]; then @@ -153,6 +159,16 @@ build() build_one tsdb return fi + + if [ "x${mod}" = "xdocker" ]; then + build_docker monapi + build_docker transfer + build_docker index + build_docker judge + build_docker collector + build_docker tsdb + return + fi build_one $mod } diff --git a/docker-compose.yml b/docker-compose.yml index d2b5e069..43acc57a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,8 +18,6 @@ services: image: api restart: always command: n9e-monapi - volumes: - - ./docker/etc:/app/etc ports: - 5800:5800 @@ -27,8 +25,6 @@ services: image: api restart: always command: n9e-transfer - volumes: - - ./docker/etc:/app/etc ports: - 5810:5810 - 5811:5811 @@ -37,8 +33,6 @@ services: image: api restart: always command: n9e-tsdb - volumes: - - ./docker/etc:/app/etc ports: - 5820:5820 - 5821:5821 @@ -47,8 +41,6 @@ services: image: api restart: always command: n9e-index - volumes: - - ./docker/etc:/app/etc ports: - 5830:5830 - 5831:5831 @@ -57,8 +49,6 @@ services: image: api restart: always command: n9e-judge - volumes: - - ./docker/etc:/app/etc ports: - 5840:5840 - 5841:5841 @@ -67,8 +57,6 @@ services: image: api restart: always command: n9e-collector - volumes: - - ./docker/etc:/app/etc ports: - 2058:2058 diff --git a/docker/etc/address.yml b/docker/etc/address.yml deleted file mode 100644 index bea44bad..00000000 --- a/docker/etc/address.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -monapi: - http: 0.0.0.0:5800 - addresses: - - 127.0.0.1 - -transfer: - http: 0.0.0.0:5810 - rpc: 0.0.0.0:5811 - addresses: - - 127.0.0.1 - -tsdb: - http: 0.0.0.0:5820 - rpc: 0.0.0.0:5821 - addresses: - - 127.0.0.1 - -index: - http: 0.0.0.0:5830 - rpc: 0.0.0.0:5831 - addresses: - - 127.0.0.1 - -judge: - http: 0.0.0.0:5840 - rpc: 0.0.0.0:5841 - addresses: - - 127.0.0.1 - -collector: - http: 0.0.0.0:2058 - - diff --git a/docker/etc/collector.yml b/docker/etc/collector.yml deleted file mode 100644 index f1218cdd..00000000 --- a/docker/etc/collector.yml +++ /dev/null @@ -1,30 +0,0 @@ -logger: - dir: logs/collector - level: WARNING - keepHours: 2 -identity: - specify: "" - shell: /usr/sbin/ifconfig `/usr/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1 -sys: - # timeout in ms - # interval in second - timeout: 1000 - interval: 20 - ifacePrefix: - - eth - - em - mountPoint: [] - mountIgnorePrefix: - - /var/lib - - ignoreMetrics: - - cpu.core.idle - - cpu.core.util - - cpu.core.sys - - cpu.core.user - - cpu.core.nice - - cpu.core.guest - - cpu.core.irq - - cpu.core.softirq - - cpu.core.iowait - - cpu.core.steal diff --git a/docker/etc/index.yml b/docker/etc/index.yml deleted file mode 100644 index 6640c261..00000000 --- a/docker/etc/index.yml +++ /dev/null @@ -1,7 +0,0 @@ -logger: - dir: logs/index - level: WARNING - keepHours: 2 -identity: - specify: "" - shell: /sbin/ifconfig `/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1 diff --git a/docker/etc/judge.yml b/docker/etc/judge.yml deleted file mode 100644 index b5714c33..00000000 --- a/docker/etc/judge.yml +++ /dev/null @@ -1,22 +0,0 @@ -query: - connTimeout: 1000 - callTimeout: 2000 - indexCallTimeout: 2000 - -redis: - addrs: - - redis:6379 - pass: "" - # timeout: - # conn: 500 - # read: 3000 - # write: 3000 - -identity: - specify: "" - shell: /usr/sbin/ifconfig `/usr/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1 - -logger: - dir: logs/judge - level: WARNING - keepHours: 2 \ No newline at end of file diff --git a/docker/etc/monapi.yml b/docker/etc/monapi.yml deleted file mode 100644 index e3335a00..00000000 --- a/docker/etc/monapi.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -salt: "PLACE_SALT" - -logger: - dir: "logs/monapi" - level: "WARNING" - keepHours: 24 - -http: - secret: "PLACE_SECRET" - -# for ldap authorization -ldap: - host: "ldap.example.org" - port: 389 - baseDn: "dc=example,dc=org" - bindUser: "cn=manager,dc=example,dc=org" - bindPass: "*******" - # openldap: (&(uid=%s)) - # AD: (&(sAMAccountName=%s)) - authFilter: "(&(uid=%s))" - tls: false - startTLS: false - -# notify support: voice, sms, mail, im -# if we have all of notice channel -# notify: -# p1: ["voice", "sms", "mail", "im"] -# p2: ["sms", "mail", "im"] -# p3: ["mail", "im"] - -# if we only have mail channel -notify: - p1: ["mail"] - p2: ["mail"] - p3: ["mail"] - -# addresses accessible using browsers -link: - stra: http://n9e.example.com/#/monitor/strategy/%v - event: http://n9e.example.com/#/monitor/history/his/%v - claim: http://n9e.example.com/#/monitor/history/cur/%v - -# for alarm event and message queue -redis: - addr: "redis:6379" - pass: "" - # in ms - # timeout: - # conn: 500 - # read: 3000 - # write: 3000 diff --git a/docker/etc/mysql.yml b/docker/etc/mysql.yml deleted file mode 100644 index a65d0094..00000000 --- a/docker/etc/mysql.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -uic: - addr: "root:1234@tcp(mysql:3306)/n9e_uic?charset=utf8&parseTime=True&loc=Asia%2FShanghai" - max: 16 - idle: 4 - debug: false -mon: - addr: "root:1234@tcp(mysql:3306)/n9e_mon?charset=utf8&parseTime=True&loc=Asia%2FShanghai" - max: 16 - idle: 4 - debug: false -hbs: - addr: "root:1234@tcp(mysql:3306)/n9e_hbs?charset=utf8&parseTime=True&loc=Asia%2FShanghai" - max: 16 - idle: 4 - debug: false \ No newline at end of file diff --git a/docker/etc/transfer.yml b/docker/etc/transfer.yml deleted file mode 100644 index 869f8089..00000000 --- a/docker/etc/transfer.yml +++ /dev/null @@ -1,11 +0,0 @@ -backend: - # in ms - # connTimeout: 1000 - # callTimeout: 3000 - cluster: - tsdb01: 127.0.0.1:5821 - -logger: - dir: logs/transfer - level: WARNING - keepHours: 2 \ No newline at end of file diff --git a/docker/etc/tsdb.yml b/docker/etc/tsdb.yml deleted file mode 100644 index 863a3bae..00000000 --- a/docker/etc/tsdb.yml +++ /dev/null @@ -1,8 +0,0 @@ -rrd: - storage: data/5821 -cache: - keepMinutes: 120 -logger: - dir: logs/tsdb - level: WARNING - keepHours: 2 \ No newline at end of file diff --git a/docker/scripts/sed.sh b/docker/scripts/sed.sh new file mode 100755 index 00000000..36372e97 --- /dev/null +++ b/docker/scripts/sed.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -xe + +sed -i 's/127.0.0.1:6379/redis:6379/g' /app/etc/judge.yml +sed -i 's/127.0.0.1:6379/redis:6379/g' /app/etc/monapi.yml +sed -i 's/127.0.0.1:3306/mysql:3306/g' /app/etc/mysql.yml +sed -i 's/127.0.0.1:5821/tsdb:5821/g' /app/etc/transfer.yml \ No newline at end of file