Skip to content

Commit 4d427ac

Browse files
committed
Merge branch 'main' into generate-genesis
2 parents be2909c + 5309eee commit 4d427ac

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

local/network.go

+10
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,16 @@ func (ln *localNetwork) buildArgs(
11891189
config.BootstrapIDsKey: ln.bootstraps.IDsArg(),
11901190
}
11911191

1192+
insideContainer, err := utils.IsInsideDockerContainer()
1193+
if err != nil {
1194+
return buildArgsReturn{}, err
1195+
}
1196+
if insideContainer {
1197+
// mapped localhost requests (eg using -p flag of docker run) are seen as coming from an external IP like 172.17.0.1
1198+
// so inside docker container just accept all requests
1199+
flags[config.HTTPHostKey] = ""
1200+
}
1201+
11921202
// Write staking key/cert etc. to disk so the new node can use them,
11931203
// and get flag that point the node to those files
11941204
fileFlags, err := writeFiles(ln.networkID, ln.genesis, dataDir, nodeConfig)

scripts/build.sh

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ else
1515
OUTPUT=$1
1616
fi
1717

18+
# Check for CGO_ENABLED
19+
if [[ $(go env CGO_ENABLED) = 0 ]]; then
20+
echo "must have installed gcc (linux), clang (macos), or have set CC to an appropriate C compiler"
21+
exit 1
22+
fi
23+
1824
# Set the CGO flags to use the portable version of BLST
1925
#
2026
# We use "export" here instead of just setting a bash variable because we need

utils/utils.go

+16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
const (
1919
genesisNetworkIDKey = "networkID"
2020
dirTimestampFormat = "20060102_150405"
21+
dockerEnvPath = "/.dockerenv"
2122
)
2223

2324
var (
@@ -140,3 +141,18 @@ func VerifySubnetHasCorrectParticipants(
140141
}
141142
return false
142143
}
144+
145+
func IsInsideDockerContainer() (bool, error) {
146+
return PathExists(dockerEnvPath)
147+
}
148+
149+
func PathExists(path string) (bool, error) {
150+
_, err := os.Stat(path)
151+
if err != nil {
152+
if errors.Is(err, fs.ErrNotExist) {
153+
return false, nil
154+
}
155+
return false, err
156+
}
157+
return true, nil
158+
}

0 commit comments

Comments
 (0)