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 Created time.Time
18}
19
20// NetworkInfo represents network configuration and state.
21type NetworkInfo struct {
22 ID string
23 Name string
24 Driver string
25 Containers []string
26 Labels map[string]string
27}
28
29// NetworkConfig holds options for creating a container network.
30type NetworkConfig struct {
31 Driver string
32 Internal bool
33 Labels map[string]string
34}
35
36// Attachment represents an attached service container.
37type Attachment struct {
38 Name string
39 Image string
40 ContainerID string
41 Status string
42 Network string
43 Ports []int
44}
45
46// RouteInfo combines route configuration with runtime state.
47type RouteInfo struct {
48 Domain string
49 Image string
50 ContainerID string
51 ContainerStatus string
52 Network string
53 Attachments []Attachment
54}
55
56// ContainerConfig holds configuration for creating a container.
57type ContainerConfig struct {
58 Image string
59 Name string
60 Env []string
61 Ports []int
62 Labels map[string]string
63 WorkingDir string
64 Cmd []string
65 AutoRemove bool
66 RestartPolicy string
67 Volumes map[string]string // map[containerPath]volumeName
68 ReadOnlyVolumes map[string]string // containerPath -> volumeName (mounted read-only)
69 NetworkMode string // Network to join
70 Hostname string // Container hostname for DNS
71 Aliases []string // Additional network aliases
72 MemoryLimit int64 // Memory limit in bytes (0 = no limit)
73 NanoCPUs int64 // CPU quota in nanoseconds (1e9 = 1 core, 0 = no limit)
74 PidsLimit int64 // Max number of PIDs (0 = no limit)
75 ReadOnlyRootFS bool // Mount container root filesystem read-only
76 User string // User to run as
77 CapDrop []string // Linux capabilities to drop; nil uses runtime compat defaults
78 CapAdd []string // Linux capabilities to add; nil uses runtime compat defaults
79}
80
81// ContainerStatus represents the current state of a container.
82type ContainerStatus string
83
84const (
85 ContainerStatusRunning ContainerStatus = "running"
86 ContainerStatusStopped ContainerStatus = "stopped"
87 ContainerStatusCreated ContainerStatus = "created"
88 ContainerStatusExited ContainerStatus = "exited"
89 ContainerStatusPaused ContainerStatus = "paused"
90 ContainerStatusUnknown ContainerStatus = "unknown"
91)
92
93const (
94 RestartPolicyAlways = "always"
95)