Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default {
'docker-compose.yml',
].map((f) =>
generate({
template: `init/emulator/${f}`,
template: `init/docker/${f}`,
target: `docker/${f}`,
props: {
kongPort,
Expand Down
26 changes: 15 additions & 11 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,22 @@ export default {
},
])

const apiKey =
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJhdWQiOiIiLCJzdWIiOiIiLCJSb2xlIjoicG9zdGdyZXMifQ.magCcozTMKNrl76Tj2dsM7XTl_YH0v0ilajzAvIlw3U'
const anonApiKey =
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJyb2xlIjoiYW5vbiJ9.36fUebxgx1mcBo4s19v0SzqmzunP--hm_hep0uLX0ew'
const serviceRoleApiKey =
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJyb2xlIjoic2VydmljZV9yb2xlIn0.necIJaiP7X2T2QjGeV-FhpkizcNTX8HjDDBAxpgQTEI'

const spinner = spin('Initializing project...')

// Write templates
await Promise.all(
[
'emulator/kong/Dockerfile',
'emulator/kong/kong.yml',
'emulator/postgres/00-initial-schema.sql',
'emulator/postgres/Dockerfile',
'emulator/postgres/auth-schema.sql',
'emulator/docker-compose.yml',
'docker/kong/Dockerfile',
'docker/kong/kong.yml',
'docker/postgres/00-initial-schema.sql',
'docker/postgres/Dockerfile',
'docker/postgres/auth-schema.sql',
'docker/docker-compose.yml',
'README.md',
].map((f) =>
generate({
Expand All @@ -65,18 +67,20 @@ export default {
props: {
kongPort,
dbPort,
apiKey,
anonApiKey,
serviceRoleApiKey,
},
})
)
)

spinner.succeed('Project initialized.')
fancy(`Supabase URL: ${highlight(`http://localhost:${kongPort}`)}
Supabase Key: ${highlight(apiKey)}
Supabase Key (anon, public): ${highlight(anonApiKey)}
Supabase Key (service_role, private): ${highlight(anonApiKey)}
Database URL: ${highlight(`postgres://postgres:postgres@localhost:${dbPort}/postgres`)}

Run ${highlight('supabase start')} to start the local emulator.
Run ${highlight('supabase start')} to start local Supabase.
`)
},
}
8 changes: 5 additions & 3 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ export default {
},
system: { run, which },
}: GluegunToolbox) => {
const spinner = spin('Starting local emulator...')
const spinner = spin('Starting local Supabase...')

const dockerCompose = which('docker-compose')
if (!dockerCompose) {
spinner.fail(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
process.exit(1)
}

await run('docker-compose -f .supabase/emulator/docker-compose.yml up -d')
await run(
'docker-compose --file .supabase/docker/docker-compose.yml --project-name supabase up --detach'
)

spinner.succeed('Started local emulator.')
spinner.succeed('Started local Supabase.')
},
}
6 changes: 3 additions & 3 deletions src/commands/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ export default {
},
system: { run, which },
}: GluegunToolbox) => {
const spinner = spin('Stopping local emulator...')
const spinner = spin('Stopping local Supabase...')

const dockerCompose = which('docker-compose')
if (!dockerCompose) {
spinner.fail(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
process.exit(1)
}

await run('docker-compose -f .supabase/emulator/docker-compose.yml down')
await run('docker-compose --file .supabase/docker/docker-compose.yml down')

spinner.succeed('Stopped local emulator.')
spinner.succeed('Stopped local Supabase.')
},
}
6 changes: 3 additions & 3 deletions src/commands/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default {
Commands:

init Initialize project
start Start local emulator
stop Stop local emulator
start Start local Supabase
stop Stop local Supabase
eject Create a ${highlight(
'docker'
)} directory with the Docker setup for the emulator.
)} directory with the Docker setup for Supabase.
See ${highlight(
'https://supabase.io/docs/guides/self-hosting'
)} for details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: '3.6'
services:
kong:
container_name: supabase-kong
build:
context: ./kong
environment:
Expand All @@ -9,6 +10,7 @@ services:
ports:
- <%= props.kongPort %>:8000/tcp
auth:
container_name: supabase-auth
image: supabase/gotrue:latest
environment:
GOTRUE_JWT_SECRET: super-secret-jwt-token-with-at-least-32-characters-long
Expand All @@ -28,6 +30,7 @@ services:
depends_on:
- db
rest:
container_name: supabase-rest
image: postgrest/postgrest:latest
depends_on:
- db
Expand All @@ -38,6 +41,7 @@ services:
PGRST_DB_ANON_ROLE: postgres
PGRST_JWT_SECRET: super-secret-jwt-token-with-at-least-32-characters-long
realtime:
container_name: supabase-realtime
image: supabase/realtime:latest
depends_on:
- db
Expand All @@ -54,6 +58,7 @@ services:
SECURE_CHANNELS: 'false'
JWT_SECRET: super-secret-jwt-token-with-at-least-32-characters-long
db:
container_name: supabase-db
build:
context: ./postgres
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ services:
consumers:
- username: 'private-key'
keyauth_credentials:
- key: <%= props.apiKey %>
- key: <%= props.anonApiKey %>