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

Commit f009c0e

Browse files
Add the CNAB base invocation-image build target in the Dockerfile.
* Fix tag generation by truncating the git sha. * Fix saving cnab base image to a global tmp directory and put it in a local git ignored directory (_build). * Remove the cnab base image from the CI local daemon * Load invocation image directly instead of using a make target. Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
1 parent aba83a5 commit f009c0e

6 files changed

Lines changed: 203 additions & 72 deletions

File tree

.gitattributes

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
* text=auto
2-
*.sh text eol=lf
3-
*.go text eol=lf
2+
* text eol=lf
3+
*.png binary
44
*.exe binary
5-
vendor/** -text
5+
*.ico binary
6+
*.jar binary
7+
vendor/** -text

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ RUN curl -Ls https://download.docker.com/linux/static/$DOCKERCLI_CHANNEL/x86_64/
1717

1818
WORKDIR /go/src/github.com/docker/app/
1919

20+
# main dev image
2021
FROM build AS dev
2122
ENV PATH=${PATH}:/go/src/github.com/docker/app/bin/
2223
ARG DEP_VERSION=v0.5.0
@@ -36,12 +37,18 @@ RUN make EXPERIMENTAL=${EXPERIMENTAL} cross
3637
# FIXME(vdemeester) change from docker-app to dev once buildkit is merged in moby/docker
3738
FROM cross AS e2e-cross
3839
ARG EXPERIMENTAL="off"
40+
# Run e2e tests
3941
RUN make EXPERIMENTAL=${EXPERIMENTAL} e2e-cross
4042

4143
# builder of invocation image entrypoint
4244
FROM build AS invocation-build
4345
COPY . .
4446
ARG EXPERIMENTAL="off"
45-
ARG TAG
46-
ARG COMMIT
47-
RUN make EXPERIMENTAL=${EXPERIMENTAL} TAG=${TAG} COMMIT=${COMMIT} bin/run
47+
RUN make EXPERIMENTAL=${EXPERIMENTAL} bin/run
48+
49+
# cnab invocation image
50+
FROM alpine:${ALPINE_VERSION} AS invocation
51+
RUN apk add --no-cache ca-certificates
52+
COPY --from=invocation-build /go/src/github.com/docker/app/bin/run /cnab/app/run
53+
WORKDIR /cnab/app
54+
CMD /cnab/app/run

Jenkinsfile

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ pipeline {
1919
steps {
2020
dir('src/github.com/docker/app') {
2121
checkout scm
22-
sh 'make -f docker.Makefile lint'
23-
sh 'make -f docker.Makefile vendor'
22+
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG lint'
23+
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG vendor'
24+
}
25+
}
26+
post {
27+
always {
28+
deleteDir()
2429
}
2530
}
2631
}
@@ -33,7 +38,7 @@ pipeline {
3338
script {
3439
try {
3540
checkout scm
36-
sh 'make -f docker.Makefile cross e2e-cross tars'
41+
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG cross e2e-cross tars'
3742
dir('bin') {
3843
stash name: 'binaries'
3944
}
@@ -48,7 +53,7 @@ pipeline {
4853
archiveArtifacts 'bin/*.tar.gz'
4954
}
5055
} finally {
51-
def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm -f/
56+
def clean_images = /docker image ls --format="{{.ID}}" '*$BUILD_TAG*' | xargs docker image rm -f/
5257
sh clean_images
5358
}
5459
}
@@ -60,6 +65,28 @@ pipeline {
6065
}
6166
}
6267
}
68+
stage('Build Invocation image'){
69+
agent {
70+
label 'ubuntu-1604-aufs-edge'
71+
}
72+
steps {
73+
dir('src/github.com/docker/app') {
74+
checkout scm
75+
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG save-invocation-image'
76+
dir('_build') {
77+
stash name: 'invocation-image', includes: 'invocation-image.tar'
78+
}
79+
}
80+
}
81+
post {
82+
always {
83+
dir('src/github.com/docker/app') {
84+
sh 'docker rmi docker/cnab-app-base:$BUILD_TAG'
85+
}
86+
deleteDir()
87+
}
88+
}
89+
}
6390
}
6491
}
6592
stage('Test') {
@@ -71,11 +98,16 @@ pipeline {
7198
steps {
7299
dir('src/github.com/docker/app') {
73100
checkout scm
74-
sh 'make -f docker.Makefile coverage'
101+
sh 'make BUILD_TAG=$BUILD_TAG -f docker.Makefile coverage'
75102
archiveArtifacts '_build/ci-cov/all.out'
76103
archiveArtifacts '_build/ci-cov/coverage.html'
77104
}
78105
}
106+
post {
107+
always {
108+
deleteDir()
109+
}
110+
}
79111
}
80112
stage("Coverage (experimental)") {
81113
agent {
@@ -84,7 +116,12 @@ pipeline {
84116
steps {
85117
dir('src/github.com/docker/app') {
86118
checkout scm
87-
sh 'make EXPERIMENTAL=on -f docker.Makefile coverage'
119+
sh 'make EXPERIMENTAL=on BUILD_TAG=$BUILD_TAG -f docker.Makefile coverage'
120+
}
121+
}
122+
post {
123+
always {
124+
deleteDir()
88125
}
89126
}
90127
}
@@ -98,7 +135,7 @@ pipeline {
98135
dir("bin") {
99136
unstash "binaries"
100137
}
101-
sh 'make -f docker.Makefile gradle-test'
138+
sh 'make BUILD_TAG=$BUILD_TAG -f docker.Makefile gradle-test'
102139
}
103140
}
104141
post {
@@ -111,11 +148,16 @@ pipeline {
111148
agent {
112149
label 'ubuntu-1604-aufs-edge'
113150
}
114-
environment {
115-
DOCKERAPP_BINARY = '../docker-app-linux'
116-
}
151+
environment {
152+
DOCKERAPP_BINARY = '../docker-app-linux'
153+
}
117154
steps {
118155
dir('src/github.com/docker/app') {
156+
checkout scm
157+
dir('_build') {
158+
unstash "invocation-image"
159+
sh 'docker load -i invocation-image.tar'
160+
}
119161
unstash "binaries"
120162
dir('examples') {
121163
unstash "examples"
@@ -128,6 +170,7 @@ pipeline {
128170
}
129171
post {
130172
always {
173+
sh 'docker rmi docker/cnab-app-base:$BUILD_TAG'
131174
deleteDir()
132175
}
133176
}

0 commit comments

Comments
 (0)