container.go RawHistoryFolder
1// Package domain contains pure business types without external dependencies.
2// These types are used throughout the application and have no tags or framework dependencies.
3package domain
4
5import "time"
6
7// Container represents a running container in the system.
8type Container struct {
9 ID string
10 Image string
11 ImageID string // Docker image ID (sha256 digest) used to detect redundant deploys
12 Name string
13 Status string
14 ExitCode int
15 Ports []int
16 Labels map[string]string
17 VolumeMounts []ContainerVolumeMount
18 Created time.Time
19}
20
21// ContainerVolumeMount describes a mounted volume-like resource on a container.
22type ContainerVolumeMount struct {
23 Name string
24 Type string
25 Source string
26 Destination string
27 ReadOnly bool
28}
29
30// NetworkInfo represents network configuration and state.
31type NetworkInfo struct {
32 ID string
33 Name string
34 Driver string
35 Containers []string
36 Labels map[string]string
37}
38
39// NetworkConfig holds options for creating a container network.
40type NetworkConfig struct {
41 Driver string
42 Internal bool
43 Labels map[string]string
44}
45
46// Attachment represents an attached service container.
47type Attachment struct {
48 Name string
49 Image string
50 ContainerID string
51 Status string
52 Network string
53 Ports []int
54}
55
56// RouteInfo combines route configuration with runtime state.
57type RouteInfo struct {
58 Domain string
59 Image string
60 ContainerID string
61 ContainerStatus string
62 Network string
63 Attachments []Attachment
64}
65
66// ContainerPortPublish describes an explicit host port binding for a container port.
67type ContainerPortPublish struct {
68 HostIP string
69 HostPort int
70 ContainerPort int
71 Protocol NetworkProtocol
72}
73
74// ContainerConfig holds configuration for creating a container.
75type ContainerConfig struct {
76 Image string
77 Name string
78 Env []string
79 Ports []int
80 PortPublishes []ContainerPortPublish
81 Labels map[string]string
82 WorkingDir string
83 Cmd []string
84 AutoRemove bool
85 RestartPolicy string
86 Volumes map[string]string // map[containerPath]volumeName
87 ReadOnlyVolumes map[string]string // containerPath -> volumeName (mounted read-only)
88 NetworkMode string // Network to join
89 Hostname string // Container hostname for DNS
90 Aliases []string // Additional network aliases
91 MemoryLimit int64 // Memory limit in bytes (0 = no limit)
92 NanoCPUs int64 // CPU quota in nanoseconds (1e9 = 1 core, 0 = no limit)
93 PidsLimit int64 // Max number of PIDs (0 = no limit)
94 ReadOnlyRootFS bool // Mount container root filesystem read-only
95 User string // User to run as
96 CapDrop []string // Linux capabilities to drop; nil uses runtime compat defaults
97 CapAdd []string // Linux capabilities to add; nil uses runtime compat defaults
98}
99
100// ContainerStatus represents the current state of a container.
101type ContainerStatus string
102
103const (
104 ContainerStatusRunning ContainerStatus = "running"
105 ContainerStatusStopped ContainerStatus = "stopped"
106 ContainerStatusCreated ContainerStatus = "created"
107 ContainerStatusExited ContainerStatus = "exited"
108 ContainerStatusPaused ContainerStatus = "paused"
109 ContainerStatusUnknown ContainerStatus = "unknown"
110)
111
112const (
113 RestartPolicyAlways = "always"
114)