celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject celix git commit: CELIX-401: Refactors docker image creating
Date Tue, 25 Jul 2017 16:00:11 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 4ed36cc18 -> 0d1ef4ad9


CELIX-401: Refactors docker image creating

Docker images are now default created from scratch.
As result no base nor builder images is needed.
All required libraries and binaries are added to the image.
A bash script is used to create a minimal needed filesystem.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/0d1ef4ad
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/0d1ef4ad
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/0d1ef4ad

Branch: refs/heads/develop
Commit: 0d1ef4ad962236e85b7094516067fe764c1e5963
Parents: 4ed36cc
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Tue Jul 25 17:55:24 2017 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Tue Jul 25 17:59:44 2017 +0200

----------------------------------------------------------------------
 CMakeLists.txt                                |   5 -
 cmake/FindCELIX.cmake                         |  11 +-
 cmake/cmake_celix/DeployPackaging.cmake       |   2 +-
 cmake/cmake_celix/DockerPackaging.cmake       | 268 ++++++++++++++++-----
 cmake/cmake_celix/create_target_filesystem.sh | 213 ++++++++++++++++
 docker/celix-builder/Dockerfile               |  70 ------
 docker/celix-builder/README.md                |  35 ---
 docker/celix-builder/libdeps/CMakeLists.txt   |  12 -
 docker/celix-builder/libdeps/main.cc          |   2 -
 docker/celix-builder/main.sh                  |   3 -
 examples/dm_example/CMakeLists.txt            |  15 ++
 examples/dm_example_cxx/CMakeLists.txt        |  19 ++
 framework/private/src/celix_launcher.c        |  62 +++++
 framework/public/include/celix_launcher.h     |   2 +
 launcher/CMakeLists.txt                       |   9 +-
 launcher/private/src/main.c                   |  68 +-----
 16 files changed, 531 insertions(+), 265 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e2b869..b6ef390 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,8 +96,3 @@ add_subdirectory(dependency_manager_cxx)
 
 #Example as last, because some example will check if underlining options are enabled
 add_subdirectory(examples)
-
-option(ENABLE_DOCKER "Generate DockerFile for all deployments and adds docker building targets
the 'docker-images' command")
-if (ENABLE_DOCKER)
-    add_docker_for_all_deployments()
-endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/cmake/FindCELIX.cmake
----------------------------------------------------------------------
diff --git a/cmake/FindCELIX.cmake b/cmake/FindCELIX.cmake
index 9d76996..db1be9d 100644
--- a/cmake/FindCELIX.cmake
+++ b/cmake/FindCELIX.cmake
@@ -25,6 +25,7 @@
 #  CELIX_LIBRARIES - The libraries needed to use Apache Celix
 #  CELIX_LAUNCHER - The path to the celix launcher
 #
+#
 #  CELIX_BUNDLES_DIR - The path where the Celix provided bundles are installed
 #  CELIX_DM_LIB - The Celix Dependency Manager library
 #  CELIX_DM_STATIC_LIB - The Celix Dependency Manager static library
@@ -35,7 +36,7 @@ set(CELIX_DIR_FROM_FINDCELIX "${CMAKE_CURRENT_LIST_DIR}/../../../..")
 
 find_path(CELIX_INCLUDE_DIR NAMES celix_errno.h
 		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
-          	PATH_SUFFIXES include include/celix
+		PATH_SUFFIXES include include/celix
 )
 
 find_path(CELIX_ETCD_INCLUDE_DIR NAMES etcd.h
@@ -44,10 +45,10 @@ find_path(CELIX_ETCD_INCLUDE_DIR NAMES etcd.h
 		)
 
 find_library(CELIX_FRAMEWORK_LIBRARY NAMES celix_framework
-             	PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
-             	PATH_SUFFIXES lib lib64
+		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
+		PATH_SUFFIXES lib lib64
 )
-             
+
 find_library(CELIX_UTILS_LIBRARY NAMES celix_utils
 		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
 		PATH_SUFFIXES lib lib64
@@ -71,7 +72,7 @@ find_file(CELIX_CMAKECELIX_FILE NAMES CMakeCelix.cmake
 #NOTE assuming shell.zip is always installed.
 find_path(CELIX_BUNDLES_DIR shell.zip
 		PATHS ${CELIX_DIR_FROM_FINDCELIX} $ENV{CELIX_DIR} ${CELIX_DIR} /usr /usr/local
-          	PATH_SUFFIXES share/celix/bundles
+		PATH_SUFFIXES share/celix/bundles
 )
 
 find_library(CELIX_DM_LIB NAMES dependency_manager_so

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/cmake/cmake_celix/DeployPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DeployPackaging.cmake b/cmake/cmake_celix/DeployPackaging.cmake
index 8de60ba..73c241d 100644
--- a/cmake/cmake_celix/DeployPackaging.cmake
+++ b/cmake/cmake_celix/DeployPackaging.cmake
@@ -216,9 +216,9 @@ function(deploy_bundles_dir)
             add_custom_command(OUTPUT ${OUT}
                 COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>"
${OUT}
                 COMMENT "Copying bundle '${BUNDLE}' to '${DEPLOY_LOC}/${BD_DIR_NAME}'"
-                DEPENDS ${BUNDLE} #Note cannot directly depends on ${BUNDLE}_bundle, depending
in ${BUNDLE} triggering build instead. 
             )
             add_dependencies(${DEPLOY_NAME} ${BUNDLE}_bundle) #ensure the the deploy depends
on the _bundle target, custom_command depends on add_library
+
         endif()
         list(APPEND DEPS "${OUT}")
 

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/cmake/cmake_celix/DockerPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DockerPackaging.cmake b/cmake/cmake_celix/DockerPackaging.cmake
index 70bb407..3f971e2 100644
--- a/cmake/cmake_celix/DockerPackaging.cmake
+++ b/cmake/cmake_celix/DockerPackaging.cmake
@@ -15,99 +15,243 @@
 # specific language governing permissions and limitations
 # under the License.
 
-add_custom_target(dockerfiles)
-add_custom_target(dockerimages)
+### Setup Docker Option
+option(ENABLE_DOCKER "Enable the add_docker function to create docker files")
 
-set(DOCKER_CMD "docker" CACHE STRING "Docker command to use.")
+if (ENABLE_DOCKER)
+    ##### setup docker target
+    add_custom_target(docker ALL
+        DEPENDS $<TARGET_PROPERTY:docker,DOCKER_DEPS>
+    )
+    add_custom_target(build-docker-images)
+    set(DOCKER_USE_SUDO ON CACHE BOOL "Wether the use of sudo is needed to run docker")
+    set(DOCKER_CMD "docker" CACHE STRING "Docker command to use.")
 
+    set_target_properties(docker PROPERTIES "DOCKER_DEPS" "") #initial empty deps list
+    set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/docker")
+    #####
 
-function(add_docker_for_all_deployments)
-    #NOTE that this function must be called after all CMake add_deploy commands are executed.
-    #NOTE that this is only done for deployments with the COPY instruction
 
-    get_target_property(DEPLOYMENTS deploy "DEPLOY_DEPLOYMENTS")
-    foreach(DEPLOY_TARGET ${DEPLOYMENTS})
-        get_target_property(COPY ${DEPLOY_TARGET} DEPLOY_COPY_BUNDLES)
-        if (COPY)
-            deploy_docker(${DEPLOY_TARGET})
-        endif()
-    endforeach()
-endfunction()
+    ##### Docker Dependencies Library
+    # This (dummy) dependencies library is used to link against required libraries for the
docker images.
+    # The create fs script will ensure that the minimal required directory / files is created
and this
+    # library will ensure that stdc++, m, jansson and libffi and ld-linux libaries are installed
+    #
+    # NOTE that this target can be used to extend the libraries added to the docker image
+    file(GENERATE
+            OUTPUT "${CMAKE_BINARY_DIR}/.celix_docker_depslib/docker_dummy.cc"
+            CONTENT "//intentionally emtpy source file")
+    add_library(celix_docker_depslib SHARED
+            ${CMAKE_BINARY_DIR}/.celix_docker_depslib/docker_dummy.cc
+    )
+    set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/.celix_docker_depslib")
+    set_target_properties(celix_docker_depslib PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/.celix_docker_depslib")
+    find_package(FFI REQUIRED)
+    find_package(Jansson REQUIRED)
+    target_link_libraries(celix_docker_depslib ${JANSSON_LIBRARIES} ${FFI_LIBRARIES})
+    target_link_libraries(celix_docker_depslib m)
 
-function(deploy_docker)
-    list(GET ARGN 0 DEPLOY_TARGET)
+        #TODO, check if libnss_dns and _files are really not needed... seems so
+    #target_link_libraries(celix_docker_depslib /lib64/libnss_dns.so.2 /lib64/libnss_files.so.2)
+endif ()
+
+function(add_docker)
+    list(GET ARGN 0 DOCKER_TARGET)
     list(REMOVE_AT ARGN 0)
 
-    deploy_docker_check(${DEPLOY_TARGET})
+    if (NOT ENABLE_DOCKER)
+        message(WARNING "Docker not enable, skipping target '${DOCKER_TARGET}'")
+        return()
+    endif()
 
     set(OPTIONS )
-    set(ONE_VAL_ARGS FROM NAME BUNDLES_DIR WORK_DIR)
-    set(MULTI_VAL_ARGS INSTRUCTIONS)
+    set(ONE_VAL_ARGS GROUP NAME FROM BUNDLES_DIR WORKDIR IMAGE_NAME ENTRYPOINT DEPSLIB)
+    set(MULTI_VAL_ARGS BUNDLES PROPERTIES INSTRUCTIONS)
     cmake_parse_arguments(DOCKER "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGN})
 
     #set defaults
     if (NOT DOCKER_FROM)
-        set(DOCKER_FROM "celix-base")
+        set(DOCKER_FROM "scratch")
+        set(DOCKER_CREATE_FS true)
+    else()
+        set(DOCKER_CREATE_FS false)
     endif()
     if (NOT DOCKER_NAME)
-        set(DOCKER_NAME "${DEPLOY_TARGET}")
+        set(DOCKER_NAME "${DOCKER_TARGET}")
     endif()
-    if (NOT DOCKER_BUNDLES_DIR)
-        set(DOCKER_BUNDLES_DIR "/var/celix/workdir/bundles/")
+    if (NOT DOCKER_IMAGE_NAME)
+        set(DOCKER_IMAGE_NAME "${DOCKER_NAME}")
+    endif()
+    if (NOT DOCKER_WORKDIR)
+        set(DOCKER_WORKDIR "/root")
+    endif()
+    if (NOT DOCKER_ENTRYPOINT)
+        set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"/bin/celix\"]")
+    else ()
+        set(DOCKER_ENTRYPOINT "ENTRYPOINT [\"${DOCKER_ENTRYPOINT}\"]")
+    endif ()
+    if (NOT DOCKER_GROUP)
+        set(DOCKER_LOC "${CMAKE_BINARY_DIR}/docker/${DOCKER_NAME}")
+    else()
+        set(DOCKER_LOC "${CMAKE_BINARY_DIR}/docker/${DOCKER_GROUP}/${DOCKER_NAME}")
     endif()
-    if (NOT DOCKER_WORK_DIR)
-        set(DOCKER_WORK_DIR "/var/celix/workdir/")
+    if (NOT DOCKER_BUNDLES_DIR)
+        set(DOCKER_BUNDLES_DIR "/bundles")
     endif()
+    if (NOT DOCKER_DEPSLIB)
+        set(DOCKER_DEPSLIB "celix_docker_depslib")
+    endif ()
+
+    ###### Setup docker custom target timestamp
+    set(TIMESTAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-timestamp")
+
+    add_custom_target(${DOCKER_TARGET}
+        DEPENDS ${TIMESTAMP_FILE}
+    )
+
+    #setup dependencies based on timestamp
+    if (DOCKER_CREATE_FS)
+        add_custom_command(OUTPUT "${TIMESTAMP_FILE}"
+            COMMAND ${CMAKE_COMMAND} -E touch ${TIMESTAMP_FILE}
+            COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOCATION>
+            COMMAND cd $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOCATION> &&
/bin/bash ${CELIX_CMAKE_DIRECTORY}/cmake_celix/create_target_filesystem.sh -e $<TARGET_FILE:celix>
-l $<TARGET_FILE:${DOCKER_DEPSLIB}>
+            DEPENDS  "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_DEPS>" ${DOCKERFILE}
${DOCKER_DEPSLIB}
+            WORKING_DIRECTORY "${DOCKER_LOCATION}"
+            COMMENT "Creating docker dir for ${DOCKER_TARGET}" VERBATIM
+        )
+    else ()
+        add_custom_command(OUTPUT "${TIMESTAMP_FILE}"
+            COMMAND ${CMAKE_COMMAND} -E touch ${TIMESTAMP_FILE}
+            COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOCATION>
+            DEPENDS  "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_DEPS>" ${DOCKERFILE}
+            WORKING_DIRECTORY "${DOCKER_LOCATION}"
+            COMMENT "Creating docker dir for ${DOCKER_TARGET}" VERBATIM
+        )
+    endif ()
 
     ##### Deploy Target Properties for Dockerfile #####
-    set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_DOCKERFILE_FROM" "${DOCKER_FROM}")
#name of docker base, default celix-base
-    set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_DOCKERFILE_IMAGE_NAME" "${DOCKER_NAME}")
#name of docker images, default deploy target name
-    set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_DOCKERFILE_BUNDLES_DIR" "${DOCKER_BUNDLES_DIR}")
#bundles directory in docker image
-    set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_DOCKERFILE_WORK_DIR" "${DOCKER_WORK_DIR}")
#workdir in docker image, should also contain the config.properties
-    set_target_properties(${DEPLOY_TARGET} PROPERTIES "DEPLOY_DOCKERFILE_INSTRUCTIONS" "")
#list of additional instructions
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_LOCATION" "${DOCKER_LOC}")
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_FROM" "${DOCKER_FROM}") #name
of docker base, default celix-base
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_IMAGE_NAME" "${DOCKER_IMAGE_NAME}")
#name of docker images, default deploy target name
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES_DIR" "${DOCKER_BUNDLES_DIR}")
#bundles directory in docker image
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES" "") #bundles
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_WORKDIR" "${DOCKER_WORKDIR}")
#workdir in docker image, should also contain the config.properties
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_ENTRYPOINT" "${DOCKER_ENTRYPOINT}")
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_CREATE_FS" "${DOCKER_CREATE_FS}")
#wether to create a fs with the minimal needed libraries / etc files
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_INSTRUCTIONS" "") #list of
additional instructions
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_PROPERTIES" "")
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_DEPS" "")
 
-    set(DOCKERFILE "$<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_LOCATION>/Dockerfile")
+    set(DOCKERFILE "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOCATION>/Dockerfile")
 
     file(GENERATE
             OUTPUT "${DOCKERFILE}"
-            CONTENT "# Dockerfile for inaetics/celix-node-agent-service
-FROM $<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_DOCKERFILE_FROM>
-
-#set image name env
-ENV IMAGE_NAME $<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_DOCKERFILE_IMAGE_NAME>
-
-#add bundles, properties and set workdir
-COPY bundles/*.zip $<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_DOCKERFILE_BUNDLES_DIR>
-COPY config.properties $<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_DOCKERFILE_WORK_DIR>
-WORKDIR $<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_DOCKERFILE_WORK_DIR>
-$<JOIN:$<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_DOCKERFILE_INSTRUCTIONS>,
+            CONTENT "# Dockerfile for celix based image
+FROM $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_FROM>
+ENV IMAGE_NAME $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_IMAGE_NAME>
+ADD . /
+WORKDIR $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_WORKDIR>
+$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_ENTRYPOINT>
+$<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_INSTRUCTIONS>,
 >
 ")
 
-    get_target_property(DEPS dockerfiles "DOCKER_FILES_DEPS")
-    list(APPEND DEPS "${DOCKERFILE}")
-    set_target_properties(dockerfiles PROPERTIES "DOCKER_FILES_DEPS" "${DEPS}")
-
-    add_custom_target(${DEPLOY_TARGET}-dockerimage
-	COMMAND ${CMAKE_COMMAND} -E chdir $<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_LOCATION>
${DOCKER_CMD} build -t "$<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_DOCKERFILE_IMAGE_NAME>"
.
-        DEPENDS ${DOCKERFILE} ${DEPLOY_TARGET}
-        COMMENT "Creating docker image for deployment '${DEPLOY_TARGET}'" VERBATIM
+    #generate config.properties
+    set(DOCKER_PROPS "${DOCKER_LOC}/root/config.properties")
+    set(STAGE1_PROPERTIES "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-config-stage1.properties")
+    file(GENERATE
+            OUTPUT "${STAGE1_PROPERTIES}"
+            CONTENT "cosgi.auto.start.1=$<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_BUNDLES>,
>
+$<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_PROPERTIES>,
+>
+"
     )
-    add_dependencies(dockerimages ${DEPLOY_TARGET}-dockerimage)
+    file(GENERATE
+            OUTPUT "${DOCKER_PROPS}"
+            INPUT "${STAGE1_PROPERTIES}"
+    )
+
+
+    if (DOCKER_BUNDLES)
+        docker_bundles(${DOCKER_TARGET} ${DOCKER_BUNDLES})
+    endif()
+    if (DOCKER_PROPERTIES)
+        docker_properties(${DOCKER_TARGET} ${DOCKER_PROPERTIES})
+    endif ()
+
+    get_target_property(DEPS docker "DOCKER_DEPS")
+    list(APPEND DEPS ${DOCKER_TARGET})
+    set_target_properties(docker PROPERTIES "DOCKER_DEPS" "${DEPS}")
 
-    add_custom_target(${DEPLOY_TARGET}-dockerfile
-            DEPENDS ${DOCKERFILE} ${DEPLOY_TARGET}
+    #Note assuming sudo is needed for the docker command
+    set(SUDO_CMD "")
+    if (DOCKER_USE_SUDO)
+        set(SUDO_CMD "sudo")
+    endif ()
+    add_custom_target(build-${DOCKER_TARGET}-docker-image
+	    COMMAND cd $<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOCATION> && ${SUDO_CMD}
${DOCKER_CMD} build -t "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_IMAGE_NAME>" .
+        DEPENDS ${DOCKERFILE} ${DOCKER_TARGET}
+        COMMENT "Creating docker image for target '${DOCKER_TARGET}'" VERBATIM
     )
-    add_dependencies(dockerfiles ${DEPLOY_TARGET}-dockerfile)
+    add_dependencies(build-docker-images build-${DOCKER_TARGET}-docker-image)
+
 endfunction()
 
-function(deploy_docker_check)
-    get_target_property(COPY ${DEPLOY_TARGET} DEPLOY_COPY_BUNDLES)
-    if (NOT COPY)
-        message(WARNING "
-            Cannot create a valid DockerFile for deploy target '${DEPLOY_TARGET}', because
the bundles are not copied in the deploy dir.
-            This is needed because the source docker copy commands must be inside the docker
build directory.
-            Add the COPY to the add_deploy command for '${DEPLOY_TARGET}'
-        ")
+function(docker_bundles)
+    if (NOT ENABLE_DOCKER)
+        return()
     endif()
+
+    #0 is docker TARGET
+    #1..n is bundles
+    list(GET ARGN 0 DOCKER_TARGET)
+    list(REMOVE_AT ARGN 0)
+
+    get_target_property(BUNDLES ${DOCKER_TARGET} "DOCKER_BUNDLES")
+    get_target_property(BUNDLES_DIR ${DOCKER_TARGET} "DOCKER_BUNDLES_DIR")
+    get_target_property(LOC ${DOCKER_TARGET} "DOCKER_LOCATION")
+    get_target_property(DEPS ${DOCKER_TARGET} "DOCKER_DEPS")
+
+    foreach(BUNDLE IN ITEMS ${ARGN})
+        if(IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE})
+            get_filename_component(BUNDLE_FILENAME ${BUNDLE} NAME)
+            list(APPEND BUNDLES "${BUNDLES_DIR}/${BUNDLE_FILENAME}")
+            set(OUT "${LOC}/bundles/${BUNDLE_FILENAME}")
+            add_custom_command(OUTPUT ${OUT}
+                COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BUNDLE} ${OUT}
+                COMMENT "Copying bundle '${BUNDLE}' to '${OUT}'"
+            )
+        else() #assuming target
+            list(APPEND BUNDLES "${BUNDLES_DIR}/${BUNDLE}.zip")
+            set(OUT ${LOC}/bundles/${BUNDLE}.zip)
+            add_custom_command(OUTPUT ${OUT}
+                    COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>"
"${OUT}"
+                    COMMENT "Copying bundle '${BUNDLE}' to '${OUT}'"
+            )
+            add_dependencies(${DOCKER_TARGET} ${BUNDLE}_bundle) #ensure the the deploy depends
on the _bundle target, custom_command depends on add_library
+        endif()
+        list(APPEND DEPS "${OUT}")
+    endforeach()
+
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_BUNDLES" "${BUNDLES}")
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_DEPS" "${DEPS}")
 endfunction()
+
+function(docker_properties)
+    if (NOT ENABLE_DOCKER)
+        return()
+    endif()
+
+    #0 is docker TARGET
+    #1..n is properties
+    list(GET ARGN 0 DOCKER_TARGET)
+    list(REMOVE_AT ARGN 0)
+
+    get_target_property(PROPS ${DOCKER_TARGET} "DOCKER_PROPERTIES")
+
+    foreach(PROP IN ITEMS ${ARGN})
+        list(APPEND PROPS ${PROP})
+    endforeach()
+
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_PROPERTIES" "${PROPS}")
+endfunction()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/cmake/cmake_celix/create_target_filesystem.sh
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/create_target_filesystem.sh b/cmake/cmake_celix/create_target_filesystem.sh
new file mode 100644
index 0000000..a6c1554
--- /dev/null
+++ b/cmake/cmake_celix/create_target_filesystem.sh
@@ -0,0 +1,213 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#    
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#!/bin/bash
+
+declare -A EXE_ARGUMENTS
+EXE_INDEX=0
+declare -A LIB_ARGUMENTS
+LIB_INDEX=0
+declare -A BUNDLE_ARGUMENTS
+BUNDLE_INDEX=0
+
+while [ -n "${1}" ]
+do
+	ARG="${1}"
+	case $ARG in
+	    -h|--help)
+	    echo "Usage ${0} [-e executable].. [-l library].. [-b bundle].."
+	    exit 0
+	    ;;
+	    -e|--executable)
+	    EXE_ARGUMENTS[${EXE_INDEX}]="${2}"
+	    EXE_INDEX=$((EXE_INDEX+1))
+	    shift
+	    ;;
+	    -l|--lib)
+	    LIB_ARGUMENTS[${LIB_INDEX}]="${2}"
+	    LIB_INDEX=$((LIB_INDEX+1))
+	    shift
+	    ;;
+	    -b|--bundle)
+	    BUNDLE_ARGUMENTS[${BUNDLE_INDEX}]="${2}"
+	    BUNDLE_INDEX=$((BUNDLE_INDEX+1))
+	    shift
+	    ;;
+	    *)
+	    echo "unknown option '${ARG}'"
+	    ;;
+	esac
+	shift
+done
+
+celix_add_file() {
+	FILE=$1
+	if [ -f ${FILE} ]
+	then #is regular file and not symlink
+
+		if [[ "${FILE}" =~ ^/.* ]]; then #absolute path
+			DIR=.$(dirname ${FILE})
+		else
+			DIR=$(dirname ${FILE})
+		fi
+
+		mkdir -p ${DIR} 2> /dev/null
+		cp -vu ${FILE} ${DIR}/
+	else
+		echo "Skipping file ${FILE}"
+	fi
+}
+
+celix_add_bundle() {
+	BUNDLE=$1
+	if [ -e ${BUNDLE} ] 
+	then
+		BUNDLE_DIR=bundles
+		mkdir -p ${BUNDLES_DIR} 2> /dev/null
+		cp -vu ${BUNDLE} ${BUNDLES_DIR}/
+	else
+		echo "Bundle '${BUNDLE}' does not exists!"
+	fi
+}
+
+celix_add_lib() {
+	LIB=$1
+	for DEP in $(ldd ${LIB} | grep lib | awk '{print $3}')
+	do
+		celix_add_file ${DEP}
+	done
+
+	#the ld-linux library is handled separately
+	LDLIB=$(ldd ${EXE} | grep ld-linux | awk '{print $1}')
+	if [ -n ${LDLIB} ] 
+	then
+		celix_add_file ${LDLIB}
+	fi
+}
+
+celix_add_libs_for_exe() {
+	EXE=$1
+	for LIB in $(ldd ${EXE} | grep lib | awk '{print $3}')
+	do
+		celix_add_file ${LIB}
+	done
+
+	#the ld-linux library is handled separately
+	LDLIB=$(ldd ${EXE} | grep ld-linux | awk '{print $1}')
+	if [ -n ${LDLIB} ] 
+	then
+		celix_add_file ${LDLIB}
+	fi
+}
+
+celix_add_exe() {
+	EXE=$1
+	celix_add_libs_for_exe ${EXE}
+
+    #if [[ "${EXE}" =~ ^/.* ]]; then
+    #    DIR=.$(dirname ${EXE})
+    #else
+    #   #for relative paths use usr/bin
+    #    DIR=usr/bin
+    #fi
+
+    #Always put executables in /bin
+    DIR=bin
+
+	mkdir -p ${DIR} 2> /dev/null
+	cp -vu ${EXE} ${DIR}/
+}
+
+celix_add_required_libs() {
+	if [ ! -d /lib64 ]
+	then
+		echo "ERROR: Assuming 64 bit architecture for docker creating. Created filesystem will
not be valid"
+	fi
+	LIBS=$(ls -1 /lib64/ld-linux* /lib64/libnss_dns* /lib64/libnss_files*)
+	for LIB in ${LIBS}
+	do
+		celix_add_file ${LIB} 
+	done
+}
+
+for INDEX in "${!EXE_ARGUMENTS[@]}"
+do
+	EXE=${EXE_ARGUMENTS[${INDEX}]}
+	echo "Adding exe ${EXE}"
+	celix_add_exe ${EXE}
+done
+
+for INDEX in "${!LIB_ARGUMENTS[@]}"
+do
+	LIB=${LIB_ARGUMENTS[${INDEX}]}
+	echo "Adding lib ${LIB}"
+	celix_add_lib ${LIB}
+done
+
+for INDEX in "${!BUNDLE_ARGUMENTS[@]}"
+do
+	BUNDLE=${BUNDLE_ARGUMENTS[${INDEX}]}
+	echo "Adding bundle ${BUNDLE}"
+	celix_add_bundle ${BUNDLE}
+done
+
+		
+mkdir root 2> /dev/null
+
+echo "Creating minimal etc dir"
+
+mkdir etc 2> /dev/null
+if [ ! -f etc/group ]
+then
+    echo """root:x:0:
+bin:x:1:
+daemon:x:2:
+adm:x:4:
+lp:x:7:
+mail:x:12:
+games:x:20:
+ftp:x:50:
+nobody:x:99:
+users:x:100:
+nfsnobody:x:65534:""" > etc/group
+fi
+
+if [ ! -f etc/nsswitch.conf ]
+then
+    echo """passwd:     files
+shadow:     files
+group:      files
+hosts:      files dns""" > etc/nsswitch.conf
+fi
+
+if [ ! -f etc/passwd ]
+then
+    echo """root:x:0:0:root:/root:/bin/bash
+bin:x:1:1:bin:/bin:/sbin/nologin
+daemon:x:2:2:daemon:/sbin:/sbin/nologin
+adm:x:3:4:adm:/var/adm:/sbin/nologin
+lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
+sync:x:5:0:sync:/sbin:/bin/sync
+shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
+halt:x:7:0:halt:/sbin:/sbin/halt
+mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
+operator:x:11:0:operator:/root:/sbin/nologin
+games:x:12:100:games:/usr/games:/sbin/nologin
+ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
+nobody:x:99:99:Nobody:/:/sbin/nologin""" > etc/passwd
+fi
+
+#Currently done by libcelix_docker_dummy.so
+#celix_add_required_libs

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/docker/celix-builder/Dockerfile
----------------------------------------------------------------------
diff --git a/docker/celix-builder/Dockerfile b/docker/celix-builder/Dockerfile
deleted file mode 100644
index 7de3bf1..0000000
--- a/docker/celix-builder/Dockerfile
+++ /dev/null
@@ -1,70 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-# 
-#   http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-FROM fedora:25
-
-#Install required libs for building, docker, python and dokerize
-RUN dnf group install -y "C Development Tools and Libraries"
-RUN dnf -y install \
-    cmake \
-    ninja-build \
-    make \
-    git \
-    java \
-    libcurl-devel \
-    jansson-devel \
-    libffi-devel \
-    libxml2-devel \
-    libuuid-devel \
-    python2 \
-    gdb-gdbserver
-
-#jdk installed for jar command
-RUN dnf install -y java-1.8.0-openjdk-devel
-
-#dockerize will be used to extract a single executable with required deps
-RUN pip2 install dockerize
-
-#Building and installing celix
-ADD . /root/celix
-RUN mkdir /root/celix-build
-WORKDIR /root/celix-build
-RUN cmake -DCMAKE_C_FLAGS="-w" ../celix
-RUN make -j && make install
-
-#Not all library (e.g. jansson / C++ (TODO)) are required by the celix framework,
-#but they are still considered a requirement because many bundles will need them
-ADD docker/celix-builder/libdeps /root/libdeps
-RUN mkdir /root/libdeps/build
-WORKDIR /root/libdeps/build
-RUN cmake .. && make -j && make install
-
-#Add Celix, gdb-server &  jansson (including softlinks)
-RUN dockerize -n -o /root/docker-image --add-file /usr/lib64/libjansson.so.4 /lib64/libjansson.so.4
/usr/local/bin/celix  /usr/bin/gdbserver /usr/local/bin/dummy && rm /root/docker-image/usr/local/bin/dummy
-
-#Optional add gdb
-#RUN dockerize -n -o /root/docker-image /usr/bin/gdb
-
-#Add ENTYPOINT instruction to Dockerfile
-RUN echo "ENTRYPOINT [\"/usr/local/bin/celix\"]" >> /root/docker-image/Dockerfile
-
-#Adding scripts
-WORKDIR /root
-ADD docker/celix-builder/main.sh /root/
-RUN chmod +x /root/main.sh
-
-ENTRYPOINT "/root/main.sh"

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/docker/celix-builder/README.md
----------------------------------------------------------------------
diff --git a/docker/celix-builder/README.md b/docker/celix-builder/README.md
deleted file mode 100644
index 8af3b1e..0000000
--- a/docker/celix-builder/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-# Intro
-
-A celix-base is can be created in two steps. The reason behind these two steps is to be able
to create small images only containing the 
-really necessary files. For celix this means the celix executable and required libraries.
To support debugging a gdb-server is also added.
-
-The first docker image is responsible for building Celix and the required libaries, setting
up a miminum image using dockerize and creating a 
-script to be able to export the mimimal image to the host environment. By running this 'builder'
docker image a new directory can be extracted 
-containing a docker setup for a mimimal image. This new directory can be used to create the
final docker image. 
-
-# How to create a Celix base image
-
-Run (in the Celix root src dir):
- - `docker build -t celix-builder -f docker/celix-builer/Dockerfile .`
- - `mkdir -p build/celix-base`
- - `cd build/celix-base`
- - `docker run celix-builder | tar x-`
- - `docker build -t celix-base .`
-
-
-# How to create a celix based docker image 
-
-Run (in the Celix root src dir):
- - `mkdir build`
- - `cd build`
- - `cmake -DENABLE_DOCKER=ON ..`
- - `make dm_example-dockerimage`
- - `docker run -t -i dm_example`
- -  Optional to build the docker images for all deployments (with the COPY instruction):
`make dockerimages`
-
-
-# Known Issues
-
- - C++ libs are missing
- - Instructions how to add your own libs (e.g zmq) are missing
- - Still need to test all deployments

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/docker/celix-builder/libdeps/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/docker/celix-builder/libdeps/CMakeLists.txt b/docker/celix-builder/libdeps/CMakeLists.txt
deleted file mode 100644
index fcbf216..0000000
--- a/docker/celix-builder/libdeps/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-project(Dummy CXX)
-
-cmake_minimum_required(VERSION 3.3)
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(JANSSON REQUIRED jansson)
-
-add_executable(dummy
-    main.cc
-)
-target_link_libraries(dummy ${JANSSON_LIBRARIES} gcc_s)
-
-install(TARGETS dummy DESTINATION bin)

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/docker/celix-builder/libdeps/main.cc
----------------------------------------------------------------------
diff --git a/docker/celix-builder/libdeps/main.cc b/docker/celix-builder/libdeps/main.cc
deleted file mode 100644
index b2f9976..0000000
--- a/docker/celix-builder/libdeps/main.cc
+++ /dev/null
@@ -1,2 +0,0 @@
-int main() {
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/docker/celix-builder/main.sh
----------------------------------------------------------------------
diff --git a/docker/celix-builder/main.sh b/docker/celix-builder/main.sh
deleted file mode 100644
index c5d9e1e..0000000
--- a/docker/celix-builder/main.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-cd /root/docker-image
-tar c --to-stdout *

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/examples/dm_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/CMakeLists.txt b/examples/dm_example/CMakeLists.txt
index 816d738..511dafd 100644
--- a/examples/dm_example/CMakeLists.txt
+++ b/examples/dm_example/CMakeLists.txt
@@ -41,4 +41,19 @@ if (BUILD_DEPENDENCY_MANAGER)
             LOGHELPER_ENABLE_STDOUT_FALLBACK=true
     )
 
+    if (ENABLE_DOCKER)
+        add_docker(dm_exmpl
+        BUNDLES
+            shell
+            shell_tui
+            dm_shell
+            phase1
+            phase2a
+            phase2b
+            phase3
+        PROPERTIES
+            LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+        )
+    endif ()
+
 endif ()

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/examples/dm_example_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/CMakeLists.txt b/examples/dm_example_cxx/CMakeLists.txt
index 88e1a89..9fa5601 100644
--- a/examples/dm_example_cxx/CMakeLists.txt
+++ b/examples/dm_example_cxx/CMakeLists.txt
@@ -52,4 +52,23 @@ if (BUILD_DEPENDENCY_MANAGER_CXX)
             LOGHELPER_ENABLE_STDOUT_FALLBACK=true
     )
 
+    if (ENABLE_DOCKER)
+        add_docker(dm_exmpl_cxx
+            BUNDLES
+                shell
+                shell_tui
+                dm_shell
+                log_service
+                log_writer
+
+                phase1_cxx
+                phase2a_cxx
+                phase2b_cxx
+                phase3_cxx
+                phase3_locking_cxx
+            PROPERTIES
+                LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+        )
+    endif ()
+
 endif ()

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/framework/private/src/celix_launcher.c
----------------------------------------------------------------------
diff --git a/framework/private/src/celix_launcher.c b/framework/private/src/celix_launcher.c
index 0fd04cf..e853f53 100644
--- a/framework/private/src/celix_launcher.c
+++ b/framework/private/src/celix_launcher.c
@@ -36,9 +36,71 @@
 #include <curl/curl.h>
 #endif
 
+#include <string.h>
+#include <curl/curl.h>
+#include <signal.h>
+#include <libgen.h>
+#include "celix_launcher.h"
 #include "framework.h"
 #include "linked_list_iterator.h"
 
+static void show_usage(char* prog_name);
+static void shutdown_framework(int signal);
+static void ignore(int signal);
+
+#define DEFAULT_CONFIG_FILE "config.properties"
+
+static framework_pt framework = NULL;
+
+int celixLauncher_launchWithArgs(int argc, char *argv[]) {
+	// Perform some minimal command-line option parsing...
+	char *opt = NULL;
+	if (argc > 1) {
+		opt = argv[1];
+	}
+
+	char *config_file = NULL;
+
+	if (opt) {
+		// Check whether the user wants some help...
+		if (strcmp("-h", opt) == 0 || strcmp("-help", opt) == 0) {
+			show_usage(argv[0]);
+			return 0;
+		} else {
+			config_file = opt;
+		}
+	} else {
+		config_file = DEFAULT_CONFIG_FILE;
+	}
+
+
+	// Set signal handler
+	(void) signal(SIGINT, shutdown_framework);
+	(void) signal(SIGUSR1, ignore);
+	(void) signal(SIGUSR2, ignore);
+
+	int rc = celixLauncher_launch(config_file, &framework);
+	if (rc == 0) {
+		celixLauncher_waitForShutdown(framework);
+		celixLauncher_destroy(framework);
+	}
+	return rc;
+}
+
+static void show_usage(char* prog_name) {
+	printf("Usage:\n  %s [path/to/config.properties]\n\n", basename(prog_name));
+}
+
+static void shutdown_framework(int signal) {
+	if (framework != NULL) {
+		celixLauncher_stop(framework); //NOTE main thread will destroy
+	}
+}
+
+static void ignore(int signal) {
+	//ignoring for signal SIGUSR1, SIGUSR2. Can be used on threads
+}
+
 int celixLauncher_launch(const char *configFile, framework_pt *framework) {
 	int status = 0;
 	FILE *config = fopen(configFile, "r");

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/framework/public/include/celix_launcher.h
----------------------------------------------------------------------
diff --git a/framework/public/include/celix_launcher.h b/framework/public/include/celix_launcher.h
index fbfdea7..0d819c9 100644
--- a/framework/public/include/celix_launcher.h
+++ b/framework/public/include/celix_launcher.h
@@ -34,6 +34,8 @@
 extern "C" {
 #endif
 
+int celixLauncher_launchWithArgs(int argc, char *argv[]);
+
 int celixLauncher_launch(const char *configFile, framework_pt *framework);
 
 int celixLauncher_launchWithStream(FILE *config, framework_pt *framework);

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/launcher/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 8c05df0..0505f7b 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -19,14 +19,15 @@ if (LAUNCHER)
     find_package(CURL REQUIRED)
 
     include_directories(public/include)
-    
+
+    #celix launcher linked to libc
     add_executable(celix
-        private/src/main
+        private/src/main.c
     )
 
-    set_target_properties(celix PROPERTIES "INSTALL_RPATH" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+    set_target_properties(celix     PROPERTIES "INSTALL_RPATH" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
     
-    target_link_libraries(celix celix_framework ${CURL_LIBRARIES})
+    target_link_libraries(celix     celix_framework ${CURL_LIBRARIES})
     if (NOT ANDROID)
         target_link_libraries(celix celix_dfi) #note not strictly needed, but ensure libdfi
is a dep for the framework, useful when create docker images
     endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/0d1ef4ad/launcher/private/src/main.c
----------------------------------------------------------------------
diff --git a/launcher/private/src/main.c b/launcher/private/src/main.c
index 8998e44..bd26e8b 100644
--- a/launcher/private/src/main.c
+++ b/launcher/private/src/main.c
@@ -16,73 +16,9 @@
  *specific language governing permissions and limitations
  *under the License.
  */
-/*
- * main.c
- *
- *  \date       Jul 30, 2015
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
 
-#include <string.h>
-#include <curl/curl.h>
-#include <signal.h>
-#include <libgen.h>
 #include "celix_launcher.h"
 
-static void show_usage(char* prog_name);
-static void shutdown_framework(int signal);
-static void ignore(int signal);
-
-#define DEFAULT_CONFIG_FILE "config.properties"
-
-static framework_pt framework = NULL;
-
 int main(int argc, char *argv[]) {
-
-    // Perform some minimal command-line option parsing...
-    char *opt = NULL;
-    if (argc > 1) {
-        opt = argv[1];
-    }
-
-    char *config_file = NULL;
-
-    if (opt) {
-        // Check whether the user wants some help...
-        if (strcmp("-h", opt) == 0 || strcmp("-help", opt) == 0) {
-            show_usage(argv[0]);
-            return 0;
-        } else {
-            config_file = opt;
-        }
-    } else {
-        config_file = DEFAULT_CONFIG_FILE;
-    }
-
-
-    // Set signal handler
-    (void) signal(SIGINT, shutdown_framework);
-    (void) signal(SIGUSR1, ignore);
-    (void) signal(SIGUSR2, ignore);
-
-    int rc = celixLauncher_launch(config_file, &framework);
-    if (rc == 0) {
-        celixLauncher_waitForShutdown(framework);
-        celixLauncher_destroy(framework);
-    }
-}
-
-static void show_usage(char* prog_name) {
-    printf("Usage:\n  %s [path/to/config.properties]\n\n", basename(prog_name));
-}
-
-static void shutdown_framework(int signal) {
-    if (framework != NULL) {
-        celixLauncher_stop(framework); //NOTE main thread will destroy
-    }
-}
-
-static void ignore(int signal) {
-    //ignoring for signal SIGUSR1, SIGUSR2. Can be used on threads
-}
+    return celixLauncher_launchWithArgs(argc, argv);
+}
\ No newline at end of file


Mime
View raw message