diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ddf8868..4ae868dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,9 @@ if(BUILD_AKLITE) include(CTest) add_subdirectory(tests EXCLUDE_FROM_ALL) + if(USE_COMPOSEAPP_ENGINE) + add_definitions(-DUSE_COMPOSEAPP_ENGINE) + endif(USE_COMPOSEAPP_ENGINE) if(BUILD_AKLITE_APPS) add_subdirectory(apps/aklite-apps) endif(BUILD_AKLITE_APPS) diff --git a/apps/aklite-apps/cmds.cpp b/apps/aklite-apps/cmds.cpp index 639ffedb..9b987ad9 100644 --- a/apps/aklite-apps/cmds.cpp +++ b/apps/aklite-apps/cmds.cpp @@ -9,6 +9,9 @@ #include "docker/docker.h" #include "docker/restorableappengine.h" #include "http/httpclient.h" +#ifdef USE_COMPOSEAPP_ENGINE +#include "ctr/appengine.h" +#endif // USE_COMPOSEAPP_ENGINE namespace fs = std::filesystem; @@ -172,6 +175,23 @@ int RunCmd::runApps(const std::vector& shortlist, const std::string auto http_client = std::make_shared(); auto docker_client{std::make_shared()}; auto registry_client{std::make_shared(http_client, "")}; +#ifdef USE_COMPOSEAPP_ENGINE + ctr::AppEngine app_engine{ + store_root, + compose_root, + docker_root, + registry_client, + docker_client, + client, + docker_host, + compose_client, + client, + 80 /* this value is non-op in the case of install/run */, + Docker::RestorableAppEngine::GetDefStorageSpaceFunc(), + [](const Docker::Uri& /* app_uri */, const std::string& image_uri) { return "docker://" + image_uri; }, + false, + true}; +#else Docker::RestorableAppEngine app_engine{ store_root, compose_root, @@ -185,6 +205,7 @@ int RunCmd::runApps(const std::vector& shortlist, const std::string [](const Docker::Uri& /* app_uri */, const std::string& image_uri) { return "docker://" + image_uri; }, false, true}; +#endif // USE_COMPOSEAPP_ENGINE for (const auto& app : apps) { LOG_INFO << "Starting App: " << app.name; diff --git a/apps/aklite-apps/cmds.h b/apps/aklite-apps/cmds.h index f1a1a074..f2fc66ef 100644 --- a/apps/aklite-apps/cmds.h +++ b/apps/aklite-apps/cmds.h @@ -97,7 +97,12 @@ class RunCmd : public Cmd { "store-root", po::value()->default_value("/var/sota/reset-apps"), "Image store root folder")( "compose-root", po::value()->default_value("/var/sota/compose-apps"), "Compose Apps root folder")( "docker-root", po::value()->default_value("/var/lib/docker"), "Docker data root folder")( +#ifdef USE_COMPOSEAPP_ENGINE + "client", po::value()->default_value("/usr/bin/composectl"), + "A client to load app images to docker")( +#else "client", po::value()->default_value("/usr/sbin/skopeo"), "A client to copy images")( +#endif "compose-client", po::value()->default_value("/usr/bin/docker compose "), "A client to manage compose apps"); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 932624b3..410b1365 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,10 +55,9 @@ if (BUILD_AKLITE_WITH_NERDCTL) add_definitions(-DBUILD_AKLITE_WITH_NERDCTL) endif(BUILD_AKLITE_WITH_NERDCTL) -if (USE_COMPOSEAPP_ENGINE) +if(USE_COMPOSEAPP_ENGINE) set(SRC ${SRC} ctr/appengine.cc) set(HEADERS ${HEADERS} ctr/appengine.h) - add_definitions(-DUSE_COMPOSEAPP_ENGINE) endif(USE_COMPOSEAPP_ENGINE) add_executable(${TARGET_EXE} main.cc)