New build logic for [AETHER-778], [AETHER-779] and [AETHER-782]
- Introduces 2 different tags for tost and tost-onos image
- Stable tag tracks stable commits; master tag tracks ONOS master and tip of the apps
- Updates README and help
- Deprecates the use of the VERSION file
- Uses actual hash for the docker labels
By default DOCKER_TAG points to stable
Change-Id: I7bdb2177b577065a1f4345248c406dcb41ba52a2
diff --git a/Dockerfile.tost b/Dockerfile.tost
index 5345b6e..984d1bb 100644
--- a/Dockerfile.tost
+++ b/Dockerfile.tost
@@ -14,9 +14,11 @@
# limitations under the License.
#
+ARG DOCKER_TAG
+
# We start from an onos image and install the apps.
# We need at least an onos image built with 'tost' profile
-FROM tost-onos as install
+FROM tost-onos:${DOCKER_TAG} as install
ARG KARAF_VERSION
ARG LOCAL_APPS
@@ -44,8 +46,10 @@
RUN chmod 755 ./app-install.sh
RUN ./app-install.sh
+ARG DOCKER_TAG
+
# Create the final image coping over the installed applications from the install stage
-FROM tost-onos
+FROM tost-onos:${DOCKER_TAG}
ARG KARAF_VERSION
diff --git a/Makefile b/Makefile
index b84e837..1ad7ec8 100644
--- a/Makefile
+++ b/Makefile
@@ -18,14 +18,14 @@
SHELL := /bin/bash -e -o pipefail
# General variables
-VERSION ?= $(shell cat ./VERSION)
THIS_MAKE := $(lastword $(MAKEFILE_LIST))
# Docker related
DOCKER_REGISTRY ?=
DOCKER_REPOSITORY ?=
DOCKER_BUILD_ARGS ?=
-DOCKER_TAG ?= ${VERSION}
+DOCKER_TAG ?= stable
+DOCKER_TAG_BUILD_DATE ?=
# Docker labels. Only set ref and commit date if committed
DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
@@ -38,22 +38,30 @@
DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)+dirty
endif
+ifeq ($(DOCKER_TAG),stable)
# Includes the default ("working") versions of each component
-include ./Makefile.vars
+ include ./Makefile.vars.stable
+else ifeq ($(DOCKER_TAG),master)
+# Includes the master versions of each component
+ include ./Makefile.vars.master
+else
+ $(error You must define properly the DOCKER_TAG variable)
+endif
+
# Shellcheck related
SHELLCHECK_TAG=v0.7.1
SHELLCHECK_IMAGE=koalaman/shellcheck:${SHELLCHECK_TAG}
# ONOS related
-ONOS_IMAGENAME := tost-onos
+ONOS_IMAGENAME := tost-onos:${DOCKER_TAG}${DOCKER_TAG_BUILD_DATE}
export ONOS_ROOT := $(shell pwd)/onos
ONOS_REPO := https://gerrit.onosproject.org/onos
ONOS_PROFILE := "tost"
KARAF_VERSION := 4.2.9
# TOST related
-TOST_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}tost:${DOCKER_TAG}
+TOST_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}tost:${DOCKER_TAG}${DOCKER_TAG_BUILD_DATE}
export LOCAL_APPS := local-apps
# Trellis-Control related
@@ -101,7 +109,8 @@
@echo "KAFKA_ONOS_VERSION : Override to use a specific branch/commit/tag/release to build the image"
@echo "FABRIC_TNA_VERSION : Override to use a specific branch/commit/tag/release to build the image"
@echo ""
- @echo "'Makefile.vars' defines default values for '*_VERSION' variables".
+ @echo "'Makefile.vars.stable' defines the stable values for '*_VERSION' variables".
+ @echo "'Makefile.vars.master' defines the tip values for '*_VERSION' variables".
@echo ""
## Make targets
@@ -290,19 +299,20 @@
tost-build: ## : Builds the tost docker image
docker build $(DOCKER_BUILD_ARGS) \
-t ${TOST_IMAGENAME} \
+ --build-arg DOCKER_TAG="${DOCKER_TAG}${DOCKER_TAG_BUILD_DATE}" \
--build-arg LOCAL_APPS=${LOCAL_APPS} \
--build-arg KARAF_VERSION=${KARAF_VERSION} \
- --build-arg org_label_schema_version="${VERSION}" \
+ --build-arg org_label_schema_version="${DOCKER_TAG}${DOCKER_TAG_BUILD_DATE}" \
--build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
--build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
--build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
- --build-arg org_onosproject_onos_version="${ONOS_VERSION}"\
- --build-arg org_onosproject_trellis_control_version="${TRELLIS_CONTROL_VERSION}"\
- --build-arg org_onosproject_trellis_t3_version="${TRELLIS_T3_VERSION}"\
- --build-arg org_opencord_fabric_tofino_version="${FABRIC_TOFINO_VERSION}"\
- --build-arg org_omecproject_up4_version="${UP4_VERSION}"\
- --build-arg org_opencord_kafka_onos_version="${KAFKA_ONOS_VERSION}"\
- --build-arg org_stratumproject_fabric_tna_version="${FABRIC_TNA_VERSION}"\
+ --build-arg org_onosproject_onos_version="$(shell cd ${ONOS_ROOT} && git rev-parse HEAD)"\
+ --build-arg org_onosproject_trellis_control_version="$(shell cd ${TRELLIS_CONTROL_ROOT} && git rev-parse HEAD)"\
+ --build-arg org_onosproject_trellis_t3_version="$(shell cd ${TRELLIS_T3_ROOT} && git rev-parse HEAD)"\
+ --build-arg org_opencord_fabric_tofino_version="$(shell cd ${FABRIC_TOFINO_ROOT} && git rev-parse HEAD)"\
+ --build-arg org_omecproject_up4_version="$(shell cd ${UP4_ROOT} && git rev-parse HEAD)"\
+ --build-arg org_opencord_kafka_onos_version="$(shell cd ${KAFKA_ONOS_ROOT} && git rev-parse HEAD)"\
+ --build-arg org_stratumproject_fabric_tna_version="$(shell cd ${FABRIC_TNA_ROOT} && git rev-parse HEAD)"\
-f Dockerfile.tost .
onos-push: ## : Pushes the tost-onos docker image to an external repository
diff --git a/Makefile.vars b/Makefile.vars.master
similarity index 77%
copy from Makefile.vars
copy to Makefile.vars.master
index 7525056..455f5b4 100644
--- a/Makefile.vars
+++ b/Makefile.vars.master
@@ -26,10 +26,10 @@
# (2) Checkout Local source code (local branch not yet pushed);
# (3) Fetch from Gerrit/Github (pending review in the form of refs/changes/... or pending pull request);
-export ONOS_VERSION ?= 2.2.7-b3
-export TRELLIS_CONTROL_VERSION ?= 3.0.0
-export TRELLIS_T3_VERSION ?= 3.0.0
-export FABRIC_TOFINO_VERSION ?= e1cf4551b4ab74bb82a7cecf19d197698ffbc1cb
-export UP4_VERSION ?= aeae3c4588f98ed1b863b3ee451e4bd48988716d
-export KAFKA_ONOS_VERSION ?= 2.4.0-SNAPSHOT
-export FABRIC_TNA_VERSION ?= 2268090aa5f973855923f8a52f4077557a90be47
+export ONOS_VERSION ?= master
+export TRELLIS_CONTROL_VERSION ?= 3.0.1-SNAPSHOT
+export TRELLIS_T3_VERSION ?= 4.0.0-SNAPSHOT
+export FABRIC_TOFINO_VERSION ?= master
+export UP4_VERSION ?= master
+export KAFKA_ONOS_VERSION ?= 2.5.0-SNAPSHOT
+export FABRIC_TNA_VERSION ?= master
diff --git a/Makefile.vars b/Makefile.vars.stable
similarity index 92%
rename from Makefile.vars
rename to Makefile.vars.stable
index 7525056..678dc99 100644
--- a/Makefile.vars
+++ b/Makefile.vars.stable
@@ -31,5 +31,5 @@
export TRELLIS_T3_VERSION ?= 3.0.0
export FABRIC_TOFINO_VERSION ?= e1cf4551b4ab74bb82a7cecf19d197698ffbc1cb
export UP4_VERSION ?= aeae3c4588f98ed1b863b3ee451e4bd48988716d
-export KAFKA_ONOS_VERSION ?= 2.4.0-SNAPSHOT
-export FABRIC_TNA_VERSION ?= 2268090aa5f973855923f8a52f4077557a90be47
+export KAFKA_ONOS_VERSION ?= 2.4.0
+export FABRIC_TNA_VERSION ?= 53e86f15024a097f24b77620bf8b6a4ed7079228
diff --git a/README.md b/README.md
index 67decdb..0895de4 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,9 @@
## Build
-We provide multiple build targets for the Makefile
+We provide multiple build targets for the Makefile. Versions of the components are defined in `Makefile.vars.*` files; `stable` version points to well known stable commits and `master` branch points to **ONOS** master and to the tip of the **TOST** components. **DOCKER_TAG** is used to select which version to build, by default points to `stable`.
-`onos-build` is used to build a specialized **Docker** image of **ONOS** (`tost-onos`) that will contain only the apps needed by **TOST**. It depends on `onos` target, which is used to setup the `onos` workspace for the build. It clones `onos` if it does not exist in the workspace, it will try to checkout the **ONOS_VERSION** first and in case of failure will try to download the patchset from remote repository. **ONOS_VERSION** is defined in `Makefile.vars`, overriding the variable at run time it is possible to build a different version of **ONOS**.
+`onos-build` is used to build a specialized **Docker** image of **ONOS** (`tost-onos`) that will contain only the apps needed by **TOST**. It depends on `onos` target, which is used to setup the `onos` workspace for the build. It clones `onos` if it does not exist in the workspace, it will try to checkout the **ONOS_VERSION** first and in case of failure will try to download the patchset from remote repository. **ONOS_VERSION** is defined in `Makefile.vars.DOCKER_TAG` file, overriding the variable at run time it is possible to build a different version of **ONOS**.
```sh
@@ -26,7 +26,7 @@
Makefile will build also the apps. These are the apps currently integrated in the script: **trellis-control**, **trellis-t3**, **fabric-tofino**, **up4**, **kafka-onos** and **fabric-tna**. For each one, there is a **build** target.
-`appname-build` builds with the version specified in the `Makefile.vars`, using the following sources in order: (1) Maven central (for released versions or snapshots); (2) Local source code (for local branch not yet pushed); (3) Gerrit/Github (for pending review in the form of refs/changes/... or pending pull request). As a prerequisite, the script prepares `mvn_settings.xml` file, creates the `local-apps` folder and checks out the code if it is not present (relies on `appname` target). **APPNAME_VERSION**, defined in `Makefile.vars`, can be overridden at runtime.
+`appname-build` builds with the version specified in the `Makefile.vars.DOCKER_TAG`, using the following sources in order: (1) Maven central (for released versions or snapshots); (2) Local source code (for local branch not yet pushed); (3) Gerrit/Github (for pending review in the form of refs/changes/... or pending pull request). As a prerequisite, the script prepares `mvn_settings.xml` file, creates the `local-apps` folder and checks out the code if it is not present (relies on `appname` target). **APPNAME_VERSION**, defined in `Makefile.vars.DOCKER_TAG` file, can be overridden at runtime.
```sh
diff --git a/VERSION b/VERSION
index 276823b..661235a 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1,2 @@
+# VERSION file is currently unused
1.0.2-SNAPSHOT