From 595f2fd82cf4e50c4cc6418487461e475f48b9dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=94=AE=E5=86=AC?= Date: Fri, 10 Apr 2020 10:52:13 +0800 Subject: [PATCH] Offer a better docker example (#75) --- Dockerfile | 23 ++++++----------------- README.md | 15 ++++++++++++--- docker-compose.yml | 38 ++++++++++++++++++++------------------ docker/nginx/nginx.conf | 6 +++--- docker/scripts/sed.sh | 8 -------- 5 files changed, 41 insertions(+), 49 deletions(-) delete mode 100755 docker/scripts/sed.sh diff --git a/Dockerfile b/Dockerfile index 4ee9fc83..ecb8d9af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,11 @@ -FROM golang AS builder -# RUN apk add --no-cache git gcc -WORKDIR /app - -COPY . . -RUN ./control build docker +FROM golang:1.13 -FROM buildpack-deps:buster-curl -LABEL maintainer="llitfkitfk@gmail.com" +LABEL maintainer="llitfkitfk@gmail.com,chenjiandongx@qq.com" WORKDIR /app -COPY --from=builder /app/docker/scripts /app/scripts -COPY --from=builder /app/etc /app/etc -# Change default address (hard code) -RUN ./scripts/sed.sh +RUN apt-get update && apt-get install net-tools -y -COPY --from=builder /app/bin /usr/local/bin - - -# ENTRYPOINT [] -# CMD [] \ No newline at end of file +COPY . . +RUN ./control build docker +RUN mv /app/bin/* /usr/local/bin diff --git a/README.md b/README.md index 11044eeb..a7c86028 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,22 @@ 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/)) +## Quickstart with Docker +We has offered a Docker demo for the users who want to give it a try. Before you get started, make sure you have installed **Docker** & **docker-compose** and there are some details you should know. + +* We highly recommend users prepare a new VM environment to use it. +* All the core components will be installed on your OS according to the `docker-compose.yaml`. +* Nightingale will use the following ports, `80`, `5800`, `5810`, `5811`, `5820`, `5821`, `5830`, `5831`, `5840`, `5841`, `6379`, `2058`, `3306`. + +Okay. Run it! Once the docker finish its jobs, visits http://your-env-ip in your broswer. Default username and password is `root:root`. ```bash -docker-compose up -d -# open http://localhost in web browser +$ docker-compose up -d ``` +![dashboard](https://user-images.githubusercontent.com/19553554/78956965-8b9c6180-7b16-11ea-9747-6ed5e62b068d.png) + + ## 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 43acc57a..29eaca41 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,28 +1,34 @@ version: "3" + volumes: mysql-data: + services: nginx: image: nginx:stable-alpine + network_mode: host 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: + + nightingale: build: . - image: api + image: nightingale monapi: - image: api + image: nightingale + network_mode: host restart: always command: n9e-monapi ports: - 5800:5800 transfer: - image: api + image: nightingale + network_mode: host restart: always command: n9e-transfer ports: @@ -30,7 +36,8 @@ services: - 5811:5811 tsdb: - image: api + image: nightingale + network_mode: host restart: always command: n9e-tsdb ports: @@ -38,7 +45,8 @@ services: - 5821:5821 index: - image: api + image: nightingale + network_mode: host restart: always command: n9e-index ports: @@ -46,7 +54,8 @@ services: - 5831:5831 judge: - image: api + image: nightingale + network_mode: host restart: always command: n9e-judge ports: @@ -54,28 +63,23 @@ services: - 5841:5841 collector: - image: api + image: nightingale + network_mode: host restart: always command: n9e-collector ports: - 2058:2058 - # web: - # build: - # context: web - # restart: always - # command: npm run dev - # ports: - # - 8010:8010 - redis: image: redis + network_mode: host restart: always ports: - 6379:6379 mysql: image: mysql:5.7 + network_mode: host restart: always environment: - MYSQL_ROOT_PASSWORD=1234 @@ -84,5 +88,3 @@ services: volumes: - ./sql:/docker-entrypoint-initdb.d - mysql-data:/var/lib/mysql - - \ No newline at end of file diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index d1864e67..51579c54 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -47,17 +47,17 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; upstream n9e.monapi { - server monapi:5800; + server localhost:5800; keepalive 10; } upstream n9e.index { - server index:5830; + server localhost:5830; keepalive 10; } upstream n9e.transfer { - server transfer:5810; + server localhost:5810; keepalive 10; } diff --git a/docker/scripts/sed.sh b/docker/scripts/sed.sh deleted file mode 100755 index 36372e97..00000000 --- a/docker/scripts/sed.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/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 -- GitLab