3
0

upd(build): add docker, docker-push

This commit is contained in:
Tit Petric
2018-08-27 13:59:54 +02:00
parent daf92fd947
commit 48ea1503de
4 changed files with 59 additions and 31 deletions

View File

@@ -1,3 +1,4 @@
*/templates
*/docs
*/db
build
codegen

View File

@@ -1,23 +0,0 @@
FROM golang:1.10-alpine AS builder
WORKDIR /go/src/github.com/crusttech/crust
ENV CGO_ENABLED=0
COPY . .
RUN mkdir /build; \
find cmd -type d -mindepth 1 -maxdepth 1 | while read CMDPATH; do \
go build -o /build/$(basename ${CMDPATH}) ${CMDPATH}/*.go; \
done;
FROM alpine:3.7
ENV PATH="/crust:{$PATH}"
WORKDIR /crust
# @todo copy crm/types, migrations
COPY --from=builder ./build/* /crust/
CMD ["/bin/echo", "Run of the crust commands: sam, crm"]

View File

@@ -1,4 +1,4 @@
.PHONY: build realize dep spec protobuf critic test test.rbac qa qa.test qa.vet codegen
.PHONY: nothing docker docker-push realize dep dep.update protobuf test test.rbac test.sam test.crm qa critic vet codegen
PKG = "github.com/$(shell cat .project)"
@@ -17,9 +17,29 @@ GOTEST = ${GOPATH}/bin/gotest
GOCRITIC = ${GOPATH}/bin/gocritic
MOCKGEN = ${GOPATH}/bin/mockgen
build:
docker build --no-cache --rm -t $(shell cat .project) .
nothing:
@echo
@echo Usage: make [target]
@echo
@echo - docker: builds docker images locally
@echo - docker-push: push built images
@echo
@echo - vet - run go vet on all code
@echo - critic - run go critic on all code
@echo - test.crm - individual package unit tests
@echo - test.sam - individual package unit tests
@echo - test.rbac - individual package unit tests
@echo - test - run all available unit tests
@echo - qa - run vet, critic and test on code
@echo
docker:
docker build --no-cache --rm --build-arg APP=sam -f docker/Dockerfile -t crusttech/sam .
docker build --no-cache --rm --build-arg APP=crm -f docker/Dockerfile -t crusttech/crm .
docker-push:
docker push crusttech/sam
docker push crusttech/crm
########################################################################################################################
# Development
@@ -44,9 +64,6 @@ protobuf: $(PROTOC)
########################################################################################################################
# QA
critic: $(GOCRITIC)
PATH=${PATH}:${GOPATH}/bin $(GOCRITIC) check-project .
test: $(GOTEST)
$(GOTEST) -covermode count -coverprofile .cover.out -v ./...
$(GO) tool cover -func=.cover.out
@@ -64,7 +81,10 @@ test.rbac: $(GOTEST)
$(GO) tool cover -func=.cover.out | grep --color "^\|[^0-9]0.0%"
vet:
$(GO) vet `cd ${GOPATH}/src/; find $(PKG) -type f -name '*.go' -and -not -path '*vendor*'|xargs -n1 dirname|uniq`
$(GO) vet ./...
critic: $(GOCRITIC)
$(GOCRITIC) check-project .
qa: vet critic test

30
docker/Dockerfile Normal file
View File

@@ -0,0 +1,30 @@
## builder image
FROM golang:1.10-alpine AS builder
WORKDIR /go/src/github.com/crusttech/crust
ARG APP
ENV APP=$APP
ENV CGO_ENABLED=0
COPY . .
RUN mkdir /build; go build -o /build/$APP cmd/$APP/*.go
## target image
FROM alpine:3.7
ENV PATH="/crust:{$PATH}"
WORKDIR /crust
# @todo copy crm/types, migrations
COPY --from=builder /build/* /crust/
ARG APP
ENV APP=$APP
ENTRYPOINT /crust/$APP