Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit e997aee

Browse files
authored
fix: set URLs correctly when customizing the port (#982)
1 parent 3467797 commit e997aee

35 files changed

+211
-356
lines changed

dockercompose/auth.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ func auth( //nolint:funlen
3232
httpPort uint,
3333
useTLS bool,
3434
nhostFolder string,
35-
port uint,
35+
exposePort uint,
3636
) (*Service, error) {
37+
if exposePort != 0 {
38+
httpPort = exposePort
39+
}
40+
3741
envars, err := appconfig.HasuraAuthEnv(
3842
cfg,
3943
"http://graphql:8080/v1/graphql",
@@ -94,7 +98,7 @@ func auth( //nolint:funlen
9498
},
9599
},
96100
}.Labels(),
97-
Ports: ports(port, authPort),
101+
Ports: ports(exposePort, authPort),
98102
Restart: "always",
99103
Volumes: []Volume{
100104
{

dockercompose/auth_test.go

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,18 @@ func TestAuth(t *testing.T) {
207207
t.Parallel()
208208

209209
cases := []struct {
210-
name string
211-
cfg func() *model.ConfigConfig
212-
useTlS bool
213-
expected func() *Service
210+
name string
211+
cfg func() *model.ConfigConfig
212+
useTlS bool
213+
exposePort uint
214+
expected func() *Service
214215
}{
215216
{
216-
name: "default",
217-
cfg: getConfig,
218-
useTlS: false,
219-
expected: expectedAuth,
217+
name: "default",
218+
cfg: getConfig,
219+
useTlS: false,
220+
exposePort: 0,
221+
expected: expectedAuth,
220222
},
221223
{
222224
name: "pre-0.22.0",
@@ -225,7 +227,8 @@ func TestAuth(t *testing.T) {
225227
cfg.Auth.Version = ptr("0.21.3")
226228
return cfg
227229
},
228-
useTlS: false,
230+
useTlS: false,
231+
exposePort: 0,
229232
expected: func() *Service {
230233
svc := expectedAuth()
231234
svc.Image = "nhost/hasura-auth:0.21.3"
@@ -237,13 +240,34 @@ func TestAuth(t *testing.T) {
237240
return svc
238241
},
239242
},
243+
{
244+
name: "custom port",
245+
cfg: getConfig,
246+
useTlS: false,
247+
exposePort: 8080,
248+
expected: func() *Service {
249+
svc := expectedAuth()
250+
251+
svc.Environment["AUTH_SERVER_URL"] = "http://dev.auth.local.nhost.run:8080/v1"
252+
svc.Ports = []Port{
253+
{
254+
Mode: "ingress",
255+
Target: 4000,
256+
Published: "8080",
257+
Protocol: "tcp",
258+
},
259+
}
260+
261+
return svc
262+
},
263+
},
240264
}
241265

242266
for _, tc := range cases {
243267
t.Run(tc.name, func(t *testing.T) {
244268
t.Parallel()
245269

246-
got, err := auth(tc.cfg(), "dev", 1336, tc.useTlS, "/tmp/nhost", 0)
270+
got, err := auth(tc.cfg(), "dev", 1336, tc.useTlS, "/tmp/nhost", tc.exposePort)
247271
if err != nil {
248272
t.Errorf("got error: %v", err)
249273
}

dockercompose/storage.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ func storage( //nolint:funlen
2222
httpPort uint,
2323
exposePort uint,
2424
) (*Service, error) {
25+
if exposePort != 0 {
26+
httpPort = exposePort
27+
}
28+
2529
envars, err := appconfig.HasuraStorageEnv(
2630
cfg,
2731
"http://graphql:8080/v1",

dockercompose/storage_test.go

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,47 @@ func TestStorage(t *testing.T) {
6868
t.Parallel()
6969

7070
cases := []struct {
71-
name string
72-
cfg func() *model.ConfigConfig
73-
useTlS bool
74-
expected func() *Service
71+
name string
72+
cfg func() *model.ConfigConfig
73+
useTlS bool
74+
exposePort uint
75+
expected func() *Service
7576
}{
7677
{
77-
name: "success",
78-
cfg: getConfig,
79-
useTlS: false,
80-
expected: expectedStorage,
78+
name: "success",
79+
cfg: getConfig,
80+
useTlS: false,
81+
exposePort: 0,
82+
expected: expectedStorage,
83+
},
84+
{
85+
name: "custom port",
86+
cfg: getConfig,
87+
useTlS: false,
88+
exposePort: 8080,
89+
expected: func() *Service {
90+
svc := expectedStorage()
91+
svc.Environment["PUBLIC_URL"] = "http://dev.storage.local.nhost.run:8080"
92+
93+
svc.Ports = []Port{
94+
{
95+
Mode: "ingress",
96+
Target: 5000,
97+
Published: "8080",
98+
Protocol: "tcp",
99+
},
100+
}
101+
102+
return svc
103+
},
81104
},
82105
}
83106

84107
for _, tc := range cases {
85108
t.Run(tc.name, func(t *testing.T) {
86109
t.Parallel()
87110

88-
got, err := storage(tc.cfg(), "dev", tc.useTlS, 444, 0)
111+
got, err := storage(tc.cfg(), "dev", tc.useTlS, 444, tc.exposePort)
89112
if err != nil {
90113
t.Errorf("got error: %v", err)
91114
}

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/go-git/go-git/v5 v5.16.2
1414
github.com/google/go-cmp v0.7.0
1515
github.com/google/uuid v1.6.0
16-
github.com/hashicorp/go-getter v1.7.8
16+
github.com/hashicorp/go-getter v1.7.9
1717
github.com/nhost/be v0.0.0-20250826100053-51f349e46355
1818
github.com/pelletier/go-toml/v2 v2.2.4
1919
github.com/rs/cors/wrapper/gin v0.0.0-20240830163046-1084d89a1692
@@ -100,7 +100,6 @@ require (
100100
github.com/mattn/go-isatty v0.0.20 // indirect
101101
github.com/mattn/go-runewidth v0.0.16 // indirect
102102
github.com/mitchellh/go-homedir v1.1.0 // indirect
103-
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
104103
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
105104
github.com/modern-go/reflect2 v1.0.2 // indirect
106105
github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de // indirect

go.sum

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ cloud.google.com/go/compute v1.15.1/go.mod h1:bjjoF/NtFUrkD/urWfdHaKuOPDR5nWIs63
180180
cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs=
181181
cloud.google.com/go/compute v1.19.0/go.mod h1:rikpw2y+UMidAe9tISo04EHNOIf42RLYF/q8Bs93scU=
182182
cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE=
183-
cloud.google.com/go/compute v1.41.0 h1:S+HvMIzBUAFK/73wxkrA4/GwvM7R9d+egGZvih4kp+M=
184183
cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU=
185184
cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
186185
cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM=
@@ -685,7 +684,6 @@ github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFos
685684
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
686685
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
687686
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
688-
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
689687
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
690688
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
691689
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@@ -726,7 +724,6 @@ github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWH
726724
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
727725
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 h1:aQ3y1lwWyqYPiWZThqv1aFbZMiM9vblcSArJRf2Irls=
728726
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
729-
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
730727
github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E=
731728
github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw=
732729
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
@@ -951,8 +948,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4Zs
951948
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w=
952949
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
953950
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
954-
github.com/hashicorp/go-getter v1.7.8 h1:mshVHx1Fto0/MydBekWan5zUipGq7jO0novchgMmSiY=
955-
github.com/hashicorp/go-getter v1.7.8/go.mod h1:2c6CboOEb9jG6YvmC9xdD+tyAFsrUaJPedwXDGr0TM4=
951+
github.com/hashicorp/go-getter v1.7.9 h1:G9gcjrDixz7glqJ+ll5IWvggSBR+R0B54DSRt4qfdC4=
952+
github.com/hashicorp/go-getter v1.7.9/go.mod h1:dyFCmT1AQkDfOIt9NH8pw9XBDqNrIKJT5ylbpi7zPNE=
956953
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
957954
github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I=
958955
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
@@ -1032,8 +1029,6 @@ github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcs
10321029
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE=
10331030
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
10341031
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
1035-
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
1036-
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
10371032
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
10381033
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
10391034
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -1047,8 +1042,6 @@ github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc
10471042
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
10481043
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
10491044
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
1050-
github.com/nhost/be v0.0.0-20250730065440-072ba750534a h1:PBNFdtz2XdGUbFVDTJNBdKwtWLab3jgEl0fpb5rn3j0=
1051-
github.com/nhost/be v0.0.0-20250730065440-072ba750534a/go.mod h1:Btk2JXy1ih/+VTlNItNNFfhOTZlKlrodBqXaJ+2K7Pg=
10521045
github.com/nhost/be v0.0.0-20250826100053-51f349e46355 h1:K0orUm3ex3GBuZ8InnmSjAVbYqcO4LfK1ftcsPDS6k0=
10531046
github.com/nhost/be v0.0.0-20250826100053-51f349e46355/go.mod h1:iRPhO+qcQzTtNQ7PaQMJAcEw0tgWzgjzcGWgJ4ifrUo=
10541047
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=

vendor/github.com/hashicorp/go-getter/.goreleaser.yml

Lines changed: 7 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/hashicorp/go-getter/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/hashicorp/go-getter/checksum.go

Lines changed: 18 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/hashicorp/go-getter/client.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)