mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-23 21:32:41 +08:00
add Dockerfile, Makefile
This commit is contained in:
parent
1a69a00422
commit
1b1361f30b
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
||||
FROM golang:latest
|
||||
ENV GOPATH="/go/"
|
||||
ENV GO111MODULE="on"
|
||||
WORKDIR /go/src/mark
|
||||
COPY / .
|
||||
RUN make get
|
||||
RUN make build
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates bash
|
||||
WORKDIR /
|
||||
COPY --from=0 /go/src/mark/mark /bin/
|
||||
ENTRYPOINT ["/bin/mark"]
|
41
Makefile
Normal file
41
Makefile
Normal file
@ -0,0 +1,41 @@
|
||||
NAME = $(notdir $(PWD))
|
||||
|
||||
VERSION = $(shell printf "%s.%s" \
|
||||
$$(git rev-list --count HEAD) \
|
||||
$$(git rev-parse --short HEAD) \
|
||||
)
|
||||
|
||||
GO111MODULE = off
|
||||
|
||||
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
REMOTE = kovetskiy
|
||||
|
||||
version:
|
||||
@echo $(VERSION)
|
||||
|
||||
get:
|
||||
go get -v -d
|
||||
|
||||
build:
|
||||
@echo :: building go binary $(VERSION)
|
||||
CGO_ENABLED=0 GOOS=linux go build \
|
||||
-ldflags "-X main.version=$(VERSION)" \
|
||||
-gcflags "-trimpath $(GOPATH)/src"
|
||||
|
||||
image:
|
||||
@echo :: building image $(NAME):$(VERSION)
|
||||
@docker build -t $(NAME):$(VERSION) -f Dockerfile .
|
||||
docker tag $(NAME):$(VERSION) $(NAME):latest
|
||||
|
||||
push:
|
||||
$(if $(REMOTE),,$(error REMOTE is not set))
|
||||
$(eval VERSION ?= latest)
|
||||
$(eval TAG ?= $(REMOTE)/$(NAME):$(VERSION))
|
||||
@echo :: pushing image $(TAG)
|
||||
@docker tag $(NAME):$(VERSION) $(TAG)
|
||||
@docker push $(TAG)
|
||||
@docker push $(REMOTE)/$(NAME):latest
|
||||
|
||||
clean:
|
||||
rm -rf $(NAME)
|
55
main.go
55
main.go
@ -67,25 +67,28 @@ Also, optional following headers are supported:
|
||||
|
||||
Usage:
|
||||
mark [options] [-u <username>] [-p <password>] [-k] [-l <url>] -f <file>
|
||||
mark [options] [-u <username>] [-p <password>] [-k] [-b <url>] -f <file>
|
||||
mark [options] [-u <username>] [-p <password>] [-k] [-n] -c <file>
|
||||
mark -v | --version
|
||||
mark -h | --help
|
||||
|
||||
Options:
|
||||
-u <username> Use specified username for updating Confluence page.
|
||||
-p <password> Use specified password for updating Confluence page.
|
||||
-l <url> Edit specified Confluence page.
|
||||
If -l is not specified, file should contain metadata (see
|
||||
above).
|
||||
-f <file> Use specified markdown file for converting to html.
|
||||
-c <file> Specify configuration file which should be used for reading
|
||||
Confluence page URL and markdown file path.
|
||||
-k Lock page editing to current user only to prevent accidental
|
||||
manual edits over Confluence Web UI.
|
||||
--dry-run Show resulting HTML and don't update Confluence page content.
|
||||
--trace Enable trace logs.
|
||||
-h --help Show this screen and call 911.
|
||||
-v --version Show version.
|
||||
-u <username> Use specified username for updating Confluence page.
|
||||
-p <password> Use specified password for updating Confluence page.
|
||||
-l <url> Edit specified Confluence page.
|
||||
If -l is not specified, file should contain metadata (see
|
||||
above).
|
||||
-b --base-url <url> Base URL for Confluence.
|
||||
Alternative option for base_url config field.
|
||||
-f <file> Use specified markdown file for converting to html.
|
||||
-c <file> Specify configuration file which should be used for reading
|
||||
Confluence page URL and markdown file path.
|
||||
-k Lock page editing to current user only to prevent accidental
|
||||
manual edits over Confluence Web UI.
|
||||
--dry-run Show resulting HTML and don't update Confluence page content.
|
||||
--trace Enable trace logs.
|
||||
-h --help Show this screen and call 911.
|
||||
-v --version Show version.
|
||||
`
|
||||
)
|
||||
|
||||
@ -245,18 +248,22 @@ func main() {
|
||||
baseURL := url.Scheme + "://" + url.Host
|
||||
|
||||
if url.Host == "" {
|
||||
baseURL, err = config.GetString("base_url")
|
||||
if err != nil {
|
||||
if zhash.IsNotFound(err) {
|
||||
logger.Fatal(
|
||||
"Confluence base URL should be specified using -l " +
|
||||
"flag or be stored in configuration file",
|
||||
var ok bool
|
||||
baseURL, ok = args["--base-url"].(string)
|
||||
if !ok {
|
||||
baseURL, err = config.GetString("base_url")
|
||||
if err != nil {
|
||||
if zhash.IsNotFound(err) {
|
||||
logger.Fatal(
|
||||
"Confluence base URL should be specified using -l " +
|
||||
"flag or be stored in configuration file",
|
||||
)
|
||||
}
|
||||
|
||||
logger.Fatalf(
|
||||
"can't read base_url configuration variable: %s", err,
|
||||
)
|
||||
}
|
||||
|
||||
logger.Fatalf(
|
||||
"can't read base_url configuration variable: %s", err,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user