mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-24 05:42:40 +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:
|
Usage:
|
||||||
mark [options] [-u <username>] [-p <password>] [-k] [-l <url>] -f <file>
|
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 [options] [-u <username>] [-p <password>] [-k] [-n] -c <file>
|
||||||
mark -v | --version
|
mark -v | --version
|
||||||
mark -h | --help
|
mark -h | --help
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-u <username> Use specified username for updating Confluence page.
|
-u <username> Use specified username for updating Confluence page.
|
||||||
-p <password> Use specified password for updating Confluence page.
|
-p <password> Use specified password for updating Confluence page.
|
||||||
-l <url> Edit specified Confluence page.
|
-l <url> Edit specified Confluence page.
|
||||||
If -l is not specified, file should contain metadata (see
|
If -l is not specified, file should contain metadata (see
|
||||||
above).
|
above).
|
||||||
-f <file> Use specified markdown file for converting to html.
|
-b --base-url <url> Base URL for Confluence.
|
||||||
-c <file> Specify configuration file which should be used for reading
|
Alternative option for base_url config field.
|
||||||
Confluence page URL and markdown file path.
|
-f <file> Use specified markdown file for converting to html.
|
||||||
-k Lock page editing to current user only to prevent accidental
|
-c <file> Specify configuration file which should be used for reading
|
||||||
manual edits over Confluence Web UI.
|
Confluence page URL and markdown file path.
|
||||||
--dry-run Show resulting HTML and don't update Confluence page content.
|
-k Lock page editing to current user only to prevent accidental
|
||||||
--trace Enable trace logs.
|
manual edits over Confluence Web UI.
|
||||||
-h --help Show this screen and call 911.
|
--dry-run Show resulting HTML and don't update Confluence page content.
|
||||||
-v --version Show version.
|
--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
|
baseURL := url.Scheme + "://" + url.Host
|
||||||
|
|
||||||
if url.Host == "" {
|
if url.Host == "" {
|
||||||
baseURL, err = config.GetString("base_url")
|
var ok bool
|
||||||
if err != nil {
|
baseURL, ok = args["--base-url"].(string)
|
||||||
if zhash.IsNotFound(err) {
|
if !ok {
|
||||||
logger.Fatal(
|
baseURL, err = config.GetString("base_url")
|
||||||
"Confluence base URL should be specified using -l " +
|
if err != nil {
|
||||||
"flag or be stored in configuration file",
|
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