Skip to content

Commit e558981

Browse files
Merge pull request #90 from harness/make-proxy-port-configurable
(FFM-5131) Make proxy port configurable
2 parents f78f468 + d733c0d commit e558981

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

cmd/ff-proxy/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ func (i *keys) Set(value string) error {
7979
return nil
8080
}
8181

82-
const (
83-
port = 8000
84-
)
85-
8682
var (
8783
debug bool
8884
bypassAuth bool
@@ -110,6 +106,7 @@ var (
110106
flagStreamEnabled bool
111107
generateOfflineConfig bool
112108
configDir string
109+
port int
113110
)
114111

115112
const (
@@ -137,6 +134,7 @@ const (
137134
generateOfflineConfigEnv = "GENERATE_OFFLINE_CONFIG"
138135
configDirEnv = "CONFIG_DIR"
139136
pprofEnabledEnv = "PPROF"
137+
portEnv = "PORT"
140138

141139
bypassAuthFlag = "bypass-auth"
142140
debugFlag = "debug"
@@ -162,6 +160,7 @@ const (
162160
generateOfflineConfigFlag = "generate-offline-config"
163161
configDirFlag = "config-dir"
164162
flagPollIntervalFlag = "flag-poll-interval"
163+
portFlag = "port"
165164
)
166165

167166
func init() {
@@ -190,6 +189,7 @@ func init() {
190189
flag.BoolVar(&flagStreamEnabled, flagStreamEnabledFlag, true, "should the proxy connect to Harness in streaming mode to get flag changes")
191190
flag.BoolVar(&generateOfflineConfig, generateOfflineConfigFlag, false, "if true the proxy will produce offline config in the /config directory then terminate")
192191
flag.StringVar(&configDir, configDirFlag, "/config", "specify a custom path to search for the offline config directory. Defaults to /config")
192+
flag.IntVar(&port, portFlag, 8000, "port the relay proxy service is exposed on, default's to 8000")
193193
sdkClients = newSDKClientMap()
194194

195195
loadFlagsFromEnv(map[string]string{
@@ -217,6 +217,7 @@ func init() {
217217
generateOfflineConfigEnv: generateOfflineConfigFlag,
218218
configDirEnv: configDirFlag,
219219
flagPollIntervalEnv: flagPollIntervalFlag,
220+
portEnv: portFlag,
220221
})
221222

222223
flag.Parse()

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ services:
2020
- API_KEYS=${API_KEYS}
2121
- TARGET_POLL_DURATION=${TARGET_POLL_DURATION}
2222
- GENERATE_OFFLINE_CONFIG=${GENERATE_OFFLINE_CONFIG}
23+
- PORT=${PORT}
2324
build:
2425
context: ./
2526
dockerfile: ./Dockerfile

docker-entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,16 @@ if [ -v target ]; then
3131
echo "* ${target},over_http" > /etc/pushpin/routes
3232
fi
3333

34+
# Update routes file to use $PORT if set
35+
if [ -w /etc/pushpin/routes ]; then
36+
if [ -n "${PORT}" ]; then
37+
echo "Setting internal relay proxy port to ${PORT}"
38+
sed -i \
39+
-e "s/8000/${PORT}/g" \
40+
/etc/pushpin/routes
41+
fi
42+
else
43+
echo "docker-entrypoint.sh: unable to write to /etc/pushpin/routes, readonly"
44+
fi
45+
3446
exec "$@"

tests/e2e/testhelpers/setup/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ ORG_IDENTIFIER=%s
3636
ADMIN_SERVICE_TOKEN=%s
3737
API_KEYS=%s
3838
AUTH_SECRET=my_secret
39-
REDIS_ADDRESS=redis:6379`
39+
REDIS_ADDRESS=redis:6379
40+
PORT=9000`
4041

4142
var generateOfflineConfigTemplate = `ACCOUNT_IDENTIFIER=%s
4243
ORG_IDENTIFIER=%s

0 commit comments

Comments
 (0)