Bootstrap Makefile
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
This commit is contained in:
Родитель
99bf4dc073
Коммит
302eabe751
|
@ -1 +1,2 @@
|
|||
*.docker-app
|
||||
_build/
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
*.docker-app
|
||||
_build/
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
ARG GO_VERSION=1.10
|
||||
ARG RUN_BASE_TAG=3.7
|
||||
ARG BUILD_BASE_TAG=${GO_VERSION}-alpine${RUN_BASE_TAG}
|
||||
|
||||
FROM golang:${BUILD_BASE_TAG} AS build
|
||||
RUN apk add --no-cache \
|
||||
make
|
||||
WORKDIR /go/src/github.com/docker/lunchbox/
|
||||
COPY . .
|
||||
RUN make bin
|
||||
|
||||
FROM alpine:${RUN_BASE_TAG} AS run
|
||||
COPY --from=build /go/src/github.com/docker/lunchbox/_build/bin/docker-app /
|
||||
ENTRYPOINT ["/docker-app"]
|
|
@ -0,0 +1,29 @@
|
|||
ARG GO_VERSION=1.10
|
||||
ARG RUN_BASE_TAG=3.7
|
||||
ARG BUILD_BASE_TAG=${GO_VERSION}-alpine${RUN_BASE_TAG}
|
||||
|
||||
FROM golang:${BUILD_BASE_TAG}
|
||||
RUN apk add --no-cache \
|
||||
curl \
|
||||
git
|
||||
|
||||
ENV GOMETALITER_VERSION=2.0.5
|
||||
ENV NAKEDRECT_SHA=c0e305a4f690fed163d47628bcc06a6d5655bf92
|
||||
|
||||
WORKDIR /go/src/github.com/alecthomas/gometalinter
|
||||
RUN curl -L https://github.com/alecthomas/gometalinter/archive/v${GOMETALITER_VERSION}.tar.gz | tar xz --strip-components=1 \
|
||||
&& go build -v -o /usr/local/bin/gometalinter . \
|
||||
&& gometalinter --install \
|
||||
&& rm -rf /go/src/* /go/pkg/*
|
||||
|
||||
WORKDIR /go/src/github.com/alexkohler/nakedret
|
||||
RUN git clone https://github.com/alexkohler/nakedret.git /go/src/github.com/alexkohler/nakedret \
|
||||
&& go build -v -o /usr/local/bin/nakedret . \
|
||||
&& rm -rf /go/src/* /go/pkg/*
|
||||
|
||||
WORKDIR /go/src/github.com/docker/lunchbox
|
||||
ENV CGO_ENABLED=0
|
||||
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
|
||||
ENTRYPOINT ["/usr/local/bin/gometalinter"]
|
||||
CMD ["--config=gometalinter.json", "./..."]
|
||||
VOLUME ["/go/src/github.com/docker/lunchbox"]
|
|
@ -0,0 +1,48 @@
|
|||
PKG_NAME := github.com/docker/lunchbox
|
||||
BIN_NAME := docker-app
|
||||
|
||||
IMAGE_NAME := docker-app
|
||||
|
||||
GO_VERSION := 1.10
|
||||
RUN_BASE_TAG := 3.7
|
||||
|
||||
IMAGE_BUILD_ARGS := \
|
||||
--build-arg GO_VERSION=$(GO_VERSION) \
|
||||
--build-arg RUN_BASE_TAG=$(RUN_BASE_TAG)
|
||||
|
||||
LDFLAGS :=
|
||||
|
||||
EXEC_EXT :=
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXEC_EXT := .exe
|
||||
endif
|
||||
|
||||
all: bin test
|
||||
|
||||
CHECK_GO_ENV:
|
||||
@test $$(go list) = "$(PKG_NAME)" || \
|
||||
(echo "Invalid Go environment" && false)
|
||||
|
||||
bin: CHECK_GO_ENV
|
||||
@echo "Building _build/bin/$(BIN_NAME)$(EXEC_EXT)..."
|
||||
@go build -ldflags=$(LDFLAGS) -i -o _build/bin/$(BIN_NAME)$(EXEC_EXT) ./
|
||||
|
||||
image:
|
||||
@docker build -t $(IMAGE_NAME) $(IMAGE_BUILD_ARGS) . --target run
|
||||
|
||||
test: lint e2e-test
|
||||
|
||||
lint:
|
||||
@echo "Linting..."
|
||||
@tar -c Dockerfile.lint gometalinter.json | docker build -t $(IMAGE_NAME)-lint $(IMAGE_BUILD_ARGS) -f Dockerfile.lint - > /dev/null
|
||||
@docker run --rm -v $(dir $(realpath $(lastword $(MAKEFILE_LIST)))):/go/src/$(PKG_NAME) $(IMAGE_NAME)-lint
|
||||
|
||||
e2e-test:
|
||||
@echo "Running e2e tests..."
|
||||
@go test ./e2e/
|
||||
|
||||
clean:
|
||||
rm -Rf ./_build
|
||||
|
||||
.PHONEY: bin image test lint e2e-test clean
|
||||
.DEFAULT: all
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"Vendor": true,
|
||||
"Deadline": "2m",
|
||||
"Sort": ["linter", "severity", "path", "line"],
|
||||
"Exclude": [
|
||||
"cli/compose/schema/bindata.go",
|
||||
"cli/command/stack/kubernetes/api/openapi",
|
||||
"cli/command/stack/kubernetes/api/client",
|
||||
".*generated.*",
|
||||
"parameter .* always receives"
|
||||
],
|
||||
"EnableGC": true,
|
||||
"Linters": {
|
||||
"nakedret": {
|
||||
"Command": "nakedret",
|
||||
"Pattern": "^(?P<path>.*?\\.go):(?P<line>\\d+)\\s*(?P<message>.*)$"
|
||||
}
|
||||
},
|
||||
"WarnUnmatchedDirective": true,
|
||||
|
||||
"DisableAll": true,
|
||||
"Enable": [
|
||||
"deadcode",
|
||||
"gocyclo",
|
||||
"gofmt",
|
||||
"goimports",
|
||||
"golint",
|
||||
"gosimple",
|
||||
"ineffassign",
|
||||
"interfacer",
|
||||
"lll",
|
||||
"misspell",
|
||||
"nakedret",
|
||||
"unconvert",
|
||||
"unparam",
|
||||
"unused",
|
||||
"vet"
|
||||
],
|
||||
|
||||
"Cyclo": 16,
|
||||
"LineLength": 200
|
||||
}
|
Загрузка…
Ссылка в новой задаче