diff --git a/README.md b/README.md index a036dbeceae9643d5186d083ca888e9a578bffa8..891f83c9e3b4c554cd11f14cb04061606908ed43 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,39 @@ are useful for TANGO control system development. ## Building the Docker images The following Docker images are built by this project: -Docker image | Description ------------------------|------------ -ska/tango-dependencies | A base image containing TANGO's preferred version of ZeroMQ plus the preferred, patched version of OmniORB. -ska/tango-db | A MariaDB image including TANGO database schema. Data is stored separately in a volume. -ska/tango-cpp | Core C++ TANGO libraries and applications. -ska/tango-java | As per ska/tango-cpp, plus Java applications and bindings -ska/tango-python | Extends ska/tango-cpp, adding PyTango Python bindings and itango for interactive TANGO sessions. -ska/tango-pogo | Image for running Pogo and displaying Pogo help. Pogo output can be persisted to a docker volume or to the host machine. -ska/tango-starter | Example image that demonstrates how to package the Starter device in an image. - -To build the images, from the root of this repository execute: +Docker image | Description +-------------------|------------ +tango-dependencies | A base image containing TANGO's preferred version of ZeroMQ plus the preferred, patched version of OmniORB. +tango-db | A MariaDB image including TANGO database schema. Data is stored separately in a volume. +tango-cpp | Core C++ TANGO libraries and applications. +tango-java | As per ska/tango-cpp, plus Java applications and bindings +tango-python | Extends ska/tango-cpp, adding PyTango Python bindings and itango for interactive TANGO sessions. +tango-pogo | Image for running Pogo and displaying Pogo help. Pogo output can be persisted to a docker volume or to the host machine. +tango-starter | Example image that demonstrates how to package the Starter device in an image. + +To build and register the images locally, from the root of this repository +execute: cd docker + # build and register TBC/tango-cpp, TBC/tango-jive, etc. locally make build - + +Optionally, you can register images to an alternative Docker registry account +by supplying the ``DOCKER_REGISTRY_HOST`` and ``DOCKER_REGISTRY_USER`` +Makefile variables, e.g., + + # build and register images as foo/tango-cpp, foo/tango-jive, etc. + make DOCKER_REGISTRY_USER=foo build + +Push the built images to a Docker registry using ``make push`` target. The +URL of the registry can be specified by providing the ``DOCKER_REGISTRY_HOST`` +Makefile argument. + + # push the images to the Docker registry, making them publicly + # available as foo/tango-cpp, foo/tango-jive, etc. + make DOCKER_REGISTRY_USER=foo DOCKER_REGISTRY_HOST=docker.io push + + ## Launching TANGO applications and services The docker-compose directory contains a set of files that can be used to run a TANGO system in Docker containers. The following services are defined: @@ -37,6 +55,18 @@ astor | Astor application starter-example | Example service running TANGO Starter device itango | interactive itango session +To pull pre-built images from the Docker hub, execute: + + cd docker-compose + # download official SKA images + make pull + +Optional: the images can be pulled from an alternative account by supplying +the DOCKER_REGISTRY_USER Makefile variable, e.g., + + cd docker-compose + # download foo/tango-cpp, foo/tango-jive, etc. + make DOCKER_REGISTRY_USER=foo pull To start and stop a minimal TANGO system (database and databaseds server), execute: diff --git a/docker-compose/.env b/docker-compose/.env new file mode 100644 index 0000000000000000000000000000000000000000..271ba908ed57ab3270afeaccfb42c7967d236b53 --- /dev/null +++ b/docker-compose/.env @@ -0,0 +1 @@ +DOCKER_REGISTRY_USER=tbd diff --git a/docker-compose/Makefile b/docker-compose/Makefile index 2de2f09209486ab0518b7b797b46f92c9c4e91d7..25b0a3ec33aa22f52351f22e15aaf13a89274ed3 100644 --- a/docker-compose/Makefile +++ b/docker-compose/Makefile @@ -22,16 +22,19 @@ endif MY_IP := $(shell ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -n1) DISPLAY = $(MY_IP):0 -.PHONY: up down minimal start stop status help +.PHONY: up down minimal start stop status clean pull help .DEFAULT_GOAL := help +pull: ## pull the images from the Docker hub + docker-compose $(COMPOSE_FILE_ARGS) pull + up: minimal ## start the base TANGO system and prepare all services DISPLAY=$(DISPLAY) docker-compose $(COMPOSE_FILE_ARGS) up --no-start down: ## stop all services and tear down the system DISPLAY=$(DISPLAY) docker-compose $(COMPOSE_FILE_ARGS) down -minimal: ## start the base TANGO system +minimal: ## start the base TANGO system docker-compose -f tango.yml up -d start: up ## start a service (usage: make start <servicename>) diff --git a/docker-compose/astor.yml b/docker-compose/astor.yml index 0b9a2fe7be69664f980457c6eea6ef097cf9f201..7c9110e5fee951c6459a4445f150c0838048adf9 100644 --- a/docker-compose/astor.yml +++ b/docker-compose/astor.yml @@ -13,9 +13,9 @@ version: '2' services: astor: - build: + build: context: ../docker/tango/tango-java - image: ska/tango-java:latest + image: ${DOCKER_REGISTRY_USER}/tango-java:latest container_name: astor depends_on: - databaseds @@ -36,7 +36,7 @@ services: starter-example: build: context: ../docker/tango/tango-starter - image: ska/tango-starter:latest + image: ${DOCKER_REGISTRY_USER}/tango-starter:latest container_name: starter-example # set the hostname, otherwise duplicate device registrations result every # time the hostname changes as the container is restarted. diff --git a/docker-compose/itango.yml b/docker-compose/itango.yml index 3d00177bb4c76768496e61d1cf80a7c3b5176ac7..4cc52aada41dc693d667010f4188158f6472b81c 100644 --- a/docker-compose/itango.yml +++ b/docker-compose/itango.yml @@ -16,8 +16,7 @@ services: itango: build: context: ../docker/tango/tango-python - dockerfile: Dockerfile.python - image: ska/tango-python:latest + image: ${DOCKER_REGISTRY_USER}/tango-python:latest container_name: itango depends_on: - databaseds diff --git a/docker-compose/jive.yml b/docker-compose/jive.yml index 0c65daa9cce782d09f770c054fc69aeaf48edd0a..1a60541d809a65dbb68081934055cf5502d2c469 100644 --- a/docker-compose/jive.yml +++ b/docker-compose/jive.yml @@ -14,7 +14,7 @@ services: jive: build: context: ../docker/tango/tango-java - image: ska/tango-java:latest + image: ${DOCKER_REGISTRY_USER}/tango-java:latest container_name: jive depends_on: - databaseds diff --git a/docker-compose/logviewer.yml b/docker-compose/logviewer.yml index 0af413dc6619cbde491fd12dc9309c684939593e..360c67b676152c8b71ac1dd303245b3a503e5d16 100644 --- a/docker-compose/logviewer.yml +++ b/docker-compose/logviewer.yml @@ -14,7 +14,7 @@ services: logviewer: build: context: ../docker/tango/tango-java - image: ska/tango-java:latest + image: ${DOCKER_REGISTRY_USER}/tango-java:latest container_name: logviewer depends_on: - databaseds diff --git a/docker-compose/pogo.yml b/docker-compose/pogo.yml index 0ff955c586a6716f035f720ddc71e8ff18edf88c..64a3d449141256b33ce5209884915466c78bba3e 100644 --- a/docker-compose/pogo.yml +++ b/docker-compose/pogo.yml @@ -22,7 +22,7 @@ services: pogo: build: context: ../docker/tango/tango-pogo - image: ska/tango-pogo:latest + image: ${DOCKER_REGISTRY_USER}/tango-pogo:latest container_name: pogo volumes: - pogo:/home/tango diff --git a/docker-compose/tango.yml b/docker-compose/tango.yml index 27e22f90f95059689833fa45a9c8ba88486db60a..c08a651080be481aab943cc4f9dd8cf114c4dad7 100644 --- a/docker-compose/tango.yml +++ b/docker-compose/tango.yml @@ -14,9 +14,9 @@ volumes: services: tangodb: - build: + build: context: ../docker/tango/tango-db - image: ska/tango-db:latest + image: ${DOCKER_REGISTRY_USER}/tango-db:latest container_name: tangodb environment: - MYSQL_ROOT_PASSWORD=secret @@ -27,9 +27,9 @@ services: - tangodb:/var/lib/mysql databaseds: - build: + build: context: ../docker/tango/tango-cpp - image: ska/tango-cpp:latest + image: ${DOCKER_REGISTRY_USER}/tango-cpp:latest container_name: databaseds hostname: databaseds depends_on: diff --git a/docker-compose/tangotest.yml b/docker-compose/tangotest.yml index 7d3440cbda6ad823237474fdacb6d112ea5d63f3..1461c3ae79949cce4c8b44dd812001535ff65873 100644 --- a/docker-compose/tangotest.yml +++ b/docker-compose/tangotest.yml @@ -13,7 +13,7 @@ services: tangotest: build: context: ../docker/tango/tango-java - image: ska/tango-java:latest + image: ${DOCKER_REGISTRY_USER}/tango-java:latest container_name: tangotest depends_on: - databaseds diff --git a/docker/make/Makefile b/docker/make/Makefile index cde96661fd4694d495b490148002beefc3d6dbe4..22634202eb9a8f18452e187598a1a703980ba9f9 100644 --- a/docker/make/Makefile +++ b/docker/make/Makefile @@ -1,7 +1,6 @@ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(SELF_DIR)/Makefile.mk -REGISTRY_HOST= -USERNAME=ska -#NAME= +DOCKER_REGISTRY_HOST= +DOCKER_REGISTRY_USER=tbd diff --git a/docker/make/Makefile.mk b/docker/make/Makefile.mk index 41a1d38f6daccc7846c639fd43d1daf35f6b1789..97102ab1a1a13a0941b1bd91cf7017f99b19e2c4 100644 --- a/docker/make/Makefile.mk +++ b/docker/make/Makefile.mk @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # -REGISTRY_HOST=docker.io -USERNAME=$(USER) +DOCKER_REGISTRY_HOST=docker.io +DOCKER_REGISTRY_USER=$(USER) NAME=$(shell basename $(CURDIR)) RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-release-support -#IMAGE=$(REGISTRY_HOST)/$(USERNAME)/$(NAME) -IMAGE=$(USERNAME)/$(NAME) +IMAGE=$(DOCKER_REGISTRY_USER)/$(NAME) VERSION=$(shell . $(RELEASE_SUPPORT) ; getVersion) TAG=$(shell . $(RELEASE_SUPPORT); getTag) @@ -48,7 +47,7 @@ post-push: docker-build: .release - docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) $(DOCKER_BUILD_CONTEXT) -f $(DOCKER_FILE_PATH) + docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) $(DOCKER_BUILD_CONTEXT) -f $(DOCKER_FILE_PATH) --build-arg DOCKER_REGISTRY_USER=$(DOCKER_REGISTRY_USER) @DOCKER_MAJOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f1) ; \ DOCKER_MINOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f2) ; \ if [ $$DOCKER_MAJOR -eq 1 ] && [ $$DOCKER_MINOR -lt 10 ] ; then \ @@ -80,14 +79,14 @@ snapshot: build push showver: .release @. $(RELEASE_SUPPORT); getVersion -tag-patch-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextPatchLevel) -tag-patch-release: .release tag +bump-patch-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextPatchLevel) +bump-patch-release: .release tag -tag-minor-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMinorLevel) -tag-minor-release: .release tag +bump-minor-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMinorLevel) +bump-minor-release: .release tag -tag-major-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMajorLevel) -tag-major-release: .release tag +bump-major-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMajorLevel) +bump-major-release: .release tag patch-release: tag-patch-release release @echo $(VERSION) @@ -101,12 +100,12 @@ major-release: tag-major-release release tag: TAG=$(shell . $(RELEASE_SUPPORT); getTag $(VERSION)) tag: check-status - @. $(RELEASE_SUPPORT) ; ! tagExists $(TAG) || (echo "ERROR: tag $(TAG) for version $(VERSION) already tagged in git" >&2 && exit 1) ; +# @. $(RELEASE_SUPPORT) ; ! tagExists $(TAG) || (echo "ERROR: tag $(TAG) for version $(VERSION) already tagged in git" >&2 && exit 1) ; @. $(RELEASE_SUPPORT) ; setRelease $(VERSION) - git add . - git commit -m "bumped to version $(VERSION)" ; - git tag $(TAG) ; - @ if [ -n "$(shell git remote -v)" ] ; then git push --tags ; else echo 'no remote to push tags to' ; fi +# git add . +# git commit -m "bumped to version $(VERSION)" ; +# git tag $(TAG) ; +# @ if [ -n "$(shell git remote -v)" ] ; then git push --tags ; else echo 'no remote to push tags to' ; fi check-status: @. $(RELEASE_SUPPORT) ; ! hasChanges || (echo "ERROR: there are still outstanding changes" >&2 && exit 1) ; diff --git a/docker/tango/Makefile b/docker/tango/Makefile index 879789af441d58b26af2e26f18ec3ea20e461aac..b6117722d3e79f53d582655197ba28f959a2a385 100644 --- a/docker/tango/Makefile +++ b/docker/tango/Makefile @@ -1,30 +1,35 @@ -TRGTS = tango-dependencies tango-db tango-cpp tango-java tango-python tango-starter tango-pogo +DIRS = tango-dependencies tango-db tango-cpp tango-java tango-python tango-starter tango-pogo +BUILDDIRS = $(DIRS:%=build-%) +CHECKSTATUSDIRS = $(DIRS:%=checkstatus-%) +SHOWVERDIRS = $(DIRS:%=showver-%) +PUSHDIRS = $(DIRS:%=push-%) -.PHONY: build tango-dependencies tango-db tango-cpp tango-java tango-python tango-starter tango-starter tango-pogo .DEFAULT_GOAL := help -build: $(TRGTS) ## build all images +build: $(DIRS) ## build all images +$(DIRS): $(BUILDDIRS) +$(BUILDDIRS): + $(MAKE) -C $(@:build-%=%) build -tango-dependencies: ## build base dependency image - $(MAKE) -C tango-dependencies +check-status: $(CHECKSTATUSDIRS) ## check whether subdirectories have uncommitted changes +$(CHECKSTATUSDIRS): + $(MAKE) -C $(@:checkstatus-%=%) check-status -tango-db: ## build ska/tango-db image - $(MAKE) -C tango-db +showver: $(SHOWVERDIRS) ## show image versions +$(SHOWVERDIRS): + $(MAKE) -C $(@:showver-%=%) showver -tango-cpp: tango-dependencies ## build ska/tango-cpp image - $(MAKE) -C tango-cpp - -tango-java: tango-dependencies ## build ska/tango-java image - $(MAKE) -C tango-java - -tango-python: tango-dependencies ## build ska/tango-python image - $(MAKE) -C tango-python - -tango-starter: tango-cpp ## build ska/tango-starter image - $(MAKE) -C tango-starter - -tango-pogo: tango-java ## build ska/tango-pogo image - $(MAKE) -C tango-pogo +push: $(PUSHDIRS) ## push images to Docker hub +$(PUSHDIRS): + $(MAKE) -C $(@:push-%=%) push help: ## show this help. @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: subdirs $(DIRS) +.PHONY: subdirs $(BUILDDIRS) +.PHONY: subdirs $(CHECKSTATUSDIRS) +.PHONY: subdirs $(PUSHDIRS) +.PHONY: subdirs $(SHOWVERDIRS) +.PHONY: build check-status showver push help + diff --git a/docker/tango/tango-cpp/Dockerfile b/docker/tango/tango-cpp/Dockerfile index 784066e1b9a9a842c09ca99dba6f94aa7b4d2dfd..5dd5ad2e7f1617eb571a83b6e5dfeaa43daa9ac0 100644 --- a/docker/tango/tango-cpp/Dockerfile +++ b/docker/tango/tango-cpp/Dockerfile @@ -1,4 +1,5 @@ -FROM ska/tango-dependencies:latest +ARG DOCKER_REGISTRY_USER +FROM ${DOCKER_REGISTRY_USER}/tango-dependencies:latest RUN TANGO_VERSION=9.2.5a \ && TANGO_DOWNLOAD_URL=https://netcologne.dl.sourceforge.net/project/tango-cs/tango-$TANGO_VERSION.tar.gz \ diff --git a/docker/tango/tango-java/Dockerfile b/docker/tango/tango-java/Dockerfile index f1a03a9053695d9c0a548bf51a889d459836775d..f739b0f1916f8272f20ab80b817ada45c10a0b20 100644 --- a/docker/tango/tango-java/Dockerfile +++ b/docker/tango/tango-java/Dockerfile @@ -1,4 +1,5 @@ -FROM ska/tango-dependencies:latest +ARG DOCKER_REGISTRY_USER +FROM ${DOCKER_REGISTRY_USER}/tango-dependencies:latest RUN runtimeDeps='default-jre' \ && DEBIAN_FRONTEND=noninteractive apt-get update \ diff --git a/docker/tango/tango-pogo/Dockerfile b/docker/tango/tango-pogo/Dockerfile index 09f34defb2a782dd2a6e3b4af11a6de368f0bd12..5f229f53a314939140f85ec543f6338ffebca632 100644 --- a/docker/tango/tango-pogo/Dockerfile +++ b/docker/tango/tango-pogo/Dockerfile @@ -1,4 +1,5 @@ -FROM ska/tango-java:latest +ARG DOCKER_REGISTRY_USER +FROM ${DOCKER_REGISTRY_USER}/tango-java:latest USER root diff --git a/docker/tango/tango-python/Dockerfile b/docker/tango/tango-python/Dockerfile index fdcc4ea03e3c96e0f25d23f161b312d2c99af1df..508a3a20059f21a87da930cf7b07371b3af8d74a 100644 --- a/docker/tango/tango-python/Dockerfile +++ b/docker/tango/tango-python/Dockerfile @@ -1,4 +1,5 @@ -FROM ska/tango-cpp:latest +ARG DOCKER_REGISTRY_USER +FROM ${DOCKER_REGISTRY_USER}/tango-cpp:latest USER root diff --git a/docker/tango/tango-starter/Dockerfile b/docker/tango/tango-starter/Dockerfile index 144d62a2dff28b5bb7681688f629bf3c04cf6607..115b84bc46633dcc7f485678b859f021c858d33b 100644 --- a/docker/tango/tango-starter/Dockerfile +++ b/docker/tango/tango-starter/Dockerfile @@ -1,4 +1,5 @@ -FROM ska/tango-cpp:latest +ARG DOCKER_REGISTRY_USER +FROM ${DOCKER_REGISTRY_USER}/tango-cpp:latest USER root