From d18f53f7c6b8187bd3306d5fab86987a2c466d66 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Wed, 3 Apr 2019 13:43:04 +0200 Subject: [PATCH] upd(build): dockerfiles and makefile update --- Dockerfile.crm => Dockerfile.api-crm | 0 ...file.messaging => Dockerfile.api-messaging | 0 Dockerfile.system => Dockerfile.api-system | 0 Dockerfile.crust | 34 +++++++++++++++++++ Dockerfile.crust-builder | 8 +++++ Makefile | 10 +++--- 6 files changed, 47 insertions(+), 5 deletions(-) rename Dockerfile.crm => Dockerfile.api-crm (100%) rename Dockerfile.messaging => Dockerfile.api-messaging (100%) rename Dockerfile.system => Dockerfile.api-system (100%) create mode 100644 Dockerfile.crust create mode 100644 Dockerfile.crust-builder diff --git a/Dockerfile.crm b/Dockerfile.api-crm similarity index 100% rename from Dockerfile.crm rename to Dockerfile.api-crm diff --git a/Dockerfile.messaging b/Dockerfile.api-messaging similarity index 100% rename from Dockerfile.messaging rename to Dockerfile.api-messaging diff --git a/Dockerfile.system b/Dockerfile.api-system similarity index 100% rename from Dockerfile.system rename to Dockerfile.api-system diff --git a/Dockerfile.crust b/Dockerfile.crust new file mode 100644 index 000000000..ce13d71d2 --- /dev/null +++ b/Dockerfile.crust @@ -0,0 +1,34 @@ +## == builder image == + +FROM golang:1.12-alpine AS builder + +WORKDIR /go/src/github.com/crusttech/crust + +COPY . . + +RUN apk add --no-cache git +RUN mkdir /build; \ + CGO_ENABLED=0 go build \ + -ldflags "-X github.com/crusttech/crust/internal/version.BuildTime="`date +%FT%T%z`" -X github.com/crusttech/crust/internal/version.Version="`git describe --always --tags` \ + -o /build/crust cmd/crust/*.go + +## == webapp image == + +FROM crusttech/webapp:latest as webapp + + + +## == target image == + +FROM alpine:3.7 + +RUN apk add --no-cache ca-certificates + +COPY --from=builder /build /crust +COPY --from=webapp /crust/webapp /crust/webapp + +EXPOSE 80 + +WORKDIR /crust + +ENTRYPOINT /crust/crust diff --git a/Dockerfile.crust-builder b/Dockerfile.crust-builder new file mode 100644 index 000000000..fb5431373 --- /dev/null +++ b/Dockerfile.crust-builder @@ -0,0 +1,8 @@ +FROM golang:1.12-alpine + +RUN apk add --no-cache git make bash && \ + go get -u github.com/golang/mock/gomock && \ + go get -u github.com/golang/mock/mockgen && \ + go get -u github.com/rakyll/gotest && \ + go get -u github.com/goware/statik && \ + cd /usr/local/bin && wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh && chmod a+x wait-for-it.sh \ No newline at end of file diff --git a/Makefile b/Makefile index 40b506aa8..50a38edc8 100644 --- a/Makefile +++ b/Makefile @@ -34,13 +34,13 @@ help: docker: $(IMAGES:%=docker-image.%) -docker-image.%: % - @ docker build --no-cache --rm -f Dockerfile.$^ -t crusttech/api-$^:latest . +docker-image.%: Dockerfile.% + @ docker build --no-cache --rm -f Dockerfile.$* -t crusttech/$*:latest . docker-push: $(IMAGES:%=docker-push.%) -docker-push.%: % - @ docker push crusttech/api-$^:latest +docker-push.%: Dockerfile.% + @ docker push crusttech/$*:latest ######################################################################################################################## @@ -50,7 +50,7 @@ realize: $(REALIZE) $(REALIZE) start dep.codegen: - go install github.com/titpetric/statik + go install github.com/goware/statik dep.update: $(DEP) $(DEP) ensure -update -v