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

Commit 2ce3fac

Browse files
authored
Merge pull request #456 from rumpl/feat-local-invocation-image
Build invocation image locally
2 parents 941df3f + 9feeadb commit 2ce3fac

5 files changed

Lines changed: 33 additions & 25 deletions

File tree

BUILDING.md

Lines changed: 5 additions & 5 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

111-
```sh
112-
$ make -f docker.Makefile invocation-image
113-
```
111+
```sh
112+
$ make -f docker.Makefile invocation-image
113+
```

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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ARG ALPINE_VERSION=3.8
2+
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
9+
10+
WORKDIR /go/src/github.com/docker/app/
11+
12+
COPY . .
13+
ARG EXPERIMENTAL="off"
14+
RUN make EXPERIMENTAL=${EXPERIMENTAL} bin/cnab-run
15+
16+
# local cnab invocation image
17+
FROM alpine:${ALPINE_VERSION} as invocation
18+
RUN apk add --no-cache ca-certificates
19+
COPY --from=build /go/src/github.com/docker/app/bin/cnab-run /cnab/app/run
20+
WORKDIR /cnab/app
21+
CMD /cnab/app/run

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)