From 8580492154e777a493f53bb95ce24d72518661dd Mon Sep 17 00:00:00 2001 From: Luis Gomez Date: Thu, 7 Jul 2022 18:39:05 -0700 Subject: [PATCH] Add docker phosphorus Change-Id: Id2947d6bf396de2114e7a1b0a31deb788933896c Signed-off-by: Luis Gomez --- docker/Dockerfile | 47 +++++++++++++++++++++++++++++++ docker/README.md | 13 +++++++++ docker/container-tag.yaml | 4 +++ docker/start_docker.sh | 18 ++++++++++++ docs/add-project-distribution.rst | 4 +-- 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md create mode 100644 docker/container-tag.yaml create mode 100755 docker/start_docker.sh diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..bcba69c7 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,47 @@ +# 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 +############################################################################## + +FROM openjdk:11-jdk-slim AS stage0 + +USER root + +RUN set -eux \ + && cd $HOME \ + && apt-get update \ + && apt-get install -y curl \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p /opt/opendaylight \ + && jlink --add-modules java.base,java.compiler,java.desktop,java.logging,java.management,java.naming,java.rmi,java.security.sasl,java.sql,java.xml,jdk.jfr,jdk.naming.rmi,jdk.xml.dom,jdk.unsupported --output /opt/openjdk-11 \ + && rm -rf /usr/local/openjdk-11 + +COPY start_docker.sh /opt/opendaylight + +FROM scratch as stage1 + +ENV JAVA_HOME /opt/openjdk-11 +ENV PATH $PATH:$JAVA_HOME/bin +ENV FEATURES odl-restconf-all + +WORKDIR /opt/opendaylight + +COPY --from=stage0 / / + +RUN set -eux \ + && curl https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/opendaylight/15.3.0/opendaylight-15.3.0.tar.gz | tar zxf - -C /opt/opendaylight/ --strip-components 1 \ + && groupadd -r karaf --gid=8181 \ + && useradd -rm -g karaf --uid=8181 karaf \ + && chown -R karaf:karaf /opt/opendaylight + +USER karaf + +EXPOSE 8101 +EXPOSE 8181 + +CMD ./start_docker.sh diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..5f4f507b --- /dev/null +++ b/docker/README.md @@ -0,0 +1,13 @@ +# OpenDaylight Docker Build + +Launch docker build task for ODL version 15.3.0 + +``` +$ docker build . -f Dockerfile -t opendaylight:15.3.0 +``` + +Run container + +``` +$ docker run -d -p 8181:8181 --env FEATURES=odl-restconf,odl-netconf-topology opendaylight:15.3.0 +``` diff --git a/docker/container-tag.yaml b/docker/container-tag.yaml new file mode 100644 index 00000000..8bf22e94 --- /dev/null +++ b/docker/container-tag.yaml @@ -0,0 +1,4 @@ +# The Jenkins job requires a tag to build the Docker image. +# Global-JJB script assumes this file is in the repo root. +--- +tag: 15.3.0 diff --git a/docker/start_docker.sh b/docker/start_docker.sh new file mode 100755 index 00000000..e8748ee2 --- /dev/null +++ b/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 diff --git a/docs/add-project-distribution.rst b/docs/add-project-distribution.rst index 5787f663..b944da96 100644 --- a/docs/add-project-distribution.rst +++ b/docs/add-project-distribution.rst @@ -235,6 +235,6 @@ every time a merge happens in the project. Follow the steps below to add this tr #. Push changes to releng/builder and wait for patch verification and review. -.. _managed-distribution: https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/karaf -.. _full-distribution: https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/opendaylight +.. _managed-distribution: https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/karaf +.. _full-distribution: https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/opendaylight .. _distribution-sanity: https://jenkins.opendaylight.org/releng/view/Sanity -- 2.36.6