From 4e58b8302416437f3af8a938ee823b6297bcd50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Carr=C3=A9?= Date: Fri, 11 May 2018 18:45:49 +0100 Subject: [PATCH] Add org.opencontainers.image.* labels to Dockerfiles - This should ultimately help for image-to-code back references. - `org.label-schema.*` labels are now deprecated, in favour of `org.opencontainers.image.*` labels. See also: https://github.com/opencontainers/image-spec/blob/master/annotations.md#back-compatibility-with-label-schema - Git revision (`git rev-parse HEAD`) is now injected at `docker build` time. --- Makefile | 3 ++- backend/Dockerfile | 7 +++++++ client/Dockerfile | 7 +++++++ docker/Dockerfile.cloud-agent | 10 ++++++++-- docker/Dockerfile.scope | 7 +++++++ extras/dialer/Dockerfile | 7 +++++++ extras/example/Makefile | 3 ++- extras/example/app/Dockerfile | 8 +++++++- extras/example/client/Dockerfile | 8 +++++++- extras/example/echo/Dockerfile | 8 +++++++- extras/example/frontend-k8s/Dockerfile | 8 +++++++- extras/example/frontend/Dockerfile | 8 +++++++- extras/example/qotd/Dockerfile | 8 +++++++- extras/example/searchapp/Dockerfile | 8 +++++++- extras/example/shout/Dockerfile | 8 +++++++- extras/example/trace_app/Dockerfile | 8 +++++++- 16 files changed, 103 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 137612741c..ea2a30ab79 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ SCOPE_UI_BUILD_UPTODATE=.scope_ui_build.uptodate SCOPE_BACKEND_BUILD_IMAGE=$(DOCKERHUB_USER)/scope-backend-build SCOPE_BACKEND_BUILD_UPTODATE=.scope_backend_build.uptodate SCOPE_VERSION=$(shell git rev-parse --short HEAD) +GIT_REVISION=$(shell git rev-parse HEAD) WEAVENET_VERSION=2.1.3 RUNSVINIT=vendor/runsvinit/runsvinit CODECGEN_DIR=vendor/github.com/ugorji/go/codec/codecgen @@ -56,7 +57,7 @@ docker/%: % cp $* docker/ %.tar: docker/Dockerfile.% - $(SUDO) docker build -t $(DOCKERHUB_USER)/$* -f $< docker/ + $(SUDO) docker build --build-arg=revision=$(GIT_REVISION) -t $(DOCKERHUB_USER)/$* -f $< docker/ $(SUDO) docker tag $(DOCKERHUB_USER)/$* $(DOCKERHUB_USER)/$*:$(IMAGE_TAG) $(SUDO) docker save $(DOCKERHUB_USER)/$*:latest > $@ diff --git a/backend/Dockerfile b/backend/Dockerfile index 0f0b2bd455..ec2f884f52 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -21,3 +21,10 @@ RUN go get -tags netgo \ RUN pip install yapf==0.16.2 flake8==3.3.0 COPY build.sh / ENTRYPOINT ["/build.sh"] + +ARG revision +LABEL maintainer="Weaveworks " \ + org.opencontainers.image.title="backend" \ + org.opencontainers.image.source="https://github.com/weaveworks/scope/tree/master/backend" \ + org.opencontainers.image.revision="${revision}" \ + org.opencontainers.image.vendor="Weaveworks" diff --git a/client/Dockerfile b/client/Dockerfile index 3acd5d1d73..efaf528731 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -4,3 +4,10 @@ COPY package.json yarn.lock /home/weave/ ENV NPM_CONFIG_LOGLEVEL=warn NPM_CONFIG_PROGRESS=false RUN yarn --pure-lockfile COPY webpack.local.config.js webpack.production.config.js server.js .babelrc .eslintrc .eslintignore .stylelintrc .sass-lint.yml /home/weave/ + +ARG revision +LABEL maintainer="Weaveworks " \ + org.opencontainers.image.title="client" \ + org.opencontainers.image.source="https://github.com/weaveworks/scope" \ + org.opencontainers.image.revision="${revision}" \ + org.opencontainers.image.vendor="Weaveworks" diff --git a/docker/Dockerfile.cloud-agent b/docker/Dockerfile.cloud-agent index 69c79e6a16..edf768c862 100644 --- a/docker/Dockerfile.cloud-agent +++ b/docker/Dockerfile.cloud-agent @@ -1,9 +1,15 @@ FROM alpine:3.5 -LABEL maintainer="Weaveworks Inc " -LABEL works.weave.role=system WORKDIR /home/weave RUN apk add --update bash conntrack-tools iproute2 util-linux curl && \ rm -rf /var/cache/apk/* ADD ./weave ./weaveutil /usr/bin/ COPY ./scope /home/weave/ ENTRYPOINT ["/home/weave/scope", "--mode=probe", "--no-app", "--probe.docker=true"] + +ARG revision +LABEL works.weave.role="system" \ + maintainer="Weaveworks " \ + org.opencontainers.image.title="cloud-agent" \ + org.opencontainers.image.source="https://github.com/weaveworks/scope" \ + org.opencontainers.image.revision="${revision}" \ + org.opencontainers.image.vendor="Weaveworks" diff --git a/docker/Dockerfile.scope b/docker/Dockerfile.scope index 59657860d2..9f2dc28514 100644 --- a/docker/Dockerfile.scope +++ b/docker/Dockerfile.scope @@ -7,3 +7,10 @@ COPY ./run-app /etc/service/app/run COPY ./run-probe /etc/service/probe/run EXPOSE 4040 ENTRYPOINT ["/home/weave/entrypoint.sh"] + +ARG revision +LABEL maintainer="Weaveworks " \ + org.opencontainers.image.title="scope" \ + org.opencontainers.image.source="https://github.com/weaveworks/scope" \ + org.opencontainers.image.revision="${revision}" \ + org.opencontainers.image.vendor="Weaveworks" diff --git a/extras/dialer/Dockerfile b/extras/dialer/Dockerfile index 942f2c4eff..8ebdc9a82e 100644 --- a/extras/dialer/Dockerfile +++ b/extras/dialer/Dockerfile @@ -1,2 +1,9 @@ FROM golang:1.7 ADD ./bin/dialer /go/bin + +ARG revision +LABEL maintainer="Weaveworks " \ + org.opencontainers.image.title="dialer" \ + org.opencontainers.image.source="https://github.com/weaveworks/scope/tree/master/extras/dialer" \ + org.opencontainers.image.revision="${revision}" \ + org.opencontainers.image.vendor="Weaveworks" diff --git a/extras/example/Makefile b/extras/example/Makefile index f714546394..16dc22b850 100644 --- a/extras/example/Makefile +++ b/extras/example/Makefile @@ -1,6 +1,7 @@ CC=gcc CFLAGS=-g -lpthread BUILD_IN_CONTAINER=true +GIT_REVISION := $(shell git rev-parse HEAD) all: .qotd.marker .app.marker .client.marker .searchapp.marker .shout.marker .frontend.marker .frontend-k8s.marker .echo.marker .trace_app.marker @@ -33,7 +34,7 @@ endif .echo.marker: echo/* .trace_app.marker: trace_app/* .%.marker: - docker build -t tomwilkie/$(