From 01562e53893e0b79e7500a687eb6ed4b39ede9a4 Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Thu, 21 Oct 2021 00:19:32 +0800 Subject: [PATCH] release: 0.1.0 --- Dockerfile | 13 ++++++++----- Makefile | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- README.md | 6 +++++- main.go | 2 +- 4 files changed, 65 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index ef8c2ca..200032e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,17 @@ FROM golang:1.17.2-alpine3.14 as builder RUN apk update && apk add --no-cache git tzdata WORKDIR /src -COPY go.mod go.sum /src/ -RUN go mod download + +# not using any libs, for now + +# COPY go.mod go.sum /src/ +# RUN go mod download COPY . . -RUN VERSION=$(git describe --tags) BUILD=$(git rev-parse --short HEAD) && \ +RUN VERSION=$(git describe --tags --abbrev=0) BUILD=$(git rev-parse --short HEAD) && \ GOOS=linux GOARCH=amd64 \ go build -ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD} -w" \ - -o /go/bin/configui main.go + -o /go/bin/configui FROM alpine:3.14 @@ -16,4 +19,4 @@ EXPOSE 5080 ENV PATH="/go/bin:${PATH}" COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=builder /go/bin/configui /go/bin/configui -CMD ["/go/bin/configui"] \ No newline at end of file +CMD ["/go/bin/configui","-log","/var/log/configui.log","-f","/data/configui.json"] \ No newline at end of file diff --git a/Makefile b/Makefile index 3223ee5..b0b47ee 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,15 @@ HUB=hub.kumoly.io HUB_PROJECT=tools LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD} -w" +PLATFORMS=darwin linux +ARCHITECTURES=amd64 +APPS=configui default: build +install: + npm install + clean: rm -rf dist @@ -17,4 +23,48 @@ run: build .PHONY: build build: npm run build - go build ${LDFLAGS} -o dist/${PROJ} \ No newline at end of file + go build ${LDFLAGS} -o dist/${PROJ} + + +build-unix: + $(foreach GOOS, $(PLATFORMS), $(foreach GOARCH, $(ARCHITECTURES), $(foreach APP, $(APPS),\ + $(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build ${LDFLAGS} -o dist/$(APP)) \ + $(shell cd dist; tar -czf ${APP}_$(VERSION)_$(GOOS)_$(GOARCH).tar.gz ${APP}) \ + $(shell rm dist/${APP}) \ + ))) + +build-win: + $(foreach APP, $(APPS), \ + $(shell export GOOS=windows; export GOARCH=amd64; go build ${LDFLAGS} -o dist/${APP}.exe) \ + $(shell cd dist; tar -czf ${APP}_$(VERSION)_windows_amd64.tar.gz ${APP}.exe) \ + $(shell rm dist/${APP}.exe) \ + ) + +build-mac-m1: + $(foreach APP, $(APPS),\ + $(shell export GOOS=darwin; export GOARCH=arm64; go build ${LDFLAGS} -o dist/$(APP)) \ + $(shell cd dist; tar -czf ${APP}_$(VERSION)_darwin_arm64.tar.gz ${APP}) \ + $(shell rm dist/${APP}) \ + ) + +.PHONY: binary +binary: build-unix build-win build-mac-m1 + +.PHONY: docker +docker: + docker build --target builder -t $(HUB)/$(HUB_PROJECT)/$(PROJ):builder . + docker build \ + -t $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION) \ + . + +docker-push: + docker tag $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION) $(HUB)/$(HUB_PROJECT)/$(PROJ):latest + docker push $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION) + docker push $(HUB)/$(HUB_PROJECT)/$(PROJ):latest + +docker-save: + docker save $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION) | gzip > dist/$(PROJ)-image-$(VERSION)-${BUILD}.tar.gz + + +.PHONY: release +release: clean binary docker docker-save \ No newline at end of file diff --git a/README.md b/README.md index de9d73d..37b5b41 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,10 @@ a web app to edit and action on update powered by [ACE](https://ace.c9.io/#nav=h ``` Usage: configui [options] + -allow string + IPs to allow, blank to allow all -bind string - address to bind (default "localhost:8000") + address to bind (default "0.0.0.0:8000") -c string cmd to apply -f string @@ -16,6 +18,8 @@ Usage: configui [options] alias of file -p string path to file, precedence over config + -static + disable config api -v show version ``` diff --git a/main.go b/main.go index bd3758b..707cdf3 100644 --- a/main.go +++ b/main.go @@ -45,7 +45,7 @@ func init() { flag.StringVar(&flagAction, "c", "", "cmd to apply") flag.StringVar(&flagLogFile, "log", "", "log to file") flag.StringVar(&flagAllow, "allow", "", "IPs to allow, blank to allow all") - flag.StringVar(&flagBind, "bind", "localhost:8000", "address to bind") + flag.StringVar(&flagBind, "bind", "0.0.0.0:8000", "address to bind") flag.BoolVar(&flagNoReconfig, "static", false, "disable config api") flag.BoolVar(&flagVer, "v", false, "show version") flag.Usage = func() {