diff --git a/Dockerfile b/Dockerfile index bce2147cac2f4b2777f40b73b2f33c9544710cb5..a1038c1a41c35ceccb0e14512aa09513ff29741b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM golang:alpine AS builder RUN apk add --no-cache git -WORKDIR /home/app +WORKDIR /app # comment this if using vendor # ENV GOPROXY=https://mod.gokit.info @@ -13,12 +13,12 @@ RUN go build -o ./bin/monapi src/modules/monapi/monapi.go FROM alpine:3.10 LABEL maintainer="llitfkitfk@gmail.com" -RUN apk add --no-cache ca-certificates +RUN apk add --no-cache tzdata ca-certificates WORKDIR /app -COPY --from=builder /home/app/etc /app/etc -COPY --from=builder /home/app/bin /usr/local/bin +COPY --from=builder /app/etc /app/etc +COPY --from=builder /app/bin /usr/local/bin # ENTRYPOINT [] # CMD [] \ No newline at end of file diff --git a/README.md b/README.md index 8ac237f84421fe93e3828fd3b728cb2423115ec3..7b11b6b9e68a843873fd88de6f36efddb994a8b2 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,13 @@ git clone https://github.com/didi/nightingale.git cd nightingale && ./control build ``` +## Quick Start (need install docker for [mac](https://docs.docker.com/docker-for-mac/install/)/[win](https://docs.docker.com/docker-for-windows/install/)) + +```bash +docker-compose up -d +# open http://localhost in web browser +``` + ## Team [ulricqin](https://github.com/ulricqin) [710leo](https://github.com/710leo) [jsers](https://github.com/jsers) [hujter](https://github.com/hujter) [n4mine](https://github.com/n4mine) [heli567](https://github.com/heli567) diff --git a/docker-compose.yml b/docker-compose.yml index e2f65185308a62ccce5a8c83487716869c22ec5f..7eff13f2f30cd226c9c3e1e61e92cbc6e5663ac9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,15 @@ version: "3" volumes: mysql-data: -services: +services: + nginx: + image: nginx:stable-alpine + ports: + - 80:80 + volumes: + - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf + - ./docker/nginx/conf.d:/etc/nginx/conf.d + - ./pub:/home/n9e/pub api: build: . image: api @@ -10,13 +18,18 @@ services: image: api restart: always command: monapi - - web: - build: - context: web - restart: always + volumes: + - ./docker/etc:/app/etc ports: - - 8010:8010 + - 5800:5800 + + # web: + # build: + # context: web + # restart: always + # command: npm run dev + # ports: + # - 8010:8010 redis: image: redis diff --git a/docker/etc/address.yml b/docker/etc/address.yml new file mode 100644 index 0000000000000000000000000000000000000000..bea44badacd8a9d5926dc5ce2dc17a654de93329 --- /dev/null +++ b/docker/etc/address.yml @@ -0,0 +1,34 @@ +--- +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/monapi.yml b/docker/etc/monapi.yml new file mode 100644 index 0000000000000000000000000000000000000000..e3335a006e9d74f8c03200a9447d3ff61fedb9be --- /dev/null +++ b/docker/etc/monapi.yml @@ -0,0 +1,52 @@ +--- +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 new file mode 100644 index 0000000000000000000000000000000000000000..a65d009410be43c68f3a1ff9acf4bc564a1b3f18 --- /dev/null +++ b/docker/etc/mysql.yml @@ -0,0 +1,16 @@ +--- +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/nginx/nginx.conf b/docker/nginx/nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..12cca06bb3b56dfe7f57407f32b7b530bb4ad16b --- /dev/null +++ b/docker/nginx/nginx.conf @@ -0,0 +1,89 @@ +user root; + +worker_processes auto; +worker_cpu_affinity auto; + +error_log /var/log/nginx/error.log; +pid /run/nginx.pid; + +include /usr/share/nginx/modules/*.conf; + +events { + use epoll; + worker_connections 204800; +} + +http { + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + include /etc/nginx/conf.d/*.conf; + + + proxy_connect_timeout 500ms; + proxy_send_timeout 1000ms; + proxy_read_timeout 3000ms; + proxy_buffers 64 8k; + proxy_busy_buffers_size 128k; + proxy_temp_file_write_size 64k; + proxy_redirect off; + proxy_next_upstream error invalid_header timeout http_502 http_504; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Real-Port $remote_port; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + upstream n9e.monapi { + server monapi:5800; + keepalive 10; + } + + upstream n9e.index { + server 127.0.0.1:5830; + keepalive 10; + } + + upstream n9e.transfer { + server 127.0.0.1:5810; + keepalive 10; + } + + server { + listen 80 default_server; + server_name _; + root /usr/share/nginx/html; + + # Load configuration files for the default server block. + include /etc/nginx/default.d/*.conf; + + location / { + root /home/n9e/pub; + } + + location /api/portal { + proxy_pass http://n9e.monapi; + } + + location /api/index { + proxy_pass http://n9e.index; + } + + location /api/transfer { + proxy_pass http://n9e.transfer; + } + } + +} \ No newline at end of file diff --git a/web/Dockerfile b/web/Dockerfile index cce595dc9d4d2403c0940d1a8c926470778338d2..101ad977f595e4ac6508d1c3beb4992eebcfded3 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,5 +1,7 @@ FROM node:lts-alpine AS builder -WORKDIR /home/app +WORKDIR /app -COPY . . \ No newline at end of file +COPY . . + +RUN npm install \ No newline at end of file