Skip to content
Open
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
18 changes: 9 additions & 9 deletions packer/supabase/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ services:
cap_add:
- NET_ADMIN
environment:
- PUID=1000
- PGID=1000
- TZ=${TIMEZONE}
- URL=${DOMAIN}
- VALIDATION=dns
- SUBDOMAINS=supabase
- DNSPLUGIN=digitalocean
- ONLY_SUBDOMAINS=true
PUID: 1000
PGID: 1000
TZ: ${TIMEZONE}
URL: ${DOMAIN}
VALIDATION: dns
SUBDOMAINS: ${SUBDOMAIN}
DNSPLUGIN: digitalocean
ONLY_SUBDOMAINS: true
volumes:
- ./supabase.subdomain.conf:/config/nginx/proxy-confs/supabase.subdomain.conf
- ./${SUBDOMAIN}.subdomain.conf:/config/nginx/proxy-confs/${SUBDOMAIN}.subdomain.conf
- ./digitalocean.ini:/config/dns-conf/digitalocean.ini
- ./.htpasswd:/config/nginx/.htpasswd
ports:
Expand Down
5 changes: 3 additions & 2 deletions terraform/files/.env.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SERVICE_ROLE_KEY=${TF_SERVICE_ROLE_KEY}
# Database - You can change these to any PostgreSQL database that has logical replication enabled.
############
DOMAIN=${TF_DOMAIN}
SUBDOMAIN=${TF_SUBDOMAIN}
TIMEZONE=${TF_TIMEZONE}

############
Expand Down Expand Up @@ -59,7 +60,7 @@ SITE_URL=https://${TF_SITE_URL}
ADDITIONAL_REDIRECT_URLS=
JWT_EXPIRY=3600
DISABLE_SIGNUP=false
API_EXTERNAL_URL=https://supabase.${TF_DOMAIN}
API_EXTERNAL_URL=https://${TF_SUBDOMAIN}.${TF_DOMAIN}

## Mailer Config
MAILER_URLPATHS_CONFIRMATION="/auth/v1/verify"
Expand Down Expand Up @@ -90,7 +91,7 @@ STUDIO_DEFAULT_ORGANIZATION=${TF_DEFAULT_ORGANIZATION}
STUDIO_DEFAULT_PROJECT=${TF_DEFAULT_PROJECT}

STUDIO_PORT=3000
SUPABASE_PUBLIC_URL=https://supabase.${TF_DOMAIN}
SUPABASE_PUBLIC_URL=https://${TF_SUBDOMAIN}.${TF_DOMAIN}

# Enable webp support
IMGPROXY_ENABLE_WEBP_DETECTION=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ server {
listen 443 ssl;
listen [::]:443 ssl;

server_name supabase.*;
server_name ${TF_SUBDOMAIN}.*;

include /config/nginx/ssl.conf;

Expand Down
14 changes: 14 additions & 0 deletions terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ locals {
TF_JWT_SECRET = "${random_password.jwt.result}",
TF_ANON_KEY = "${jwt_hashed_token.anon.token}",
TF_SERVICE_ROLE_KEY = "${jwt_hashed_token.service_role.token}",
TF_SUBDOMAIN = "${var.subdomain}",
TF_DOMAIN = "${var.domain}",
TF_SITE_URL = "${var.site_url}",
TF_TIMEZONE = "${var.timezone}",
Expand All @@ -135,6 +136,12 @@ locals {

do_ini = templatefile("${path.module}/files/digitalocean.ini.tftpl", { TF_DIGITALOCEAN_TOKEN = "${var.do_token}" })

subdomain_conf = templatefile("${path.module}/files/supabase.subdomain.conf.tftpl",
{
TF_SUBDOMAIN = "${var.subdomain}",
}
)

htpasswd = templatefile("${path.module}/files/.htpasswd.tftpl",
{
AUTH_USER = "${var.auth_user}",
Expand Down Expand Up @@ -167,6 +174,13 @@ locals {
encoding = "b64"
content = base64encode("${local.do_ini}")
},
{
path = "/root/supabase/${var.subdomain}.subdomain.conf"
permissions = "0744"
owner = "root:root"
encoding = "b64"
content = base64encode("${local.subdomain_conf}")
},
{
path = "/root/supabase/.htpasswd"
permissions = "0644"
Expand Down
2 changes: 1 addition & 1 deletion terraform/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resource "digitalocean_reserved_ip" "this" {
resource "digitalocean_record" "a_record" {
domain = var.domain
type = "A"
name = "supabase"
name = var.subdomain
value = digitalocean_reserved_ip.this.ip_address
}

Expand Down
1 change: 1 addition & 0 deletions terraform/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spaces_secret_access_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
## REQUIRED ##
region = "ams3"
domain = "example.com"
subdomain = "supabase"
timezone = "Europe/Amsterdam"
auth_user = "admin"
site_url = "app.example.com"
Expand Down
7 changes: 6 additions & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ variable "region" {
}

variable "domain" {
description = "Domain name where the Supabase instance is accessible. The final domain will be of the format `supabase.example.com`"
description = "Root domain where the Supabase instance is accessible. The final domain will be of the format `subdomain.example.com`"
type = string
}

variable "subdomain" {
description = "Subdomain where the Supabase instance is accessible. The final domain will be of the format `subdomain.example.com`"
type = string
}

Expand Down