-RUN git clone https://gerrit.opnfv.org/gerrit/functest ${repos_dir}/functest
-RUN git clone https://gerrit.opnfv.org/gerrit/releng ${repos_dir}/releng
-RUN git clone https://gerrit.opnfv.org/gerrit/doctor ${repos_dir}/doctor
-RUN git clone -b 0.5.0 https://github.com/openstack/rally.git ${repos_dir}/rally
-RUN git clone -b 12.1.0 https://github.com/openstack/tempest.git ${repos_dir}/tempest
-RUN git clone https://git.opendaylight.org/gerrit/p/integration/test.git ${repos_dir}/odl_test
-RUN git clone -b stable https://github.com/boucherv-orange/clearwater-live-test ${repos_dir}/vims-test
-RUN git clone https://github.com/openstack/networking-bgpvpn ${repos_dir}/bgpvpn
-RUN git clone https://github.com/wuwenbin2/OnosSystemTest.git ${repos_dir}/onos
-RUN git clone https://github.com/opnfv/promise ${repos_dir}/promise
-RUN git clone https://gerrit.opnfv.org/gerrit/ovno ${repos_dir}/ovno
-RUN git clone https://gerrit.opnfv.org/gerrit/copper ${repos_dir}/copper
-RUN git clone https://gerrit.opnfv.org/gerrit/moon ${repos_dir}/moon
-RUN git clone https://gerrit.opnfv.org/gerrit/sdnvpn ${repos_dir}/sdnvpn
-RUN git clone https://github.com/openstack/kingbird.git ${repos_dir}/kingbird
-RUN git clone https://gerrit.opnfv.org/gerrit/domino ${repos_dir}/domino
-RUN git clone https://gerrit.opnfv.org/gerrit/parser ${repos_dir}/parser
-RUN git clone https://gerrit.opnfv.org/gerrit/securityscanning ${repos_dir}/securityscanning
-
-RUN pip install -r ${repos_dir}/functest/docker/requirements.pip
-RUN pip install -r ${repos_dir}/rally/requirements.txt
-RUN pip install -r ${repos_dir}/tempest/requirements.txt
-
-RUN find ${repos_dir}/functest -name "*.py" |xargs grep __main__ |cut -d\: -f 1 |xargs chmod -c 755
-RUN find ${repos_dir}/functest -name "*.sh" |xargs grep \#\! |cut -d\: -f 1 |xargs chmod -c 755
-
-RUN /bin/bash ${repos_dir}/parser/tests/parser_install.sh ${repos_dir}
-RUN ${repos_dir}/rally/install_rally.sh --yes
-
-ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img /home/opnfv/functest/data/
-ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-lxc.tar.gz /home/opnfv/functest/data/
-ADD http://205.177.226.237:9999/onosfw/firewall_block_image.img /home/opnfv/functest/data/
+
+# OPNFV repositories
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/functest ${REPOS_DIR}/functest
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/copper ${REPOS_DIR}/copper
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/moon ${REPOS_DIR}/moon
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sdnvpn ${REPOS_DIR}/sdnvpn
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/domino ${REPOS_DIR}/domino
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/parser ${REPOS_DIR}/parser
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPOS_DIR}/doctor
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/ovno ${REPOS_DIR}/ovno
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REPOS_DIR}/promise
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sfc ${REPOS_DIR}/sfc
+RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/securityscanning ${REPOS_DIR}/securityscanning
+RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng ${REPOS_DIR}/releng
+
+# OpenStack repositories
+RUN git clone --depth 1 -b $OPENSTACK_TAG https://github.com/openstack/networking-bgpvpn ${REPOS_DIR}/bgpvpn
+#RUN git clone --depth 1 -b $KINGBIRD_TAG https://github.com/openstack/kingbird.git ${REPOS_DIR}/kingbird
+RUN git clone --depth 1 -b $RALLY_TAG https://github.com/openstack/rally.git ${REPOS_DIR}/rally
+RUN git clone --depth 1 -b $TEMPEST_TAG https://github.com/openstack/tempest.git ${REPOS_DIR}/tempest
+
+# other repositories
+RUN git clone --depth 1 -b $ODL_TAG https://git.opendaylight.org/gerrit/p/integration/test.git ${REPOS_DIR}/odl_test
+RUN git clone --depth 1 -b $VIMS_TAG https://github.com/boucherv-orange/clearwater-live-test ${REPOS_DIR}/vims-test
+RUN git clone --depth 1 https://github.com/wuwenbin2/OnosSystemTest.git ${REPOS_DIR}/onos
+
+RUN cd ${FUNCTEST_REPO_DIR} \
+ && pip install -r requirements.txt \
+ && pip install .
+
+RUN cd ${RELENG_MODULE_DIR} \
+ && pip install .
+
+RUN pip install -r ${REPOS_DIR}/rally/requirements.txt
+RUN pip install -r ${REPOS_DIR}/tempest/requirements.txt
+
+RUN find ${FUNCTEST_REPO_DIR} -name "*.py" \
+ -not -path "*tests/unit*" |xargs grep __main__ |cut -d\: -f 1 |xargs chmod -c 755 \
+ && find ${FUNCTEST_REPO_DIR} -name "*.sh" |xargs grep \#\! |cut -d\: -f 1 |xargs chmod -c 755
+
+RUN /bin/bash ${REPOS_DIR}/parser/tests/parser_install.sh ${REPOS_DIR}
+RUN ${REPOS_DIR}/rally/install_rally.sh --yes
+
+ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img ${FUNCTEST_BASE_DIR}/data/
+ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-lxc.tar.gz ${FUNCTEST_BASE_DIR}/data/
+ADD http://205.177.226.237:9999/onosfw/firewall_block_image.img ${FUNCTEST_BASE_DIR}/data/