fixes docker container building issues

This commit is contained in:
Ronald Steinke 2018-05-22 13:20:42 +02:00
parent 692f55f6af
commit aecf7c0c02
6 changed files with 27 additions and 20 deletions

View File

@ -1,6 +1,6 @@
import re
from flask import Flask, Response, request
from gevent import wsgi
from gevent.pywsgi import WSGIServer
from openmtc_app.onem2m import ResourceManagementXAE
from orion_api import OrionAPI
@ -10,7 +10,7 @@ class OrionContextBroker(ResourceManagementXAE):
def __init__(self,
orion_host="http://localhost:1026",
orion_api="v2",
labels=["openmtc:sensor_data"],
labels=None,
accumulate_address="http://localhost:8080",
*args,
**kw):
@ -19,11 +19,12 @@ class OrionContextBroker(ResourceManagementXAE):
self.labels = {labels}
elif hasattr(labels, '__iter__'):
self.labels = set(labels)
elif labels is None:
self.labels = ["openmtc:sensor_data"]
else:
self.labels = None
self._entity_names = {}
self._subscriptions = {}
self.logger.critical(accumulate_address)
self.orion_api = OrionAPI(
orion_host=orion_host,
api_version=orion_api,
@ -38,8 +39,8 @@ class OrionContextBroker(ResourceManagementXAE):
methods=["POST"])
accumulate_ip, accumulate_port = accumulate_address.split('//')[
1].split(':')
self.server = wsgi.WSGIServer(("0.0.0.0", int(accumulate_port)),
self.app)
self.server = WSGIServer(("0.0.0.0", int(accumulate_port)),
self.app)
self.server.start()
def process_notification(self):
@ -59,7 +60,8 @@ class OrionContextBroker(ResourceManagementXAE):
else:
return True
def _get_entity_name(self, sensor_info):
@staticmethod
def _get_entity_name(sensor_info):
device_type = "sensor" if sensor_info.get("sensor_labels",
None) else "actuator"
try:
@ -113,6 +115,6 @@ class OrionContextBroker(ResourceManagementXAE):
self.orion_api.update_attributes(
entity_name, data_dummy, fiware_service=fiware_service)
subscriptionId = self.orion_api.subscribe(
subscription_id = self.orion_api.subscribe(
entity_name, fiware_service=fiware_service)
self._subscriptions[subscriptionId] = actuator_info['ID']
self._subscriptions[subscription_id] = actuator_info['ID']

View File

@ -260,6 +260,14 @@ rm -f "${target_docker_binary}"
rm -f "${docker_tmp}/${name}-dependencies.txt"
${docker_cmd} rm -f ${build_container_name} &> /dev/null
printf "done\n"
# remove dangling images
separator_line
printf "### Removing dangled images..."
for image in $(${docker_cmd} images -qa -f "dangling=true"); do
${docker_cmd} rmi -f ${image} > /dev/null
done
printf "done\n"
}
trap cleanup SIGINT SIGTERM
@ -391,7 +399,7 @@ printf "%s\n" $(get_requirements_from_setup_file) | tr " " "\n" > \
separator_line
printf "### Building %s-%s container...\n" ${name} ${machine}
${docker_cmd} build -t ${target_docker_name} \
${docker_cmd} build --force-rm -t ${target_docker_name} \
-f ${target_docker_file} ${docker_path}
if [ $? -gt 0 ]; then
printf "### Building %s-%s container failed. Exiting now.\n" \
@ -405,15 +413,6 @@ printf "### Base %s-%s container built successfully.\n" ${name} ${machine}
# cleanup
cleanup
##############################################################################
# remove dangling images
separator_line
printf "### Removing dangled images..."
for image in $(${docker_cmd} images -qa -f "dangling=true"); do
${docker_cmd} rmi -f ${image} > /dev/null
done
printf "done\n"
##############################################################################
# example to run the docker file
#${docker_cmd} run --name test -d \

View File

@ -10,6 +10,9 @@ ENV MOD_NAME=sdk
# Set the file maintainer
MAINTAINER rst/tgu
# update pip to latest version
RUN pip install --upgrade pip
# install openmtc dependencies
COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt
RUN pip install --upgrade --requirement /tmp/requirements.txt

View File

@ -10,6 +10,9 @@ ENV MOD_NAME=sdk
# Set the file maintainer
MAINTAINER rst/tgu
# update pip to latest version
RUN pip install --upgrade pip
# install openmtc dependencies
COPY tmp/$MOD_NAME-dependencies.txt /tmp/requirements.txt
RUN pip install --upgrade --requirement /tmp/requirements.txt

View File

@ -4,7 +4,7 @@
# or $ sudo pip install --requirement dependencies.txt
urllib3
gevent>=1.0
gevent>=1.1
iso8601>=0.1.5
werkzeug>=0.9
funcy

View File

@ -6,7 +6,7 @@ from operator import itemgetter
from socket import AF_INET, AF_INET6, getaddrinfo, SOCK_STREAM, inet_pton
from funcy import pluck
from gevent.wsgi import WSGIHandler, WSGIServer
from gevent.pywsgi import WSGIHandler, WSGIServer
from werkzeug.wrappers import (BaseRequest, CommonRequestDescriptorsMixin,
UserAgentMixin, AcceptMixin, Response)