Compare commits

...

1 Commits

Author SHA1 Message Date
Evan Chen 01562e5389 release: 0.1.0 2021-10-21 00:19:32 +08:00
4 changed files with 65 additions and 8 deletions

View File

@ -1,14 +1,17 @@
FROM golang:1.17.2-alpine3.14 as builder FROM golang:1.17.2-alpine3.14 as builder
RUN apk update && apk add --no-cache git tzdata RUN apk update && apk add --no-cache git tzdata
WORKDIR /src 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 . . 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 \ GOOS=linux GOARCH=amd64 \
go build -ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD} -w" \ 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 FROM alpine:3.14
@ -16,4 +19,4 @@ EXPOSE 5080
ENV PATH="/go/bin:${PATH}" ENV PATH="/go/bin:${PATH}"
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /go/bin/configui /go/bin/configui COPY --from=builder /go/bin/configui /go/bin/configui
CMD ["/go/bin/configui"] CMD ["/go/bin/configui","-log","/var/log/configui.log","-f","/data/configui.json"]

View File

@ -5,9 +5,15 @@ HUB=hub.kumoly.io
HUB_PROJECT=tools HUB_PROJECT=tools
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD} -w" LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD} -w"
PLATFORMS=darwin linux
ARCHITECTURES=amd64
APPS=configui
default: build default: build
install:
npm install
clean: clean:
rm -rf dist rm -rf dist
@ -17,4 +23,48 @@ run: build
.PHONY: build .PHONY: build
build: build:
npm run build npm run build
go build ${LDFLAGS} -o dist/${PROJ} 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

View File

@ -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] Usage: configui [options]
-allow string
IPs to allow, blank to allow all
-bind string -bind string
address to bind (default "localhost:8000") address to bind (default "0.0.0.0:8000")
-c string -c string
cmd to apply cmd to apply
-f string -f string
@ -16,6 +18,8 @@ Usage: configui [options]
alias of file alias of file
-p string -p string
path to file, precedence over config path to file, precedence over config
-static
disable config api
-v show version -v show version
``` ```

View File

@ -45,7 +45,7 @@ func init() {
flag.StringVar(&flagAction, "c", "", "cmd to apply") flag.StringVar(&flagAction, "c", "", "cmd to apply")
flag.StringVar(&flagLogFile, "log", "", "log to file") flag.StringVar(&flagLogFile, "log", "", "log to file")
flag.StringVar(&flagAllow, "allow", "", "IPs to allow, blank to allow all") 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(&flagNoReconfig, "static", false, "disable config api")
flag.BoolVar(&flagVer, "v", false, "show version") flag.BoolVar(&flagVer, "v", false, "show version")
flag.Usage = func() { flag.Usage = func() {