Add docker build file 41/11041/1
authorBin Yang <bin.yang@windriver.com>
Fri, 8 Sep 2017 07:50:05 +0000 (15:50 +0800)
committerBin Yang <bin.yang@windriver.com>
Fri, 8 Sep 2017 07:50:05 +0000 (15:50 +0800)
add docker build file to generate container image

Change-Id: I08e289dea8caf01b9690d80c2c21355d0f121a6b
Issue-Id: MULTICLOUD-58
Signed-off-by: Bin Yang <bin.yang@windriver.com>
newton/docker/Dockerfile [new file with mode: 0644]
newton/docker/build-image.sh [new file with mode: 0644]
newton/pom.xml
newton/run.sh
newton/stop.sh

diff --git a/newton/docker/Dockerfile b/newton/docker/Dockerfile
new file mode 100644 (file)
index 0000000..e8440e1
--- /dev/null
@@ -0,0 +1,24 @@
+FROM python:2
+
+ENV MSB_ADDR "127.0.0.1"
+ENV MSB_PORT "80"
+ENV AAI_ADDR "aai.api.simpledemo.openecomp.org"
+ENV AAI_PORT "8443"
+ENV AAI_SCHEMA_VERSION "v11"
+ENV AAI_USERNAME "AAI"
+ENV AAI_PASSWORD "AAI"
+
+EXPOSE 9003
+
+# COPY ./ /opt/newton/
+RUN apt-get update && \
+    apt-get install -y memcached && \
+    apt-get install -y unzip && \
+    cd /opt/ && \
+    wget -O multicloud-openstack-newton.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.multicloud.openstack&a=multicloud-openstack-newton&e=zip&v=LATEST" && \
+    unzip -q -o -B multicloud-openstack-newton.zip && \
+    rm -f multicloud-openstack-newton.zip && \
+    pip install -r /opt/newton/requirements.txt
+
+WORKDIR /opt/newton
+CMD /bin/sh -c /opt/newton/run.sh
\ No newline at end of file
diff --git a/newton/docker/build-image.sh b/newton/docker/build-image.sh
new file mode 100644 (file)
index 0000000..8d5fe47
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+IMAGE="multicloud-openstack-newton"
+VERSION="latest"
+
+docker build -t ${IMAGE}:${VERSION} .
index e198949..555f3b5 100644 (file)
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
         <groupId>org.onap.oparent</groupId>
         <artifactId>oparent</artifactId>
         </plugin>
       </plugins>
     </build>
+    <profiles>
+        <profile>
+            <id>docker</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>io.fabric8</groupId>
+                        <artifactId>docker-maven-plugin</artifactId>
+                        <version>0.16.5</version>
+                        <inherited>false</inherited>
+                        <configuration>
+                            <images>
+                                <image>
+                                    <name>onap/multicloud/multicloud-openstack-newton</name>
+                                    <build>
+                                        <cleanup>try</cleanup>
+                                        <dockerFileDir>${basedir}/docker/</dockerFileDir>
+                                        <dockerFile>${basedir}/docker/Dockerfile</dockerFile>
+                                        <tags>
+                                            <tag>${project.version}-STAGING-latest</tag>
+                                        </tags>
+                                    </build>
+                                </image>
+                            </images>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>generate-images</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>build</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>push-images</id>
+                                <phase>deploy</phase>
+                                <goals>
+                                    <goal>build</goal>
+                                    <goal>push</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>
index 8b8b089..763f72d 100755 (executable)
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
-nohup python manage.py runserver 127.0.0.1:9003 > /dev/null &
+#!/bin/bash
+
+sed -i "s/MSB_SERVICE_ADDR =.*/MSB_SERVICE_ADDR = \"${MSB_ADDR}\"/g" newton/pub/config/config.py
+sed -i "s/MSB_SERVICE_PORT =.*/MSB_SERVICE_PORT = \"${MSB_PORT}\"/g" newton/pub/config/config.py
+sed -i "s/AAI_ADDR =.*/AAI_ADDR = \"${AAI_ADDR}\"/g" newton/pub/config/config.py
+sed -i "s/AAI_PORT =.*/AAI_PORT = \"${AAI_PORT}\"/g" newton/pub/config/config.py
+sed -i "s/AAI_SCHEMA_VERSION =.*/AAI_SCHEMA_VERSION = \"${AAI_SCHEMA_VERSION}\"/g" newton/pub/config/config.py
+sed -i "s/AAI_USERNAME =.*/AAI_USERNAME = \"${AAI_USERNAME}\"/g" newton/pub/config/config.py
+sed -i "s/AAI_PASSWORD =.*/AAI_PASSWORD = \"${AAI_PASSWORD}\"/g" newton/pub/config/config.py
+
+memcached -d -m 2048 -u root -c 1024 -p 11211 -P /tmp/memcached1.pid
+
+nohup python manage.py runserver 0.0.0.0:9003 2>&1 &
+
+while [ ! -f logs/runtime_newton.log ]; do
+    sleep 1
+done
+
+tail -F logs/runtime_newton.log
index db6d736..1abfe40 100755 (executable)
@@ -10,4 +10,5 @@
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
-ps auxww | grep 'manage.py runserver 127.0.0.1:9003' | awk '{print $2}' | xargs kill -9
+ps auxww | grep 'manage.py runserver 0.0.0.0:9003' | awk '{print $2}' | xargs kill -9
+ps auxww | grep 'memcached -d -m 2048 -u root -c 1024 -p 11211 -P /tmp/memcached1.pid' | awk '{print $2}' | xargs kill -9