Add: Dockerfile and Makefile
This commit is contained in:
parent
ef301af04f
commit
cd9f496fc9
5 changed files with 51 additions and 9 deletions
|
@ -12,11 +12,7 @@ env:
|
||||||
- BINDIR=bin
|
- BINDIR=bin
|
||||||
script:
|
script:
|
||||||
- go test
|
- go test
|
||||||
- GOARCH=amd64 GOOS=linux go build -o $BINDIR/$NAME-linux
|
before_deploy: make -j releases
|
||||||
- GOARCH=amd64 GOOS=darwin go build -o $BINDIR/$NAME-macos
|
|
||||||
- chmod +x $BINDIR/$NAME-*
|
|
||||||
- gzip $BINDIR/$NAME-linux
|
|
||||||
- gzip $BINDIR/$NAME-macos
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: releases
|
provider: releases
|
||||||
prerelease: true
|
prerelease: true
|
||||||
|
|
21
Dockerfile
Normal file
21
Dockerfile
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
FROM golang:latest as builder
|
||||||
|
RUN wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz -O /tmp/GeoLite2-Country.tar.gz && \
|
||||||
|
cd /tmp && \
|
||||||
|
tar zxvf GeoLite2-Country.tar.gz && \
|
||||||
|
cd GeoLite2-Country_* && \
|
||||||
|
cp GeoLite2-Country.mmdb /Country.mmdb
|
||||||
|
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh && \
|
||||||
|
mkdir -p /go/src/github.com/Dreamacro/clash
|
||||||
|
WORKDIR /go/src/github.com/Dreamacro/clash
|
||||||
|
COPY . /go/src/github.com/Dreamacro/clash
|
||||||
|
RUN dep ensure && \
|
||||||
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-w -s' -o /clash && \
|
||||||
|
chmod +x /clash
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
RUN apk --no-cache add ca-certificates && \
|
||||||
|
mkdir -p /root/.config/clash
|
||||||
|
COPY --from=builder /clash .
|
||||||
|
COPY --from=builder /Country.mmdb /root/.config/clash/
|
||||||
|
EXPOSE 7890 7891
|
||||||
|
ENTRYPOINT ["/clash"]
|
5
Gopkg.lock
generated
5
Gopkg.lock
generated
|
@ -49,10 +49,11 @@
|
||||||
"chacha20poly1305",
|
"chacha20poly1305",
|
||||||
"hkdf",
|
"hkdf",
|
||||||
"internal/chacha20",
|
"internal/chacha20",
|
||||||
|
"internal/subtle",
|
||||||
"poly1305",
|
"poly1305",
|
||||||
"ssh/terminal"
|
"ssh/terminal"
|
||||||
]
|
]
|
||||||
revision = "8ac0e0d97ce45cd83d1d7243c060cb8461dda5e9"
|
revision = "a8fb68e7206f8c78be19b432c58eb52a6aa34462"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -62,7 +63,7 @@
|
||||||
"unix",
|
"unix",
|
||||||
"windows"
|
"windows"
|
||||||
]
|
]
|
||||||
revision = "9527bec2660bd847c050fda93a0f0c6dee0800bb"
|
revision = "6c888cc515d3ed83fc103cf1d84468aad274b0a7"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "gopkg.in/eapache/channels.v1"
|
name = "gopkg.in/eapache/channels.v1"
|
||||||
|
|
19
Makefile
Normal file
19
Makefile
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
NAME=clash
|
||||||
|
BINDIR=bin
|
||||||
|
GOBUILD=CGO_ENABLED=0 go build -ldflags '-w -s'
|
||||||
|
|
||||||
|
all: linux macos
|
||||||
|
|
||||||
|
linux:
|
||||||
|
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||||
|
|
||||||
|
macos:
|
||||||
|
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
||||||
|
|
||||||
|
releases: linux macos
|
||||||
|
chmod +x $(BINDIR)/$(NAME)-*
|
||||||
|
gzip $(BINDIR)/$(NAME)-linux
|
||||||
|
gzip $(BINDIR)/$(NAME)-macos
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm $(BINDIR)/*
|
|
@ -29,9 +29,14 @@ var (
|
||||||
func init() {
|
func init() {
|
||||||
currentUser, err := user.Current()
|
currentUser, err := user.Current()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
dir := os.Getenv("HOME")
|
||||||
|
if dir == "" {
|
||||||
log.Fatalf("Can't get current user: %s", err.Error())
|
log.Fatalf("Can't get current user: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
HomeDir = dir
|
||||||
|
} else {
|
||||||
HomeDir = currentUser.HomeDir
|
HomeDir = currentUser.HomeDir
|
||||||
|
}
|
||||||
|
|
||||||
dirPath := path.Join(HomeDir, ".config", Name)
|
dirPath := path.Join(HomeDir, ".config", Name)
|
||||||
if _, err := os.Stat(dirPath); os.IsNotExist(err) {
|
if _, err := os.Stat(dirPath); os.IsNotExist(err) {
|
||||||
|
|
Loading…
Reference in a new issue