Skip to content

Commit

Permalink
Merge pull request #1849 from mesg-foundation/feature/docker-build-cache
Browse files Browse the repository at this point in the history
Add a mechanism to reuse previous build image to speed up build time
  • Loading branch information
antho1404 authored Jun 3, 2020
2 parents 3f91776 + cc43866 commit 8f6377f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
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

0 comments on commit 8f6377f

Please sign in to comment.