77 "fmt"
88 "os"
99 "path/filepath"
10+ "strconv"
1011 "strings"
1112 "sync"
1213 "text/template"
@@ -23,6 +24,7 @@ import (
2324const (
2425 DefaultHTTPPort = "6688"
2526 DefaultP2PPort = "6690"
27+ DefaultDebuggerPort = 40000
2628 TmpImageName = "chainlink-tmp:latest"
2729 CustomPortSeparator = ":"
2830)
@@ -54,6 +56,7 @@ type NodeInput struct {
5456 HTTPPort int `toml:"port"`
5557 P2PPort int `toml:"p2p_port"`
5658 CustomPorts []string `toml:"custom_ports"`
59+ DebuggerPort int `toml:"debugger_port"`
5760}
5861
5962// Output represents Chainlink node output, nodes and databases connection URLs
@@ -114,18 +117,38 @@ func NewNode(in *Input, pgOut *postgres.Output) (*Output, error) {
114117 return out , nil
115118}
116119
120+ func generateEntryPoint () []string {
121+ entrypoint := []string {
122+ "/bin/sh" , "-c" ,
123+ }
124+ if os .Getenv ("CTF_CLNODE_DLV" ) == "true" {
125+ entrypoint = append (entrypoint , "dlv exec /usr/local/bin/chainlink --continue --listen=0.0.0.0:40000 --headless=true --api-version=2 --accept-multiclient -- -c /config/config -c /config/overrides -c /config/user-overrides -s /config/secrets -s /config/secrets-overrides -s /config/user-secrets-overrides node start -d -p /config/node_password -a /config/apicredentials" )
126+ } else {
127+ entrypoint = append (entrypoint , "chainlink -c /config/config -c /config/overrides -c /config/user-overrides -s /config/secrets -s /config/secrets-overrides -s /config/user-secrets-overrides node start -d -p /config/node_password -a /config/apicredentials" )
128+ }
129+ return entrypoint
130+ }
131+
117132// generatePortBindings generates exposed ports and port bindings
118133// exposes default CL node port
119134// exposes custom_ports in format "host:docker" or map 1-to-1 if only "host" port is provided
120135func generatePortBindings (in * Input ) ([]string , nat.PortMap , error ) {
121136 httpPort := fmt .Sprintf ("%s/tcp" , DefaultHTTPPort )
137+ innerDebuggerPort := fmt .Sprintf ("%d/tcp" , DefaultDebuggerPort )
138+ debuggerPort := fmt .Sprintf ("%d/tcp" , in .Node .DebuggerPort )
122139 portBindings := nat.PortMap {
123140 nat .Port (httpPort ): []nat.PortBinding {
124141 {
125142 HostIP : "0.0.0.0" ,
126143 HostPort : fmt .Sprintf ("%d/tcp" , in .Node .HTTPPort ),
127144 },
128145 },
146+ nat .Port (innerDebuggerPort ): []nat.PortBinding {
147+ {
148+ HostIP : "0.0.0.0" ,
149+ HostPort : debuggerPort ,
150+ },
151+ },
129152 }
130153 customPorts := make ([]string , 0 )
131154 for _ , p := range in .Node .CustomPorts {
@@ -157,7 +180,7 @@ func generatePortBindings(in *Input) ([]string, nat.PortMap, error) {
157180 }
158181 }
159182 }
160- exposedPorts := []string {httpPort }
183+ exposedPorts := []string {httpPort , strconv . Itoa ( DefaultDebuggerPort ) }
161184 exposedPorts = append (exposedPorts , customPorts ... )
162185 return exposedPorts , portBindings , nil
163186}
@@ -219,11 +242,8 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
219242 framework .DefaultNetworkName : {containerName },
220243 },
221244 ExposedPorts : exposedPorts ,
222- Entrypoint : []string {
223- "/bin/sh" , "-c" ,
224- "chainlink -c /config/config -c /config/overrides -c /config/user-overrides -s /config/secrets -s /config/secrets-overrides -s /config/user-secrets-overrides node start -d -p /config/node_password -a /config/apicredentials" ,
225- },
226- WaitingFor : wait .ForHTTP ("/" ).WithPort (DefaultHTTPPort ).WithStartupTimeout (1 * time .Minute ).WithPollInterval (200 * time .Millisecond ),
245+ Entrypoint : generateEntryPoint (),
246+ WaitingFor : wait .ForHTTP ("/" ).WithPort (DefaultHTTPPort ).WithStartupTimeout (1 * time .Minute ).WithPollInterval (200 * time .Millisecond ),
227247 }
228248 if in .Node .HTTPPort != 0 && in .Node .P2PPort != 0 {
229249 req .HostConfigModifier = func (h * container.HostConfig ) {
0 commit comments