backport Dockerfile and docker build command

we got "build dependency yarn not installed" in CI when it tried to
build the release. The new Dockerfile has a separate lattice builder
which does "yarn install"
This commit is contained in:
Matthew Jaffee 2021-09-09 09:25:31 -05:00
parent 909e159aaa
commit ddfaa65d0e
2 changed files with 44 additions and 8 deletions

View file

@ -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

View file

@ -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: