Skip to content
Snippets Groups Projects
Unverified Commit ca85ef57 authored by Vitalii Koshura's avatar Vitalii Koshura Committed by GitHub
Browse files

Merge pull request #6147 from BOINC/dpa_docker_wrapper4

docker_wrapper: support HTML graphics
parents 2e6b3a24 6920f637
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,11 @@ ifdef BUILD_APPS_WITH_VCPKG ...@@ -31,6 +31,11 @@ ifdef BUILD_APPS_WITH_VCPKG
-L$(VCPKG_DIR)/lib -L$(VCPKG_DIR)/lib
endif endif
ifdef BUILD_WITH_MINGW
MAKEFILE_LDFLAGS += \
-lws2_32
endif
all: docker_wrapper all: docker_wrapper
libstdc++.a: libstdc++.a:
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
// docker_wrapper: run a BOINC job in a Docker container, // docker_wrapper: run a BOINC job in a Docker container,
// and interface between the BOINC client and the container // and interface between the BOINC client and the container
// See https://github.com/BOINC/boinc/wiki/Docker-apps#the-docker-wrapper
// //
// docker_wrapper [options] arg1 arg2 ... // docker_wrapper [options] arg1 arg2 ...
// options: // options:
...@@ -92,6 +93,7 @@ ...@@ -92,6 +93,7 @@
#include "util.h" #include "util.h"
#include "boinc_api.h" #include "boinc_api.h"
#include "network.h"
#ifdef _WIN32 #ifdef _WIN32
#include "win_util.h" #include "win_util.h"
...@@ -128,6 +130,10 @@ struct CONFIG { ...@@ -128,6 +130,10 @@ struct CONFIG {
// use this as the image name, and don't delete it when done. // use this as the image name, and don't delete it when done.
// For testing. // For testing.
bool use_gpu; bool use_gpu;
// tell Docker to enable GPU access
int web_graphics_guest_port;
// map this to a host port,
// and inform the client using boinc_web_graphics_url()
vector<string> mounts; vector<string> mounts;
// -v args in create container // -v args in create container
vector<string> portmaps; vector<string> portmaps;
...@@ -141,6 +147,11 @@ struct CONFIG { ...@@ -141,6 +147,11 @@ struct CONFIG {
fprintf(stderr, " project dir mounted at: %s\n", project_dir_mount.c_str()); fprintf(stderr, " project dir mounted at: %s\n", project_dir_mount.c_str());
} }
fprintf(stderr, " use GPU: %s\n", use_gpu?"yes":"no"); fprintf(stderr, " use GPU: %s\n", use_gpu?"yes":"no");
if (web_graphics_guest_port) {
fprintf(stderr, " Web graphics guest port: %d\n",
web_graphics_guest_port
);
}
for (string& s: mounts) { for (string& s: mounts) {
fprintf(stderr, " mount: %s\n", s.c_str()); fprintf(stderr, " mount: %s\n", s.c_str());
} }
...@@ -202,6 +213,11 @@ int parse_config_file() { ...@@ -202,6 +213,11 @@ int parse_config_file() {
config.use_gpu = x->as<bool>(); config.use_gpu = x->as<bool>();
} }
x = v.find("web_graphics_guest_port");
if (x) {
config.web_graphics_guest_port = x->as<int>();
}
x = v.find("mount"); x = v.find("mount");
if (x) { if (x) {
const toml::Array& ar = x->as<toml::Array>(); const toml::Array& ar = x->as<toml::Array>();
...@@ -373,6 +389,26 @@ int create_container() { ...@@ -373,6 +389,26 @@ int create_container() {
strcat(cmd, " --gpus all"); strcat(cmd, " --gpus all");
} }
// web graphics
//
if (config.web_graphics_guest_port) {
int host_port;
retval = boinc_get_port(false, host_port);
if (retval) {
fprintf(stderr, "can't allocated host port for web graphics\n");
} else {
fprintf(stderr, "web graphics: host port %d, guest port %d\n",
host_port, config.web_graphics_guest_port
);
snprintf(buf, sizeof(buf), " -p %d:%d",
host_port, config.web_graphics_guest_port
);
strcat(cmd, buf);
snprintf(buf, sizeof(buf), "http://localhost:%d", host_port);
boinc_web_graphics_url(buf);
}
}
strcat(cmd, " "); strcat(cmd, " ");
strcat(cmd, image_name); strcat(cmd, image_name);
retval = docker_conn.command(cmd, out); retval = docker_conn.command(cmd, out);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)'=='Debug'">libcmtd.lib;libcpmtd.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies Condition="'$(Configuration)'=='Debug'">libcmtd.lib;libcpmtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)'=='Release'">libcmt.lib;libcpmt.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies Condition="'$(Configuration)'=='Release'">libcmt.lib;libcpmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment