Add ci scripts

This commit is contained in:
wweir
2019-01-19 11:03:32 +08:00
parent 98247845ad
commit 8d0ee2a9ea
6 changed files with 58 additions and 8 deletions
+22
View File
@@ -0,0 +1,22 @@
version: 2
jobs:
build:
docker:
- image: circleci/golang:1.11.4
steps:
- checkout # check out the code in the project directory
- setup_remote_docker # install docker in docker
- run:
name: build linux binary
command: |
make build
mv sower sower.linux
- run:
name: build macOS binary
command: |
GOOS=darwin GOARCH=amd64 make build
mv sower sower.darwin
- run:
name: build docker image
command: |
make image
+9 -5
View File
@@ -6,20 +6,24 @@ generate:
go generate ./...
build:
GOBIN=$(PWD) go install -v
go build -v -ldflags \
"-X main.version=$(shell git describe --tags) \
-X main.date=$(shell date +%Y-%m-%d)"
image:
docker build -t sower -f deploy/Dockerfile .
kill:
sudo pkill -9 sower || true
client: build kill
sudo $(PWD)/sower -f conf/sower.toml -logtostderr
sudo $(PWD)/sower -f conf/sower.toml
server: build kill
$(PWD)/sower -n TCP -logtostderr -v 1
$(PWD)/sower -n TCP -v 1
run: build kill
$(PWD)/sower -n TCP -logtostderr -v 1 &
sudo $(PWD)/sower -f conf/sower.toml -logtostderr &
$(PWD)/sower -n TCP -v 1 &
sudo $(PWD)/sower -f conf/sower.toml &
@sleep 1
curl 127.0.0.1
@sleep 1
+4 -1
View File
@@ -45,4 +45,7 @@ http(s) proxy | +----------+ | |
## todo
- [x] authenticate
- [ ] broker
- [ ] broker
- [ ] CI/CD
- [ ] relay optimization
- [ ] deploy script for all normal platform
+2 -1
View File
@@ -36,7 +36,7 @@ var Conf = struct {
func init() {
flag.StringVar(&Conf.ConfigFile, "f", "", "config file location")
flag.StringVar(&Conf.NetType, "n", "QUIC", "proxy net type (QUIC|KCP|TCP)")
flag.StringVar(&Conf.NetType, "n", "TCP", "proxy net type (QUIC|KCP|TCP)")
flag.StringVar(&Conf.Cipher, "C", "AES_128_GCM", "cipher type (AES_128_GCM|AES_192_GCM|AES_256_GCM|CHACHA20_IETF_POLY1305|XCHACHA20_IETF_POLY1305)")
flag.StringVar(&Conf.Password, "p", "12345678", "password")
flag.StringVar(&Conf.ServerPort, "P", "5533", "server mode listen port")
@@ -46,6 +46,7 @@ func init() {
flag.StringVar(&Conf.ClientIP, "c", "127.0.0.1", "client dns service redirect IP")
if !flag.Parsed() {
flag.Set("logtostderr", "true")
flag.Parse()
}
+18
View File
@@ -0,0 +1,18 @@
# Compile
FROM golang:1.11-alpine AS compiler
RUN apk add --no-cache git make
# enable go modules
WORKDIR /go-mod
COPY . .
# do not worry about downloading dependency, sower will fix this.
RUN CGO_ENABLED=0 make build
# Build image
FROM scratch
COPY --from=compiler /go-mod/sower /sower
ENTRYPOINT [ "/sower" ]
+3 -1
View File
@@ -7,9 +7,11 @@ import (
"github.com/wweir/sower/proxy"
)
var version, date string
func main() {
conf := conf.Conf
glog.Infoln("Starting:", conf)
glog.Infof("Starting sower(%s %s): %v", version, date, conf)
if conf.ServerAddr == "" {
proxy.StartServer(conf.NetType, conf.ServerPort, conf.Cipher, conf.Password)