diff --git a/README.md b/README.md index f4df61ce27240d915d5b615df2bbc41b5264bd35..f885890d9f564ffa2e290700e32242e7c4bd5005 100644 --- a/README.md +++ b/README.md @@ -4,30 +4,21 @@ This repository defines a set of Docker images and Docker compose files that are useful for TANGO control system development. ## Building the Docker images -It is recommended that you use the Docker compose files located in the root of -this repository to create a set of tagged docker images. The images created -by the Docker compose files comprise: - +The Docker images created by this project comprise: Docker image | Description -----------------------|------------ ska/tango-dependencies | A base image containing TANGO's preferred version of ZeroMQ plus the preferred, patched version of OmniORB. -ska/tangodb | A MariaDB image with TANGO database schema defined. Data is stored separately in a volume -ska/tango | Core C++ TANGO libraries and applications. -ska/tango-java | As per ska/tango, plus Java applications and bindings -ska/tango-python | As per ska/tango, plus pytango Python bindings and itango for interactive TANGO sessions. +ska/tango-db | A MariaDB image with TANGO database schema defined. 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. To build the images, from the root of this repository execute: - # build the TANGO dependency and core C++ images - docker-compose -f dependencies.yml -f tango.yml build - # build Docker images for Java and Python - docker-compose -f tango.yml -f tangotest.yml -f itango.yml build + cd docker + make build -Alternatively, images can be created by following the standard Docker image -build procedure using the Dockerfile definitions located in the `tango` directory. - - ## Launching a TANGO system The Docker compose files define a set of containers for a TANGO system. In addition to the processes to be launched, the files define the connections and diff --git a/docker/make/.make-release-support b/docker/make/.make-release-support new file mode 100644 index 0000000000000000000000000000000000000000..06ecbcc99be1619f0ea293452748845ebb2d0160 --- /dev/null +++ b/docker/make/.make-release-support @@ -0,0 +1,105 @@ +#!/bin/bash +# +# Copyright 2015 Xebia Nederland B.V. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +function hasChanges() { + test -n "$(git status -s .)" +} + +function getRelease() { + awk -F= '/^release=/{print $2}' .release +} + +function getBaseTag() { + sed -n -e "s/^tag=\(.*\)$(getRelease)\$/\1/p" .release +} + +function getTag() { + if [ -z "$1" ] ; then + awk -F= '/^tag/{print $2}' .release + else + echo "$(getBaseTag)$1" + fi +} + +function setRelease() { + if [ -n "$1" ] ; then + sed -i.x -e "s/^tag=.*/tag=$(getTag $1)/" .release + sed -i.x -e "s/^release=.*/release=$1/g" .release + rm -f .release.x + runPreTagCommand "$1" + else + echo "ERROR: missing release version parameter " >&2 + return 1 + fi +} + +function runPreTagCommand() { + if [ -n "$1" ] ; then + COMMAND=$(sed -n -e "s/@@RELEASE@@/$1/g" -e 's/^pre_tag_command=\(.*\)/\1/p' .release) + if [ -n "$COMMAND" ] ; then + if ! OUTPUT=$(bash -c "$COMMAND" 2>&1) ; then echo $OUTPUT >&2 && exit 1 ; fi + fi + else + echo "ERROR: missing release version parameter " >&2 + return 1 + fi +} + +function tagExists() { + tag=${1:-$(getTag)} + test -n "$tag" && test -n "$(git tag | grep "^$tag\$")" +} + +function differsFromRelease() { + tag=$(getTag) + ! tagExists $tag || test -n "$(git diff --shortstat -r $tag .)" +} + +function getVersion() { + result=$(getRelease) + + if differsFromRelease; then + result="$result-$(git log -n 1 --format=%h .)" + fi + + if hasChanges ; then + result="$result-dirty" + fi + echo $result +} + +function nextPatchLevel() { + version=${1:-$(getRelease)} + major_and_minor=$(echo $version | cut -d. -f1,2) + patch=$(echo $version | cut -d. -f3) + version=$(printf "%s.%d" $major_and_minor $(($patch + 1))) + echo $version +} + +function nextMinorLevel() { + version=${1:-$(getRelease)} + major=$(echo $version | cut -d. -f1); + minor=$(echo $version | cut -d. -f2); + version=$(printf "%d.%d.0" $major $(($minor + 1))) ; + echo $version +} + +function nextMajorLevel() { + version=${1:-$(getRelease)} + major=$(echo $version | cut -d. -f1); + version=$(printf "%d.0.0" $(($major + 1))) + echo $version +} diff --git a/docker/make/Makefile b/docker/make/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..cde96661fd4694d495b490148002beefc3d6dbe4 --- /dev/null +++ b/docker/make/Makefile @@ -0,0 +1,7 @@ +SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(SELF_DIR)/Makefile.mk + +REGISTRY_HOST= +USERNAME=ska +#NAME= + diff --git a/docker/make/Makefile.mk b/docker/make/Makefile.mk new file mode 100644 index 0000000000000000000000000000000000000000..41a1d38f6daccc7846c639fd43d1daf35f6b1789 --- /dev/null +++ b/docker/make/Makefile.mk @@ -0,0 +1,116 @@ +# +# Copyright 2015 Xebia Nederland B.V. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +REGISTRY_HOST=docker.io +USERNAME=$(USER) +NAME=$(shell basename $(CURDIR)) + +RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-release-support +#IMAGE=$(REGISTRY_HOST)/$(USERNAME)/$(NAME) +IMAGE=$(USERNAME)/$(NAME) + +VERSION=$(shell . $(RELEASE_SUPPORT) ; getVersion) +TAG=$(shell . $(RELEASE_SUPPORT); getTag) + +SHELL=/bin/bash + +DOCKER_BUILD_CONTEXT=. +DOCKER_FILE_PATH=Dockerfile + +.PHONY: pre-build docker-build post-build build release patch-release minor-release major-release tag check-status check-release showver \ + push pre-push do-push post-push + +build: pre-build docker-build post-build + +pre-build: + + +post-build: + + +pre-push: + + +post-push: + + + +docker-build: .release + docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) $(DOCKER_BUILD_CONTEXT) -f $(DOCKER_FILE_PATH) + @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 \ + echo docker tag -f $(IMAGE):$(VERSION) $(IMAGE):latest ;\ + docker tag -f $(IMAGE):$(VERSION) $(IMAGE):latest ;\ + else \ + echo docker tag $(IMAGE):$(VERSION) $(IMAGE):latest ;\ + docker tag $(IMAGE):$(VERSION) $(IMAGE):latest ; \ + fi + +.release: + @echo "release=0.0.0" > .release + @echo "tag=$(NAME)-0.0.0" >> .release + @echo INFO: .release created + @cat .release + + +release: check-status check-release build push + + +push: pre-push do-push post-push + +do-push: + docker push $(IMAGE):$(VERSION) + docker push $(IMAGE):latest + +snapshot: build push + +showver: .release + @. $(RELEASE_SUPPORT); getVersion + +tag-patch-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextPatchLevel) +tag-patch-release: .release tag + +tag-minor-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMinorLevel) +tag-minor-release: .release tag + +tag-major-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMajorLevel) +tag-major-release: .release tag + +patch-release: tag-patch-release release + @echo $(VERSION) + +minor-release: tag-minor-release release + @echo $(VERSION) + +major-release: tag-major-release release + @echo $(VERSION) + + +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) ; 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 + +check-status: + @. $(RELEASE_SUPPORT) ; ! hasChanges || (echo "ERROR: there are still outstanding changes" >&2 && exit 1) ; + +check-release: .release + @. $(RELEASE_SUPPORT) ; tagExists $(TAG) || (echo "ERROR: version not yet tagged in git. make [minor,major,patch]-release." >&2 && exit 1) ; + @. $(RELEASE_SUPPORT) ; ! differsFromRelease $(TAG) || (echo "ERROR: current directory differs from tagged $(TAG). make [minor,major,patch]-release." ; exit 1) diff --git a/docker/tango/Makefile b/docker/tango/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9284cda52e7100f545081d322c384290137d7e7b --- /dev/null +++ b/docker/tango/Makefile @@ -0,0 +1,28 @@ +TRGTS = tango-dependencies tango-db tango-cpp tango-java tango-python + +.PHONY: all build tango-dependencies tango-db tango-cpp tango-java tango-python + +all: build + +build: $(TRGTS) + +$(TRGTS): + $(MAKE) --directory=$@ $(TARGET) + $(if $(TARGET), $(MAKE) $(TARGET)) + + +tango-dependencies: + $(MAKE) -C tango-dependencies + +tango-db: + $(MAKE) -C tango-db + +tango-cpp: tango-dependencies + $(MAKE) -C tango-cpp + +tango-java: tango-dependencies + $(MAKE) -C tango-java + +tango-python: tango-dependencies + $(MAKE) -C tango-python + diff --git a/docker/tango/tango-cpp/.release b/docker/tango/tango-cpp/.release new file mode 100644 index 0000000000000000000000000000000000000000..37505c411994f6c7cb6c29f09ae5e18c4db4389e --- /dev/null +++ b/docker/tango/tango-cpp/.release @@ -0,0 +1,2 @@ +release=0.0.0 +tag=tango-cpp-0.0.0 diff --git a/tango/Dockerfile.base b/docker/tango/tango-cpp/Dockerfile similarity index 74% rename from tango/Dockerfile.base rename to docker/tango/tango-cpp/Dockerfile index b084934c48542c59893c2ce9f29bbb958c7d6d93..4a7eac40d8d369534118ab42794fad088a9b1c6f 100644 --- a/tango/Dockerfile.base +++ b/docker/tango/tango-cpp/Dockerfile @@ -1,4 +1,11 @@ -FROM ska/tango-dependencies:9.2.5a +FROM ska/tango-dependencies:latest + +# supervisor is installed so that the TANGO Starter device can run, one +# Starter process per container +RUN runtimeDeps='supervisor' \ + && DEBIAN_FRONTEND=noninteractive apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends $runtimeDeps \ + && rm -rf /var/lib/apt/lists/* 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-cpp/Makefile b/docker/tango/tango-cpp/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9f046a948604496191fe3dcfb695d21018b6435b --- /dev/null +++ b/docker/tango/tango-cpp/Makefile @@ -0,0 +1,7 @@ +include ../../make/Makefile + +pre-build: + @echo do some stuff before the docker build + +post-build: + @echo do some stuff after the docker build \ No newline at end of file diff --git a/docker/tango/tango-db/.release b/docker/tango/tango-db/.release new file mode 100644 index 0000000000000000000000000000000000000000..862c6191739cd4e9cedb5e8546379aad277fcae1 --- /dev/null +++ b/docker/tango/tango-db/.release @@ -0,0 +1,2 @@ +release=0.0.0 +tag=tango-db-0.0.0 diff --git a/tango/Dockerfile.db b/docker/tango/tango-db/Dockerfile similarity index 100% rename from tango/Dockerfile.db rename to docker/tango/tango-db/Dockerfile diff --git a/docker/tango/tango-db/Makefile b/docker/tango/tango-db/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9f046a948604496191fe3dcfb695d21018b6435b --- /dev/null +++ b/docker/tango/tango-db/Makefile @@ -0,0 +1,7 @@ +include ../../make/Makefile + +pre-build: + @echo do some stuff before the docker build + +post-build: + @echo do some stuff after the docker build \ No newline at end of file diff --git a/tango/sql_mode.cnf b/docker/tango/tango-db/sql_mode.cnf similarity index 100% rename from tango/sql_mode.cnf rename to docker/tango/tango-db/sql_mode.cnf diff --git a/docker/tango/tango-dependencies/.release b/docker/tango/tango-dependencies/.release new file mode 100644 index 0000000000000000000000000000000000000000..eee4ee40a3fdf38208c7b9c95b3815ea9084508b --- /dev/null +++ b/docker/tango/tango-dependencies/.release @@ -0,0 +1,2 @@ +release=0.0.0 +tag=tango-dependencies-0.0.0 diff --git a/tango/Dockerfile.dependencies b/docker/tango/tango-dependencies/Dockerfile similarity index 100% rename from tango/Dockerfile.dependencies rename to docker/tango/tango-dependencies/Dockerfile diff --git a/docker/tango/tango-dependencies/Makefile b/docker/tango/tango-dependencies/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9f046a948604496191fe3dcfb695d21018b6435b --- /dev/null +++ b/docker/tango/tango-dependencies/Makefile @@ -0,0 +1,7 @@ +include ../../make/Makefile + +pre-build: + @echo do some stuff before the docker build + +post-build: + @echo do some stuff after the docker build \ No newline at end of file diff --git a/tango/wait-for-it.sh b/docker/tango/tango-dependencies/wait-for-it.sh similarity index 100% rename from tango/wait-for-it.sh rename to docker/tango/tango-dependencies/wait-for-it.sh diff --git a/docker/tango/tango-java/.release b/docker/tango/tango-java/.release new file mode 100644 index 0000000000000000000000000000000000000000..4619ad74196be941cb45cf44927a1eb64b3ea491 --- /dev/null +++ b/docker/tango/tango-java/.release @@ -0,0 +1,2 @@ +release=0.0.0 +tag=tango-java-0.0.0 diff --git a/tango/Dockerfile.java b/docker/tango/tango-java/Dockerfile similarity index 97% rename from tango/Dockerfile.java rename to docker/tango/tango-java/Dockerfile index ee9115e77a0d3facfb60171372597b86105db81c..f1a03a9053695d9c0a548bf51a889d459836775d 100644 --- a/tango/Dockerfile.java +++ b/docker/tango/tango-java/Dockerfile @@ -1,4 +1,4 @@ -FROM ska/tango-dependencies:9.2.5a +FROM ska/tango-dependencies:latest RUN runtimeDeps='default-jre' \ && DEBIAN_FRONTEND=noninteractive apt-get update \ diff --git a/docker/tango/tango-java/Makefile b/docker/tango/tango-java/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9f046a948604496191fe3dcfb695d21018b6435b --- /dev/null +++ b/docker/tango/tango-java/Makefile @@ -0,0 +1,7 @@ +include ../../make/Makefile + +pre-build: + @echo do some stuff before the docker build + +post-build: + @echo do some stuff after the docker build \ No newline at end of file diff --git a/docker/tango/tango-python/.release b/docker/tango/tango-python/.release new file mode 100644 index 0000000000000000000000000000000000000000..e9de52a0e3e230c8766d10115ad83d5251efa5cc --- /dev/null +++ b/docker/tango/tango-python/.release @@ -0,0 +1,2 @@ +release=0.0.0 +tag=tango-python-0.0.0 diff --git a/tango/Dockerfile.python b/docker/tango/tango-python/Dockerfile similarity index 97% rename from tango/Dockerfile.python rename to docker/tango/tango-python/Dockerfile index 985e0dc764d43f28798dcfe5bbf1570baf866786..a1b8f1c1e3c6cf593173996ffd2acb935d7d8c41 100644 --- a/tango/Dockerfile.python +++ b/docker/tango/tango-python/Dockerfile @@ -1,4 +1,4 @@ -FROM ska/tango-base:9.2.5a +FROM ska/tango-cpp:latest USER root @@ -7,7 +7,7 @@ RUN runtimeDeps='ipython libboost-python1.62.0 python-concurrent.futures python- && apt-get -y install --no-install-recommends $runtimeDeps \ && rm -rf /var/lib/apt/lists/* -RUN PYTANGO_TAG=v9.2.2 \ +RUN PYTANGO_TAG=v9.2.4 \ && PYTANGO_URL=https://github.com/tango-cs/pytango.git \ && buildDeps='build-essential ca-certificates git libboost-python-dev python-dev python-setuptools python3-dev python3-setuptools' \ && DEBIAN_FRONTEND=noninteractive apt-get update \ diff --git a/docker/tango/tango-python/Makefile b/docker/tango/tango-python/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..9f046a948604496191fe3dcfb695d21018b6435b --- /dev/null +++ b/docker/tango/tango-python/Makefile @@ -0,0 +1,7 @@ +include ../../make/Makefile + +pre-build: + @echo do some stuff before the docker build + +post-build: + @echo do some stuff after the docker build \ No newline at end of file