Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 9feeadb

Browse files
committed
Refactor invocation image build
There were two different ways to build an invocation image, with this change there will be one and only one way. Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
1 parent 3582273 commit 9feeadb

6 files changed

Lines changed: 17 additions & 37 deletions

File tree

BUILDING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ go test -v -run "<TEST_NAME>" .
105105
```
106106

107107
**NOTE** if the tests fail with an error message like `"Error: manifest
108-
for docker/cnab-app-base:v0.6.0-68-g3ae57efdb6-dirty not found"`, it means
109-
you forgot to rebuild the base invocation image, simply run
108+
for docker/cnab-app-base:v0.6.0-68-g3ae57efdb6-dirty not found"`, it means
109+
you forgot to rebuild the base invocation image, simply run
110110

111111
```sh
112-
$ make invocation-image
112+
$ make -f docker.Makefile invocation-image
113113
```

Dockerfile

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
ARG ALPINE_VERSION=3.8
2-
ARG GO_VERSION=1.11.0
3-
41
FROM dockercore/golang-cross:1.11.5@sha256:17a7e0f158521c50316a0d0c1ab1f6a75350b4d82e7ef03c98bcfbdf04feb4f3 AS build
52
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
63

@@ -41,16 +38,3 @@ ARG EXPERIMENTAL="off"
4138
ARG TAG="unknown"
4239
# Run e2e tests
4340
RUN make EXPERIMENTAL=${EXPERIMENTAL} TAG=${TAG} e2e-cross
44-
45-
# builder of invocation image entrypoint
46-
FROM build AS invocation-build
47-
COPY . .
48-
ARG EXPERIMENTAL="off"
49-
RUN make EXPERIMENTAL=${EXPERIMENTAL} bin/cnab-run
50-
51-
# cnab invocation image
52-
FROM alpine:${ALPINE_VERSION} AS invocation
53-
RUN apk add --no-cache ca-certificates
54-
COPY --from=invocation-build /go/src/github.com/docker/app/bin/cnab-run /cnab/app/run
55-
WORKDIR /cnab/app
56-
CMD /cnab/app/run

Dockerfile.invocation-image

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
ARG ALPINE_VERSION=3.8
2-
ARG GO_VERSION=1.11.0
32

4-
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build
5-
ARG DOCKERCLI_VERSION=18.03.1-ce
6-
ARG DOCKERCLI_CHANNEL=edge
7-
RUN apk add --no-cache \
8-
make
3+
FROM dockercore/golang-cross:1.11.5@sha256:17a7e0f158521c50316a0d0c1ab1f6a75350b4d82e7ef03c98bcfbdf04feb4f3 AS build
4+
5+
RUN apt-get install -y -q --no-install-recommends \
6+
coreutils \
7+
util-linux \
8+
uuid-runtime
99

1010
WORKDIR /go/src/github.com/docker/app/
1111

12-
# builder of invocation image entrypoint
13-
FROM build AS invocation-build
1412
COPY . .
1513
ARG EXPERIMENTAL="off"
1614
RUN make EXPERIMENTAL=${EXPERIMENTAL} bin/cnab-run
1715

1816
# local cnab invocation image
1917
FROM alpine:${ALPINE_VERSION} as invocation
2018
RUN apk add --no-cache ca-certificates
21-
COPY --from=invocation-build /go/src/github.com/docker/app/bin/cnab-run /cnab/app/run
19+
COPY --from=build /go/src/github.com/docker/app/bin/cnab-run /cnab/app/run
2220
WORKDIR /cnab/app
2321
CMD /cnab/app/run

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ endif
2727
GO_BUILD := CGO_ENABLED=0 go build -tags=$(BUILDTAGS) -ldflags=$(LDFLAGS)
2828
GO_TEST := CGO_ENABLED=0 go test -tags=$(BUILDTAGS) -ldflags=$(LDFLAGS)
2929

30-
CNAB_BASE_INVOCATION_IMAGE_NAME := docker/cnab-app-base:$(BUILD_TAG)
31-
3230
all: bin/$(BIN_NAME) test
3331

3432
check_go_env:
@@ -99,9 +97,6 @@ specification/bindata.go: specification/schemas/*.json
9997

10098
schemas: specification/bindata.go ## generate specification/bindata.go from json schemas
10199

102-
invocation-image:
103-
docker build -f Dockerfile.invocation-image $(BUILD_ARGS) --target=invocation -t $(CNAB_BASE_INVOCATION_IMAGE_NAME) .
104-
105100
help: ## this help
106101
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
107102

docker.Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ E2E_CROSS_CTNR_NAME := $(BIN_NAME)-e2e-cross-$(TAG)
1515
COV_CTNR_NAME := $(BIN_NAME)-cov-$(TAG)
1616
SCHEMAS_CTNR_NAME := $(BIN_NAME)-schemas-$(TAG)
1717

18-
BUILD_ARGS=--build-arg=EXPERIMENTAL=$(EXPERIMENTAL) --build-arg=TAG=$(TAG) --build-arg=COMMIT=$(COMMIT)
18+
BUILD_ARGS=--build-arg=EXPERIMENTAL=$(EXPERIMENTAL) --build-arg=TAG=$(TAG) --build-arg=COMMIT=$(COMMIT) --build-arg=ALPINE_VERSION=$(ALPINE_VERSION)
1919

2020
PKG_PATH := /go/src/$(PKG_NAME)
2121

22-
CNAB_BASE_INVOCATION_IMAGE_NAME := docker/cnab-app-base:$(BUILD_TAG)
2322
PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME := docker/cnab-app-base:$(TAG)
2423
CNAB_BASE_INVOCATION_IMAGE_PATH := _build/invocation-image.tar
2524

@@ -113,7 +112,7 @@ specification/bindata.go: specification/schemas/*.json build_dev_image
113112
schemas: specification/bindata.go ## generate specification/bindata.go from json schemas
114113

115114
invocation-image:
116-
docker build $(BUILD_ARGS) --target=invocation -t $(CNAB_BASE_INVOCATION_IMAGE_NAME) .
115+
docker build -f Dockerfile.invocation-image $(BUILD_ARGS) --target=invocation -t $(CNAB_BASE_INVOCATION_IMAGE_NAME) .
117116

118117
save-invocation-image: invocation-image
119118
@$(call mkdir,_build)
@@ -126,4 +125,4 @@ push-invocation-image:
126125
help: ## this help
127126
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
128127

129-
.PHONY: lint test-e2e test-unit test cli-cross cross e2e-cross coverage gradle-test shell build_dev_image tars vendor schemas help invocation-image save-invocation-image push-invocation-image
128+
.PHONY: lint test-e2e test-unit test cli-cross cross e2e-cross coverage gradle-test shell build_dev_image tars vendor schemas help save-invocation-image push-invocation-image

vars.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ E2E_NAME := $(BIN_NAME)-e2e
55
# Enable experimental features. "on" or "off"
66
EXPERIMENTAL := off
77

8+
ALPINE_VERSION=3.8
9+
810
# Failing to resolve sh.exe to a full path denotes a windows vanilla shell.
911
# Although 'simple' commands are still exec'ed, 'complex' ones are batch'ed instead of sh'ed.
1012
ifeq ($(SHELL),sh.exe)
@@ -33,3 +35,5 @@ endif
3335
ifeq ($(TAG),)
3436
TAG := $(BUILD_TAG)
3537
endif
38+
39+
CNAB_BASE_INVOCATION_IMAGE_NAME := docker/cnab-app-base:$(BUILD_TAG)

0 commit comments

Comments
 (0)