Skip to content

Commit eb94aef

Browse files
committed
bug fix
1 parent 00b7cf3 commit eb94aef

File tree

4 files changed

+44
-24
lines changed

4 files changed

+44
-24
lines changed

containers/kong/kong-template.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ acls:
3535
services:
3636
## Open Auth routes
3737
- name: auth-v1-open
38-
url: ${SUPABASE_AUTH_URL:=http://auth:9999/}verify
38+
url: ${SUPABASE_AUTH_URL:=http://auth.supabase.internal:9999/}verify
3939
routes:
4040
- name: auth-v1-open
4141
strip_path: true
@@ -44,7 +44,7 @@ services:
4444
plugins:
4545
- name: cors
4646
- name: auth-v1-open-callback
47-
url: ${SUPABASE_AUTH_URL:=http://auth:9999/}callback
47+
url: ${SUPABASE_AUTH_URL:=http://auth.supabase.internal:9999/}callback
4848
routes:
4949
- name: auth-v1-open-callback
5050
strip_path: true
@@ -53,7 +53,7 @@ services:
5353
plugins:
5454
- name: cors
5555
- name: auth-v1-open-authorize
56-
url: ${SUPABASE_AUTH_URL:=http://auth:9999/}authorize
56+
url: ${SUPABASE_AUTH_URL:=http://auth.supabase.internal:9999/}authorize
5757
routes:
5858
- name: auth-v1-open-authorize
5959
strip_path: true
@@ -65,7 +65,7 @@ services:
6565
## Secure Auth routes
6666
- name: auth-v1
6767
_comment: "GoTrue: /auth/v1/* -> http://auth:9999/*"
68-
url: ${SUPABASE_AUTH_URL:=http://auth:9999/}
68+
url: ${SUPABASE_AUTH_URL:=http://auth.supabase.internal:9999/}
6969
routes:
7070
- name: auth-v1-all
7171
strip_path: true
@@ -86,7 +86,7 @@ services:
8686
## Secure REST routes
8787
- name: rest-v1
8888
_comment: "PostgREST: /rest/v1/* -> http://rest:3000/*"
89-
url: ${SUPABASE_REST_URL:=http://rest:3000/}
89+
url: ${SUPABASE_REST_URL:=http://rest.supabase.internal:3000/}
9090
routes:
9191
- name: rest-v1-all
9292
strip_path: true
@@ -107,7 +107,7 @@ services:
107107
## Secure GraphQL routes
108108
- name: graphql-v1
109109
_comment: "PostgREST: /graphql/v1/* -> http://rest:3000/rpc/graphql"
110-
url: ${SUPABASE_GRAPHQL_URL:=http://rest:3000/rpc/graphql}
110+
url: ${SUPABASE_GRAPHQL_URL:=http://rest.supabase.internal:3000/rpc/graphql}
111111
routes:
112112
- name: graphql-v1-all
113113
strip_path: true
@@ -133,7 +133,7 @@ services:
133133
## Secure Realtime routes
134134
- name: realtime-v1
135135
_comment: "Realtime: /realtime/v1/* -> ws://realtime:4000/socket/*"
136-
url: ${SUPABASE_REALTIME_URL:=http://realtime:4000/socket/}
136+
url: ${SUPABASE_REALTIME_URL:=http://realtime.supabase.internal:4000/socket/}
137137
routes:
138138
- name: realtime-v1-all
139139
strip_path: true
@@ -154,7 +154,7 @@ services:
154154
## Storage routes: the storage server manages its own auth
155155
- name: storage-v1
156156
_comment: "Storage: /storage/v1/* -> http://storage:5000/*"
157-
url: ${SUPABASE_STORAGE_URL:=http://storage:5000/}
157+
url: ${SUPABASE_STORAGE_URL:=http://storage.supabase.internal:5000/}
158158
routes:
159159
- name: storage-v1-all
160160
strip_path: true
@@ -166,7 +166,7 @@ services:
166166
## Secure Database routes
167167
- name: meta
168168
_comment: "pg-meta: /pg/* -> http://pg-meta:8080/*"
169-
url: ${SUPABASE_META_HOST:=http://meta:8080/}
169+
url: ${SUPABASE_META_HOST:=http://meta.supabase.internal:8080/}
170170
routes:
171171
- name: meta-all
172172
strip_path: true

src/ecs-patterns.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export interface AutoScalingFargateServiceProps extends BaseFargateServiceProps
3030

3131
export class BaseFargateService extends Construct {
3232
readonly listenerPort: number;
33-
readonly serviceName: string;
33+
readonly dnsName: string;
3434
readonly service: ecs.FargateService;
3535

3636
constructor(scope: Construct, id: string, props: BaseFargateServiceProps) {
3737
super(scope, id);
3838

39-
this.serviceName = props.serviceName || id.toLowerCase();
39+
const serviceName = props.serviceName || id.toLowerCase();
4040
const { cluster, taskImageOptions } = props;
4141

4242
this.listenerPort = taskImageOptions.containerPort;
@@ -79,12 +79,13 @@ export class BaseFargateService extends Construct {
7979
this.service.enableServiceConnect({
8080
services: [{
8181
portMappingName: 'http',
82-
discoveryName: this.serviceName,
83-
dnsName: this.serviceName,
82+
discoveryName: serviceName,
8483
}],
8584
logDriver,
8685
});
8786

87+
this.dnsName = `${serviceName}.${cluster.defaultCloudMapNamespace?.namespaceName}`;
88+
8889
//const cloudMapService = this.service.enableCloudMap({
8990
// name: this.serviceName,
9091
// dnsRecordType: servicediscovery.DnsRecordType.SRV,

src/supabase-stack.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ export class SupabaseStack extends FargateStack {
269269
minTaskCount: 0,
270270
maxTaskCount: 0,
271271
});
272-
kong.service.taskDefinition.defaultContainer!.addEnvironment('SUPABASE_GRAPHQL_URL', `http://${gql.serviceName}:${gql.listenerPort}/graphql`);
273272

274273
const realtime = new AutoScalingFargateService(this, 'Realtime', {
275274
cluster,
@@ -313,7 +312,7 @@ export class SupabaseStack extends FargateStack {
313312
image: ecs.ContainerImage.fromRegistry(storageImageUri.valueAsString),
314313
containerPort: 5000,
315314
environment: {
316-
POSTGREST_URL: `http://${rest.serviceName}:${rest.listenerPort}`,
315+
POSTGREST_URL: `http://${rest.dnsName}:${rest.listenerPort}`,
317316
PGOPTIONS: '-c search_path=storage,public',
318317
FILE_SIZE_LIMIT: '52428800',
319318
TENANT_ID: 'stub',
@@ -357,6 +356,13 @@ export class SupabaseStack extends FargateStack {
357356
},
358357
});
359358

359+
kong.service.taskDefinition.defaultContainer!.addEnvironment('SUPABASE_AUTH_URL', `http://${auth.dnsName}:${auth.listenerPort}/`);
360+
kong.service.taskDefinition.defaultContainer!.addEnvironment('SUPABASE_REST_URL', `http://${rest.dnsName}:${rest.listenerPort}/`);
361+
kong.service.taskDefinition.defaultContainer!.addEnvironment('SUPABASE_GRAPHQL_URL', `http://${gql.dnsName}:${gql.listenerPort}/graphql`);
362+
kong.service.taskDefinition.defaultContainer!.addEnvironment('SUPABASE_REALTIME_URL', `http://${realtime.dnsName}:${realtime.listenerPort}/socket/`);
363+
kong.service.taskDefinition.defaultContainer!.addEnvironment('SUPABASE_STORAGE_URL', `http://${storage.dnsName}:${storage.listenerPort}/`);
364+
kong.service.taskDefinition.defaultContainer!.addEnvironment('SUPABASE_META_HOST', `http://${meta.dnsName}:${meta.listenerPort}/`);
365+
360366
kong.addBackend(auth);
361367
kong.addBackend(rest);
362368
kong.addBackend(gql);

test/__snapshots__/main.test.ts.snap

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

0 commit comments

Comments
 (0)