Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mechanism to reuse previous build image to speed up build time #1849

Merged
merged 3 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# base Go image version for building the binaries
FROM golang:1.13.10 AS build
ARG from=golang:1.13.10
FROM $from AS build
WORKDIR /app

COPY go.mod go.sum ./
Expand Down
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,27 @@ MINOR_VERSION := $(shell echo $(version) | cut -d . -f 1-2)
build: dep
./scripts/build-cli.sh "$(version)"

build-docker:
build-docker-cache:
# building cache image
docker build \
--build-arg version=$(version) \
--target build \
-t mesg/engine:$(version)-build \
.

build-docker-cache-if-needed:
if [ -z "$(shell docker images -q mesg/engine:$(version)-build)" ]; then \
make build-docker-cache ; \
fi

build-docker: build-docker-cache-if-needed
# building image
docker build \
--build-arg version=$(version) \
--build-arg from=mesg/engine:$(version)-build \
-t mesg/engine:$(version) \
.
# building dev image
docker build \
-f ./Dockerfile.dev \
--build-arg from=mesg/engine:$(version) \
Expand Down Expand Up @@ -82,7 +98,7 @@ protobuf: build-tools
changelog:
./scripts/changelog.sh $(milestone)

clean:
clean:
- rm -rf bin
- docker volume rm engine
- docker image rm $(shell docker images -q mesg/engine)
Expand Down