diff --git a/Dockerfile b/Dockerfile index 969396a74..20170e420 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,46 @@ -FROM golang:latest as builder +ARG GO_VERSION=latest -ARG BUILD_FLAGS +####################### +### Lattice builder ### +####################### + +FROM moleculacorp/nodejs:latest as lattice-builder +WORKDIR /lattice + +COPY lattice/package.json ./ +COPY lattice/yarn.lock ./ +RUN yarn install + +COPY lattice ./ +RUN yarn build + +###################### +### Pilosa builder ### +###################### + +FROM golang:${GO_VERSION} as pilosa-builder ARG MAKE_FLAGS +WORKDIR /pilosa -COPY . pilosa +RUN go get github.com/rakyll/statik -RUN cd pilosa && make install FLAGS="-a -mod=vendor ${BUILD_FLAGS}" ${MAKE_FLAGS} +COPY . ./ +COPY --from=lattice-builder /lattice/build /lattice +RUN /go/bin/statik -src=/lattice -dest=/pilosa -FROM alpine:3.12.1 +RUN make build FLAGS="-o build/pilosa" ${MAKE_FLAGS} -LABEL maintainer "dev@pilosa.com" +##################### +### Pilosa runner ### +##################### + +FROM alpine:3.13.2 as runner + +LABEL maintainer "dev@molecula.com" RUN apk add --no-cache curl jq -COPY --from=builder /go/bin/pilosa /pilosa +COPY --from=pilosa-builder /pilosa/build/pilosa / COPY LICENSE /LICENSE COPY NOTICE /NOTICE diff --git a/Makefile b/Makefile index 263a7a165..4153c2ab8 100644 --- a/Makefile +++ b/Makefile @@ -212,7 +212,16 @@ docker-release: check-clean generate-statik # Compile Pilosa inside Docker container docker-build: vendor - docker run --rm -v $(PWD):/go/src/$(CLONE_URL) -w /go/src/$(CLONE_URL) -e GOOS=$(GOOS) -e GOARCH=$(GOARCH) golang:$(GO_VERSION) make build FLAGS="$(FLAGS) -mod=vendor" RELEASE=$(RELEASE) + docker build \ + --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg MAKE_FLAGS="GOOS=$(GOOS) GOARCH=$(GOARCH)" \ + --target pilosa-builder \ + --tag pilosa:build . + docker create --name pilosa-build pilosa:build + mkdir -p build/pilosa-$(VERSION_ID) + docker cp pilosa-build:/pilosa/build/. ./build/pilosa-$(VERSION_ID) + docker rm pilosa-build + tar -cvz -C build -f build/pilosa-$(VERSION_ID).tar.gz pilosa-$(VERSION_ID)/ # Install diagnostic pilosa-keydump tool. Allows viewing the keys in a transaction-engine directory. pilosa-keydump: