Skip to content

Commit

Permalink
aklite-apps: Add composectl app engine support
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Sul <[email protected]>
  • Loading branch information
mike-sul committed Dec 5, 2023
1 parent 2d5613a commit 7db512f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions apps/aklite-apps/cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -172,6 +175,23 @@ int RunCmd::runApps(const std::vector<std::string>& shortlist, const std::string
auto http_client = std::make_shared<HttpClient>();
auto docker_client{std::make_shared<Docker::DockerClient>()};
auto registry_client{std::make_shared<Docker::RegistryClient>(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,
Expand All @@ -185,6 +205,7 @@ int RunCmd::runApps(const std::vector<std::string>& 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;
Expand Down
5 changes: 5 additions & 0 deletions apps/aklite-apps/cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ class RunCmd : public Cmd {
"store-root", po::value<std::string>()->default_value("/var/sota/reset-apps"), "Image store root folder")(
"compose-root", po::value<std::string>()->default_value("/var/sota/compose-apps"), "Compose Apps root folder")(
"docker-root", po::value<std::string>()->default_value("/var/lib/docker"), "Docker data root folder")(
#ifdef USE_COMPOSEAPP_ENGINE
"client", po::value<std::string>()->default_value("/usr/bin/composectl"),
"A client to load app images to docker")(
#else
"client", po::value<std::string>()->default_value("/usr/sbin/skopeo"), "A client to copy images")(
#endif
"compose-client", po::value<std::string>()->default_value("/usr/bin/docker compose "),
"A client to manage compose apps");
}
Expand Down
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7db512f

Please sign in to comment.