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: Improves the add_docker examples, improves some cmake cleanup configuration and adds an initial documentation
Date Tue, 25 Jul 2017 19:32:55 GMT
Repository: celix
Updated Branches:
  refs/heads/develop fff2c5ffb -> 0d5e9c814


CELIX-401: Improves the add_docker examples, improves some cmake cleanup configuration and
adds an initial  documentation


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

Branch: refs/heads/develop
Commit: 0d5e9c814c675becd21c4c4cc324bb374495d5e7
Parents: fff2c5f
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Tue Jul 25 21:32:39 2017 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Tue Jul 25 21:32:39 2017 +0200

----------------------------------------------------------------------
 cmake/cmake_celix/DeployPackaging.cmake | 11 +++-
 cmake/cmake_celix/DockerPackaging.cmake | 44 +++++++++++++--
 documents/cmake_commands/readme.md      | 82 ++++++++++++++++++++++++++--
 examples/dm_example/CMakeLists.txt      | 29 ++++++----
 examples/dm_example_cxx/CMakeLists.txt  |  3 +
 5 files changed, 147 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/0d5e9c81/cmake/cmake_celix/DeployPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DeployPackaging.cmake b/cmake/cmake_celix/DeployPackaging.cmake
index 73c241d..a52a306 100644
--- a/cmake/cmake_celix/DeployPackaging.cmake
+++ b/cmake/cmake_celix/DeployPackaging.cmake
@@ -20,7 +20,10 @@ add_custom_target(deploy ALL
         DEPENDS $<TARGET_PROPERTY:deploy,DEPLOY_DEPLOYMENTS>
 )
 set_target_properties(deploy PROPERTIES "DEPLOY_DEPLOYMENTS" "") #initial empty deps list
-set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/deploy")
+
+get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES)
+list(APPEND CLEANFILES "${CMAKE_BINARY_DIR}/deploy")
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
 #####
 
 function(add_deploy)
@@ -182,6 +185,12 @@ $<JOIN:$<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_PROPERTIES>,
 
     deploy_bundles(${DEPLOY_TARGET} ${DEPLOY_BUNDLES})
     deploy_properties(${DEPLOY_TARGET} ${DEPLOY_PROPERTIES})
+
+
+    #ensure the docker dir will be deleted during clean
+    get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES)
+    list(APPEND CLEANFILES "$<TARGET_PROPERTY:${DEPLOY_TARGET},DEPLOY_LOCATION>")
+    set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
 endfunction()
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/0d5e9c81/cmake/cmake_celix/DockerPackaging.cmake
----------------------------------------------------------------------
diff --git a/cmake/cmake_celix/DockerPackaging.cmake b/cmake/cmake_celix/DockerPackaging.cmake
index 3f971e2..46b3008 100644
--- a/cmake/cmake_celix/DockerPackaging.cmake
+++ b/cmake/cmake_celix/DockerPackaging.cmake
@@ -28,7 +28,10 @@ if (ENABLE_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")
+
+    get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES)
+    list(APPEND CLEANFILES "${CMAKE_BINARY_DIR}/docker")
+    set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
     #####
 
 
@@ -44,14 +47,16 @@ if (ENABLE_DOCKER)
     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")
+    get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES)
+    list(APPEND CLEANFILES "${CMAKE_BINARY_DIR}/.celix_docker_depslib")
+    set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
     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)
 
-        #TODO, check if libnss_dns and _files are really not needed... seems so
+    #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 ()
 
@@ -102,6 +107,11 @@ function(add_docker)
         set(DOCKER_DEPSLIB "celix_docker_depslib")
     endif ()
 
+    #ensure the docker dir will be deleted during clean
+    get_directory_property(CLEANFILES ADDITIONAL_MAKE_CLEAN_FILES)
+    list(APPEND CLEANFILES "$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_LOCATION>")
+    set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
+
     ###### Setup docker custom target timestamp
     set(TIMESTAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-timestamp")
 
@@ -157,7 +167,7 @@ $<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_INSTRUCTIONS>,
 ")
 
     #generate config.properties
-    set(DOCKER_PROPS "${DOCKER_LOC}/root/config.properties")
+    set(DOCKER_PROPS "${DOCKER_LOC}/${DOCKER_WORKDIR}/config.properties")
     set(STAGE1_PROPERTIES "${CMAKE_CURRENT_BINARY_DIR}/${DOCKER_TARGET}-docker-config-stage1.properties")
     file(GENERATE
             OUTPUT "${STAGE1_PROPERTIES}"
@@ -178,6 +188,9 @@ $<JOIN:$<TARGET_PROPERTY:${DOCKER_TARGET},DOCKER_PROPERTIES>,
     if (DOCKER_PROPERTIES)
         docker_properties(${DOCKER_TARGET} ${DOCKER_PROPERTIES})
     endif ()
+    if (DOCKER_INSTRUCTIONS)
+        docker_instructions(${DOCKER_TARGET} ${DOCKER_INSTRUCTIONS})
+    endif ()
 
     get_target_property(DEPS docker "DOCKER_DEPS")
     list(APPEND DEPS ${DOCKER_TARGET})
@@ -216,14 +229,14 @@ function(docker_bundles)
         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}")
+            set(OUT "${LOC}/${BUNDLES_DIR}/${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)
+            set(OUT ${LOC}/${BUNDLES_DIR}/${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}'"
@@ -254,4 +267,23 @@ function(docker_properties)
     endforeach()
 
     set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_PROPERTIES" "${PROPS}")
+endfunction()
+
+function(docker_instructions)
+    if (NOT ENABLE_DOCKER)
+        return()
+    endif()
+
+    #0 is docker TARGET
+    #1..n is instructions
+    list(GET ARGN 0 DOCKER_TARGET)
+    list(REMOVE_AT ARGN 0)
+
+    get_target_property(INSTRUCTIONS ${DOCKER_TARGET} "DOCKER_INSTRUCTIONS")
+
+    foreach(INSTR IN ITEMS ${ARGN})
+        list(APPEND INSTRUCTIONS ${INSTR})
+    endforeach()
+
+    set_target_properties(${DOCKER_TARGET} PROPERTIES "DOCKER_INSTRUCTIONS" "${INSTRUCTIONS}")
 endfunction()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/0d5e9c81/documents/cmake_commands/readme.md
----------------------------------------------------------------------
diff --git a/documents/cmake_commands/readme.md b/documents/cmake_commands/readme.md
index 63f8732..87eb56f 100644
--- a/documents/cmake_commands/readme.md
+++ b/documents/cmake_commands/readme.md
@@ -149,7 +149,7 @@ install_bundle(<bundle_target>
 
 # Deployments
 
-# add_deploy
+## add_deploy
 Add a deployment, consisting out of a selection of bundles, for the project. 
 Deployments can be used to run/test a selection of bundles in the celix framework.
 A deployment can be found in `<cmake_build_dir>/deploy[/<group_name>]/<deploy_name>`.

@@ -168,7 +168,7 @@ add_deploy(<deploy_target_name>
 ```
 
 The provided bundle targets for a deployment do not have to exists (yet).
-This removes the need for correctly ordening the add_bundle commands so that all bundle target
are present before an add_deploy command.
+This removes the need for correctly ordering the add_bundle commands so that all bundle target
are present before an add_deploy command.
 If the bundle target is never added CMake will give an error:
 ```
   Error evaluating generator expression:
@@ -184,7 +184,7 @@ If the bundle target is never added CMake will give an error:
 - If BUNDLES is provided the list of bundles will be added the the generated config.properties
for startup. Combined with COPY the bundles will also be copied to a bundles dir.
 - If PROPERTIES is provided the list of properties will be appended to the generated config.properties
 
-# deploy_bundles_dir
+## deploy_bundles_dir
 Deploy a selection of bundles to the provided bundle dir. This can be used to create an endpoints
/ proxies bundles dir for the remote service admin or drivers bundles dir for the device access.

 
 ```CMake
@@ -197,7 +197,7 @@ deploy_bundles_dir(<deploy_target_name>
 )
 ```
 
-# deploy_bundles
+## deploy_bundles
 Deploy the selected bundles. The bundles are configured for auto starting. 
 
 ```CMake
@@ -208,7 +208,7 @@ deploy_bundles(<deploy_target_name>
 )
 ```
 
-# deploy_properties
+## deploy_properties
 
 ```CMake
 Add the provided properties to the target deploy config.properties.
@@ -218,4 +218,76 @@ deploy_properties(<deploy_target_name>
     "prop2=val2" 
     ...
 )
+```
+
+# Celix Docker Images
+It is possible the use the `add_docker` Apache Celix CMake command to create Apache Celix
docker directories,
+which in turn can be used to create very small Apache Celix docker images.
+
+## add_docker
+Adds a docker target dir, containing a all the required executables, 
+libraries and filesystem needed to run a Apache Celix framework in a docker container. 
+Also includes the selected bundles. 
+
+The add_docker image use a `celix_docker_depslib` target to infer which shared libraries
are required 
+for the docker image. The `celix_docker_depslib` is a empty C++ libraries linked against
`jansson`, `libffi` and `m`.
+As result these libraries and some additional required libraries (libgcc_s, libstdc++) are
added to the
+docker dir. It is possible to link additional libraries to the `celix_docker_depslib` to
that these are also
+added to the docker image. It is also possible to specify a own "docker libs" library to
use to infer 
+the required library dependencies
+
+The docker dir can be found in `<cmake_build_dir>/docker[/<group_name>]/<docker_name>`.

+  
+  
+The provided bundle targets for a docker dir do not have to exists (yet).
+This removes the need for correctly order the add_bundle commands so that all bundle target
are present before 
+an `add_docker` command.
+If the bundle target is never added CMake will give an error:
+  ```
+    Error evaluating generator expression:
+  
+      $<TARGET_PROPERTY:foo,BUNDLE_FILE>
+  ```
+ 
+```CMake
+add_docker(<docker_target_name>
+    [GROUP group_name]
+    [NAME deploy_name]
+    [FROM docker_from_image]
+    [BUNDLES_DIR bundle_dir_in_docker_image]
+    [WORKDIR workdir_in_docker_image]
+    [DEPSLIB deps_lib_target_name]
+    [IMAGE_NAME docker_image_name]
+    [ENTRYPOINT docker_entry_point]
+    [BUNDLES <bundle1> <bundle2> ...]
+    [PROPERTIES "prop1=val1" "prop2=val2" ...]
+    [INSTRUCTIONS "instr1" "instr2" ...]
+)
+```
 
+- If GROUP is provided the docker will be grouped in the provided group name. 
+- If NAME is provided that name will be used for the docker dir. Default the deploy target
name will be used.
+- If FROM is provided the docker image will use the provide FROM as base, else `FROM scratch`
is used and 
+    a minimal filesystem will be created for the docker image
+- If BUNDLES_DIR is provided that directory will be used as bundles location. Default `/bundles`
will be used
+- If WORKDIR is provided that directory will be used a workdir. Default `/root` will be used
+- If DEPSLIB is provided that target name will be used to infer the required libraries. Default
the target 
+name `celix_docker_libsdep` will be used
+- If IMAGE_NAME is provided that will be used as docker image name. Default the NAME will
be used
+- If ENTRYPOINT is provided that will be used as docker entrypoint. Default `/bin/celix`
will be used
+- If BUNDLES is provided, the list of bundles will be added to the docker images and configured
in the generated 
+ `config.properties`
+- If PROPERTIES is provided, the list of properties will added to the generated `config.properties`
file
+- If INSTRUCTIONS id provided, the list of docker instructions will be added the the generated
`Dockerfile`
+
+## build-docker-images target
+TODO
+
+## docker_bundles
+TODO
+
+## docker_properties
+TODO
+
+## docker_instructions
+TODO
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/0d5e9c81/examples/dm_example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example/CMakeLists.txt b/examples/dm_example/CMakeLists.txt
index 511dafd..7a51719 100644
--- a/examples/dm_example/CMakeLists.txt
+++ b/examples/dm_example/CMakeLists.txt
@@ -42,17 +42,26 @@ if (BUILD_DEPENDENCY_MANAGER)
     )
 
     if (ENABLE_DOCKER)
+        add_docker(dm_exmpl_base
+                NAME dmbase
+                IMAGE_NAME dmbase
+                GROUP examples
+                INSTRUCTIONS
+                    "LABEL exmpl=value"
+        )
         add_docker(dm_exmpl
-        BUNDLES
-            shell
-            shell_tui
-            dm_shell
-            phase1
-            phase2a
-            phase2b
-            phase3
-        PROPERTIES
-            LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+            FROM dmbase
+            GROUP examples
+            BUNDLES
+                shell
+                shell_tui
+                dm_shell
+                phase1
+                phase2a
+                phase2b
+                phase3
+            PROPERTIES
+                LOGHELPER_ENABLE_STDOUT_FALLBACK=true
         )
     endif ()
 

http://git-wip-us.apache.org/repos/asf/celix/blob/0d5e9c81/examples/dm_example_cxx/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/dm_example_cxx/CMakeLists.txt b/examples/dm_example_cxx/CMakeLists.txt
index 9fa5601..2f6b1cf 100644
--- a/examples/dm_example_cxx/CMakeLists.txt
+++ b/examples/dm_example_cxx/CMakeLists.txt
@@ -54,6 +54,9 @@ if (BUILD_DEPENDENCY_MANAGER_CXX)
 
     if (ENABLE_DOCKER)
         add_docker(dm_exmpl_cxx
+            GROUP examples
+            BUNDLES_DIR /usr/share/bundles
+            WORKDIR /workspace
             BUNDLES
                 shell
                 shell_tui


Mime
View raw message