From d46983f956827242626243273927e2e369355c1e Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Tue, 21 Apr 2026 11:26:10 +0800 Subject: [PATCH] fix proto --- proto/docker.proto | 134 +++++++++++++++++++++++++++++++++++++++++++ proto/message.proto | 136 +------------------------------------------- 2 files changed, 136 insertions(+), 134 deletions(-) create mode 100644 proto/docker.proto diff --git a/proto/docker.proto b/proto/docker.proto new file mode 100644 index 0000000..3341b35 --- /dev/null +++ b/proto/docker.proto @@ -0,0 +1,134 @@ +syntax = "proto3"; + +message ContainerRef { + string id = 1; + string name = 2; +} + +message ContainerRequest { + message List { + bool all = 1; + } + + message Deploy { + uint32 task_id = 1; + ContainerDeployParams params = 2; + } + + message Start { + ContainerRef target = 1; + } + + message Stop { + ContainerRef target = 1; + uint32 timeout_seconds = 2; + } + + message Kill { + ContainerRef target = 1; + string signal = 2; + } + + message Remove { + ContainerRef target = 1; + bool force = 2; + bool remove_volumes = 3; + } + + message Config { + ContainerRef target = 1; + bytes config = 2; + } + + oneof action { + List list = 10; + Deploy deploy = 11; + Start start = 12; + Stop stop = 13; + Kill kill = 14; + Remove remove = 15; + Config config = 16; + } +} + +message ContainerDeployParams { + string container_name = 1; + string container_dir = 2; + DockerCreateOptions create = 3; +} + +message DockerCreateOptions { + DockerContainerConfig config = 1; + DockerHostConfig host_config = 2; + DockerNetworkingConfig networking_config = 3; +} + +message DockerContainerConfig { + string image = 1; + repeated string cmd = 2; + repeated string entrypoint = 3; + + repeated string env = 4; + map labels = 5; + repeated string volumes = 6; + string user = 7; + string working_dir = 8; + string hostname = 9; + repeated DockerExposedPort exposed_ports = 10; + Healthcheck healthcheck = 11; +} + +message DockerHostConfig { + repeated string binds = 1; + string network_mode = 2; + RestartPolicy restart_policy = 3; + bool privileged = 4; + repeated string cap_add = 5; + repeated string cap_drop = 6; + repeated DeviceMapping devices = 7; + uint64 memory = 8; + uint64 memory_reservation = 9; + uint64 nano_cpus = 10; + uint64 cpu_shares = 11; + repeated Ulimit ulimits = 12; + map tmpfs = 13; + map sysctls = 14; + repeated string extra_hosts = 15; +} + +message DockerNetworkingConfig { + repeated DockerNetworkEndpoint endpoints = 1; +} + +message DockerNetworkEndpoint { + string name = 1; +} + +message DockerExposedPort { + uint32 container_port = 1; + string protocol = 2; // tcp / udp +} + +message Healthcheck { + repeated string test = 1; + uint64 interval_ns = 2; + uint64 timeout_ns = 3; + uint32 retries = 4; +} + +message RestartPolicy { + string name = 1; // no, always, unless-stopped, on-failure + uint32 maximum_retry_count = 2; +} + +message DeviceMapping { + string host_path = 1; + string container_path = 2; + string cgroup_permissions = 3; // 默认可填 rwm +} + +message Ulimit { + string name = 1; + uint64 soft = 2; + uint64 hard = 3; +} \ No newline at end of file diff --git a/proto/message.proto b/proto/message.proto index 94e3f26..f3f5e24 100644 --- a/proto/message.proto +++ b/proto/message.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "docker.proto"; + // 整体封装的消息体 message RequestFrame { uint32 packet_id = 1; @@ -36,140 +38,6 @@ message CastFrame { } // message定义 - -message ContainerRef { - string id = 1; - string name = 2; -} - -message ContainerRequest { - message List { - bool all = 1; - } - - message Deploy { - uint32 task_id = 1; - ContainerDeployParams params = 2; - } - - message Start { - ContainerRef target = 1; - } - - message Stop { - ContainerRef target = 1; - uint32 timeout_seconds = 2; - } - - message Kill { - ContainerRef target = 1; - string signal = 2; - } - - message Remove { - ContainerRef target = 1; - bool force = 2; - bool remove_volumes = 3; - } - - message Config { - ContainerRef target = 1; - bytes config = 2; - } - - oneof action { - List list = 10; - Deploy deploy = 11; - Start start = 12; - Stop stop = 13; - Kill kill = 14; - Remove remove = 15; - Config config = 16; - } -} - -message ContainerDeployParams { - string container_name = 1; - string container_dir = 2; - DockerCreateOptions create = 3; -} - -message DockerCreateOptions { - DockerContainerConfig config = 1; - DockerHostConfig host_config = 2; - DockerNetworkingConfig networking_config = 3; -} - -message DockerContainerConfig { - string image = 1; - repeated string cmd = 2; - repeated string entrypoint = 3; - - repeated string env = 4; - map labels = 5; - repeated string volumes = 6; - string user = 7; - string working_dir = 8; - string hostname = 9; - repeated DockerExposedPort exposed_ports = 10; - Healthcheck healthcheck = 11; -} - -message DockerHostConfig { - repeated string binds = 1; - string network_mode = 2; - RestartPolicy restart_policy = 3; - bool privileged = 4; - repeated string cap_add = 5; - repeated string cap_drop = 6; - repeated DeviceMapping devices = 7; - uint64 memory = 8; - uint64 memory_reservation = 9; - uint64 nano_cpus = 10; - uint64 cpu_shares = 11; - repeated Ulimit ulimits = 12; - map tmpfs = 13; - map sysctls = 14; - repeated string extra_hosts = 15; -} - -message DockerNetworkingConfig { - repeated DockerNetworkEndpoint endpoints = 1; -} - -message DockerNetworkEndpoint { - string name = 1; -} - -message DockerExposedPort { - uint32 container_port = 1; - string protocol = 2; // tcp / udp -} - -message Healthcheck { - repeated string test = 1; - uint64 interval_ns = 2; - uint64 timeout_ns = 3; - uint32 retries = 4; -} - -message RestartPolicy { - string name = 1; // no, always, unless-stopped, on-failure - uint32 maximum_retry_count = 2; -} - -message DeviceMapping { - string host_path = 1; - string container_path = 2; - string cgroup_permissions = 3; // 默认可填 rwm -} - -message Ulimit { - string name = 1; - uint64 soft = 2; - uint64 hard = 3; -} - message AuthRequest { bytes uuid = 1; bytes username = 2;