From f79911d90f38a823caaf3f074c39d3066dc2bf3d Mon Sep 17 00:00:00 2001 From: Luis Gomez Date: Tue, 6 Jul 2021 20:59:01 -0700 Subject: [PATCH] Single docker image with default feature docker run --name odl-docker -d -p 8101:8101 -p 8181:8181 -e FEATURES="odl-restconf,odl-netconf-topology" odl-docker Signed-off-by: Luis Gomez Change-Id: I39d015eacb659dd607679be93d983c52f505f53a --- odl-docker/Dockerfile | 14 ++++++++++++-- odl-docker/install_docker.sh | 23 ++++++++++++++++------- odl-docker/start_docker.sh | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+), 9 deletions(-) create mode 100755 odl-docker/start_docker.sh diff --git a/odl-docker/Dockerfile b/odl-docker/Dockerfile index f22907c..744890e 100644 --- a/odl-docker/Dockerfile +++ b/odl-docker/Dockerfile @@ -8,7 +8,7 @@ # http://www.eclipse.org/legal/epl-v10.html ############################################################################## -FROM openjdk:11 +FROM openjdk:11 AS stage0 WORKDIR /opt/opendaylight @@ -18,6 +18,16 @@ RUN groupadd -r karaf --gid=8181 && \ useradd -rm -g karaf --uid=8181 karaf && \ chown -R karaf:karaf . +FROM scratch + +ENV JAVA_HOME /usr/local/openjdk-11 +ENV PATH $PATH:$JAVA_HOME/bin +ENV FEATURES odl-restconf + +COPY --from=stage0 / / + +WORKDIR /opt/opendaylight + USER karaf EXPOSE 8101 8181 -CMD ["bin/karaf", "run"] +CMD ./start_docker.sh diff --git a/odl-docker/install_docker.sh b/odl-docker/install_docker.sh index 7dae6c4..75ab619 100755 --- a/odl-docker/install_docker.sh +++ b/odl-docker/install_docker.sh @@ -1,12 +1,21 @@ #!/bin/bash +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2021 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + set -x -VERSION="0.14.1" -FEATURES="odl-restconf,odl-netconf-topology" +VERSION="14.1.0" BASEDIR=$(dirname "$0") -wget --progress=dot:mega -P /tmp https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/onap-karaf/${VERSION}/onap-karaf-${VERSION}.tar.gz -tar xzf /tmp/onap-karaf-${VERSION}.tar.gz --directory ${BASEDIR} -mv ${BASEDIR}/onap-karaf-${VERSION} ${BASEDIR}/opendaylight -sed -i "s/\(featuresBoot= \|featuresBoot = \)/featuresBoot = ${FEATURES},/g" ${BASEDIR}/opendaylight/etc/org.apache.karaf.features.cfg -cat ${BASEDIR}/opendaylight/etc/org.apache.karaf.features.cfg +wget --progress=dot:mega -P /tmp https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/opendaylight/${VERSION}/opendaylight-${VERSION}.tar.gz +tar xzf /tmp/opendaylight-${VERSION}.tar.gz --directory ${BASEDIR} +rm /tmp/opendaylight-${VERSION}.tar.gz +mv ${BASEDIR}/opendaylight-${VERSION} ${BASEDIR}/opendaylight +cp ${BASEDIR}/start_docker.sh ${BASEDIR}/opendaylight diff --git a/odl-docker/start_docker.sh b/odl-docker/start_docker.sh new file mode 100755 index 0000000..e8748ee --- /dev/null +++ b/odl-docker/start_docker.sh @@ -0,0 +1,18 @@ +#!/bin/bash -e +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2021 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +set -x + +BASEDIR=$(dirname "$0") + +sed -i "s/\(featuresBoot= \|featuresBoot = \)/featuresBoot = ${FEATURES},/g" ${BASEDIR}/etc/org.apache.karaf.features.cfg +cat ${BASEDIR}/etc/org.apache.karaf.features.cfg +${BASEDIR}/bin/karaf run -- 2.36.6