ci: add docker files

This commit is contained in:
ICKelin
2021-04-23 19:05:44 +08:00
parent e14d63c3de
commit 3d522b013c
10 changed files with 49 additions and 14 deletions

View File

@@ -1,12 +0,0 @@
#!/bin/sh
WORKSPACE=`pwd`
BIN=$WORKSPACE/bin/
cd $WORKSPACE/opennotr
GOOS=darwin go build -o $BIN/opennotr-client_darwin_amd64
GOOS=linux go build -o $BIN/opennotr-client_linux_amd64
GOARCH=arm GOOS=linux go build -o $BIN/opennotr-client_arm
GOARCH=arm64 GOOS=linux go build -o $BIN/opennotr-client_arm64
cd $WORKSPACE/opennotrd
GOOS=linux go build -o $BIN/opennotr-server_linux

17
build_exec.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
WORKSPACE=`pwd`
BIN=$WORKSPACE/bin/
EXEC_PREFIX=opennotrd
cd $WORKSPACE/opennotr
export GO111MODULE = on
echo 'building client...'
GOOS=darwin go build -o $BIN/$EXEC_PREFIX-client_darwin_amd64
GOOS=linux go build -o $BIN/$EXEC_PREFIX-client_linux_amd64
GOARCH=arm GOOS=linux go build -o $BIN/$EXEC_PREFIX-client_arm
GOARCH=arm64 GOOS=linux go build -o $BIN/$EXEC_PREFIX-client_arm64
echo 'building server...'
cd $WORKSPACE/opennotrd
GOOS=linux go build -o $BIN/$EXEC_PREFIX-server_linux_amd64

6
build_image.sh Normal file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
WORKSPACE=`pwd`
cd opennotrd && go build -o ../docker-build/opennotrd
cd $WORKSPACE/docker-build
docker build . -t opennotr

5
docker-build/Dockerfile Normal file
View File

@@ -0,0 +1,5 @@
FROM ickelin/resty-upstream:latest
COPY opennotrd /opt/
COPY start.sh /opt/
RUN chmod +x /opt/start.sh && chmod +x /opt/opennotrd
CMD /opt/start.sh

View File

@@ -0,0 +1,13 @@
version: '3'
services:
opennotrd:
image: ickelin/opennotr:latest
network_mode: host
container_name: opennotrd
restart: always
privileged: true
volumes:
- /opt/logs/opennotr:/opt/resty-upstream/logs
- /opt/data/opennotrd:/opt/conf
environment:
TIME_ZONE: Asia/Shanghai

3
docker-build/start.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
/opt/openresty/bin/openresty -p /opt/resty-upstream -c /opt/conf/nginx-conf/nginx.conf
/opt/opennotrd -conf /opt/conf/notrd.yaml

View File

@@ -5,4 +5,6 @@ http: 8080
https: 8080 https: 8080
grpc: 50052 grpc: 50052
tcp: tcp:
2222: 22 2222: 22
udp:
53: 53

View File

@@ -150,6 +150,7 @@ func (p *UDPProxy) udpCopy(src, dst *net.UDPConn, toaddr *net.UDPAddr) {
logs.Error("read from udp fail: %v", err) logs.Error("read from udp fail: %v", err)
break break
} }
logs.Debug("write back to client %d bytes", nr) logs.Debug("write back to client %d bytes", nr)
_, err = dst.WriteToUDP(buf[:nr], toaddr) _, err = dst.WriteToUDP(buf[:nr], toaddr)
if err != nil { if err != nil {

View File

@@ -74,7 +74,7 @@ func (p *UpstreamManager) DelUpstream(host string, httpPort, httpsPort, grpcPort
} }
if grpcPort != 0 { if grpcPort != 0 {
p.sendDeleteReq(host, "http2") p.sendDeleteReq(host, "h2c")
} }
} }

0
run_image.sh Normal file
View File