Merge pull request #12 from llitfkitfk/feature/docker
Add Docker support for local development
This commit is contained in:
commit
3e8a6946e0
|
@ -0,0 +1 @@
|
|||
web
|
|
@ -0,0 +1,28 @@
|
|||
FROM golang AS builder
|
||||
# RUN apk add --no-cache git gcc
|
||||
WORKDIR /app
|
||||
|
||||
# comment this if using vendor
|
||||
# ENV GOPROXY=https://mod.gokit.info
|
||||
# COPY go.mod go.sum ./
|
||||
# RUN go mod download
|
||||
|
||||
COPY . .
|
||||
ENV GOPROXY=https://mod.gokit.info
|
||||
RUN ./control build docker
|
||||
|
||||
FROM buildpack-deps:buster-curl
|
||||
LABEL maintainer="llitfkitfk@gmail.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
|
||||
|
||||
COPY --from=builder /app/bin /usr/local/bin
|
||||
|
||||
|
||||
# ENTRYPOINT []
|
||||
# CMD []
|
|
@ -21,6 +21,13 @@ 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)
|
||||
|
|
16
control
16
control
|
@ -139,6 +139,12 @@ build_one()
|
|||
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
|
||||
}
|
||||
|
||||
build()
|
||||
{
|
||||
export GO111MODULE=on
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
version: "3"
|
||||
volumes:
|
||||
mysql-data:
|
||||
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
|
||||
|
||||
monapi:
|
||||
image: api
|
||||
restart: always
|
||||
command: n9e-monapi
|
||||
ports:
|
||||
- 5800:5800
|
||||
|
||||
transfer:
|
||||
image: api
|
||||
restart: always
|
||||
command: n9e-transfer
|
||||
ports:
|
||||
- 5810:5810
|
||||
- 5811:5811
|
||||
|
||||
tsdb:
|
||||
image: api
|
||||
restart: always
|
||||
command: n9e-tsdb
|
||||
ports:
|
||||
- 5820:5820
|
||||
- 5821:5821
|
||||
|
||||
index:
|
||||
image: api
|
||||
restart: always
|
||||
command: n9e-index
|
||||
ports:
|
||||
- 5830:5830
|
||||
- 5831:5831
|
||||
|
||||
judge:
|
||||
image: api
|
||||
restart: always
|
||||
command: n9e-judge
|
||||
ports:
|
||||
- 5840:5840
|
||||
- 5841:5841
|
||||
|
||||
collector:
|
||||
image: api
|
||||
restart: always
|
||||
command: n9e-collector
|
||||
ports:
|
||||
- 2058:2058
|
||||
|
||||
# web:
|
||||
# build:
|
||||
# context: web
|
||||
# restart: always
|
||||
# command: npm run dev
|
||||
# ports:
|
||||
# - 8010:8010
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
restart: always
|
||||
ports:
|
||||
- 6379:6379
|
||||
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=1234
|
||||
ports:
|
||||
- 3306:3306
|
||||
volumes:
|
||||
- ./sql:/docker-entrypoint-initdb.d
|
||||
- mysql-data:/var/lib/mysql
|
||||
|
||||
|
|
@ -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 index:5830;
|
||||
keepalive 10;
|
||||
}
|
||||
|
||||
upstream n9e.transfer {
|
||||
server transfer: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/conf.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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
node_modules
|
|
@ -0,0 +1,7 @@
|
|||
FROM node:lts-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm install
|
Loading…
Reference in New Issue