Commit 3aa06abd authored by Eric's avatar Eric

[Update] modify Makefile

parent 92ff0002
...@@ -14,6 +14,8 @@ FROM alpine ...@@ -14,6 +14,8 @@ FROM alpine
WORKDIR /opt/coco/ WORKDIR /opt/coco/
COPY --from=stage-build /go/src/cocogo/cmd/coco . COPY --from=stage-build /go/src/cocogo/cmd/coco .
COPY --from=stage-build /go/src/cocogo/cmd/locale . COPY --from=stage-build /go/src/cocogo/cmd/locale .
COPY --from=stage-build /go/src/cocogo/cmd/static .
COPY --from=stage-build /go/src/cocogo/cmd/templates .
RUN echo > config.yml RUN echo > config.yml
EXPOSE 2222 EXPOSE 2222
CMD ["./coco"] CMD ["./coco"]
...@@ -4,6 +4,7 @@ BUILD := $(shell git rev-parse --short HEAD) ...@@ -4,6 +4,7 @@ BUILD := $(shell git rev-parse --short HEAD)
VERSION=$(BRANCH)-$(BUILD) VERSION=$(BRANCH)-$(BUILD)
NAME := coco NAME := coco
DIRNAME := cocogo
BASEPATH := $(shell pwd) BASEPATH := $(shell pwd)
CGO_ENABLED = 0 CGO_ENABLED = 0
GOCMD=go GOCMD=go
...@@ -11,27 +12,27 @@ GOBUILD=$(GOCMD) build ...@@ -11,27 +12,27 @@ GOBUILD=$(GOCMD) build
SOFTWARENAME=$(NAME)-$(VERSION) SOFTWARENAME=$(NAME)-$(VERSION)
COCOSRCFILE= coco.go COCOSRCFILE= coco.go
BUILDDIR:=$(BASEPATH)/../build
ASSETS=locale static templates config_example.yml
.PHONY: windows PLATFORMS := linux darwin
windows:
@echo "编译windows" .PHONY: release
mkdir -p $(BASEPATH)/../build release: linux darwin
GOOS=windows GOARCH=amd64 go build -o $(BASEPATH)/$(SOFTWARENAME)-windows-amd64 $(COCOSRCFILE)
tar czvf $(BASEPATH)/../build/$(SOFTWARENAME)-windows-amd64.tar.gz $(SOFTWARENAME)-windows-amd64 locale/ config_example.yml
.PHONY:Asset
.PHONY: linux Asset:
linux: @[ -d $(BUILDDIR) ] || mkdir -p $(BUILDDIR)
@echo "编译linux" @[ -d $(DIRNAME) ] || mkdir -p $(DIRNAME)
mkdir -p $(BASEPATH)/../build cp -r $(ASSETS) $(DIRNAME)
GOOS=linux GOARCH=amd64 go build -o $(BASEPATH)/$(SOFTWARENAME)-linux-amd64 $(COCOSRCFILE)
tar czvf $(BASEPATH)/../build/$(SOFTWARENAME)-linux-amd64.tar.gz $(SOFTWARENAME)-linux-amd64 locale/ config_example.yml .PHONY: $(PLATFORMS)
$(PLATFORMS): Asset
.PHONY: darwin @echo "编译" $@
darwin: GOOS=$@ GOARCH=amd64 go build -o $(NAME) $(COCOSRCFILE)
@echo "编译darwin" cp -f $(NAME) $(DIRNAME)
mkdir -p $(BASEPATH)/../build tar czvf $(BUILDDIR)/$(SOFTWARENAME)-$@-amd64.tar.gz $(DIRNAME)
GOOS=darwin GOARCH=amd64 go build -o $(BASEPATH)/$(SOFTWARENAME)-darwin-amd64 $(COCOSRCFILE)
tar czvf $(BASEPATH)/../build/$(SOFTWARENAME)-darwin-amd64.tar.gz $(SOFTWARENAME)-darwin-amd64 locale/ config_example.yml
.PHONY: docker .PHONY: docker
docker: docker:
...@@ -40,6 +41,8 @@ docker: ...@@ -40,6 +41,8 @@ docker:
.PHONY: clean .PHONY: clean
clean: clean:
-rm -rf $(BASEPATH)/../build -rm -rf $(NAME)
-rm -rf $(DIRNAME)
-rm -rf $(BUILDDIR)
...@@ -397,7 +397,7 @@ func CreateSFTPConn(user, password, privateKey, host, port string) (*sftp.Client ...@@ -397,7 +397,7 @@ func CreateSFTPConn(user, password, privateKey, host, port string) (*sftp.Client
if privateKey != "" { if privateKey != "" {
if signer, err := gossh.ParsePrivateKey([]byte(privateKey)); err != nil { if signer, err := gossh.ParsePrivateKey([]byte(privateKey)); err != nil {
err = fmt.Errorf("parse private key error: %sc", err) err = fmt.Errorf("parse private key error: %s", err)
} else { } else {
authMethods = append(authMethods, gossh.PublicKeys(signer)) authMethods = append(authMethods, gossh.PublicKeys(signer))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment