Compare commits
3 Commits
bb0dd14ec9
...
main
Author | SHA1 | Date | |
---|---|---|---|
ed1e2ff046 | |||
a895a05f8c | |||
c3f6eadabe |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -46,3 +46,5 @@ yarn-error.log*
|
|||||||
.idea
|
.idea
|
||||||
# Sentry Config File
|
# Sentry Config File
|
||||||
.env.sentry-build-plugin
|
.env.sentry-build-plugin
|
||||||
|
|
||||||
|
src/server/docker/volumes/db/data/
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
techtracker-next:
|
techtracker-next:
|
||||||
build:
|
build:
|
||||||
context: ../../../
|
context: ../../..
|
||||||
dockerfile: docker/development/Dockerfile
|
dockerfile: scripts/docker/development/Dockerfile
|
||||||
image: with-docker-multi-env-development
|
image: with-docker-multi-env-development
|
||||||
container_name: techtracker-next
|
container_name: techtracker-next
|
||||||
networks:
|
networks:
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
techtracker-next:
|
techtracker-next:
|
||||||
build:
|
build:
|
||||||
context: ../../../
|
context: ../../..
|
||||||
dockerfile: docker/production/Dockerfile
|
dockerfile: scripts/docker/production/Dockerfile
|
||||||
image: with-docker-multi-env-development
|
image: with-docker-multi-env-development
|
||||||
container_name: techtracker-next
|
container_name: techtracker-next
|
||||||
networks:
|
networks:
|
||||||
|
@@ -51,7 +51,7 @@ const sentryConfig = {
|
|||||||
// For all available options, see:
|
// For all available options, see:
|
||||||
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
|
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
|
||||||
org: 'gib',
|
org: 'gib',
|
||||||
project: 't3-supabase-template',
|
project: 'tech-tracker-next',
|
||||||
sentryUrl: process.env.NEXT_PUBLIC_SENTRY_URL,
|
sentryUrl: process.env.NEXT_PUBLIC_SENTRY_URL,
|
||||||
authToken: process.env.SENTRY_AUTH_TOKEN,
|
authToken: process.env.SENTRY_AUTH_TOKEN,
|
||||||
// Only print logs for uploading source maps in CI
|
// Only print logs for uploading source maps in CI
|
||||||
|
@@ -1,12 +1,14 @@
|
|||||||
/**
|
/* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
|
||||||
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
|
* This is especially useful for Docker builds.
|
||||||
* for Docker builds.
|
|
||||||
*/
|
*/
|
||||||
import './src/env.js';
|
import './src/env.js';
|
||||||
import { withSentryConfig } from '@sentry/nextjs';
|
import { withSentryConfig } from '@sentry/nextjs';
|
||||||
|
import { withPlausibleProxy } from 'next-plausible';
|
||||||
|
|
||||||
/** @type {import("next").NextConfig} */
|
/** @type {import("next").NextConfig} */
|
||||||
const config = {
|
const config = withPlausibleProxy({
|
||||||
|
customDomain: 'https://plausible.gbrown.org',
|
||||||
|
})({
|
||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
@@ -22,22 +24,29 @@ const config = {
|
|||||||
bodySizeLimit: '10mb',
|
bodySizeLimit: '10mb',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//turbopack: {
|
turbopack: {
|
||||||
//rules: {
|
rules: {
|
||||||
//'*.svg': {
|
'*.svg': {
|
||||||
//loaders: ['@svgr/webpack'],
|
loaders: [
|
||||||
//as: '*.js',
|
{
|
||||||
//},
|
loader: '@svgr/webpack',
|
||||||
//},
|
options: {
|
||||||
//},
|
icon: true,
|
||||||
};
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
as: '*.js',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const sentryConfig = {
|
const sentryConfig = {
|
||||||
// For all available options, see:
|
// For all available options, see:
|
||||||
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
|
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
|
||||||
org: 'gib',
|
org: 'gib',
|
||||||
project: 't3-supabase-template',
|
project: 'tech-tracker-next',
|
||||||
sentryUrl: process.env.SENTRY_URL,
|
sentryUrl: process.env.NEXT_PUBLIC_SENTRY_URL,
|
||||||
authToken: process.env.SENTRY_AUTH_TOKEN,
|
authToken: process.env.SENTRY_AUTH_TOKEN,
|
||||||
// Only print logs for uploading source maps in CI
|
// Only print logs for uploading source maps in CI
|
||||||
silent: !process.env.CI,
|
silent: !process.env.CI,
|
||||||
|
@@ -450,6 +450,8 @@ services:
|
|||||||
- ./volumes/db/logs.sql:/docker-entrypoint-initdb.d/migrations/99-logs.sql:Z
|
- ./volumes/db/logs.sql:/docker-entrypoint-initdb.d/migrations/99-logs.sql:Z
|
||||||
# Changes required for Pooler support
|
# Changes required for Pooler support
|
||||||
- ./volumes/db/pooler.sql:/docker-entrypoint-initdb.d/migrations/99-pooler.sql:Z
|
- ./volumes/db/pooler.sql:/docker-entrypoint-initdb.d/migrations/99-pooler.sql:Z
|
||||||
|
# Initial SQL that should run
|
||||||
|
- ../db/schema.sql:/docker-entrypoint-initdb.d/seed.sql
|
||||||
# Use named volume to persist pgsodium decryption key between restarts
|
# Use named volume to persist pgsodium decryption key between restarts
|
||||||
- db-config:/etc/postgresql-custom
|
- db-config:/etc/postgresql-custom
|
||||||
healthcheck:
|
healthcheck:
|
||||||
@@ -574,4 +576,4 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db-config:
|
db-config:
|
||||||
name: techtracker-db-config
|
name: techtracker-config
|
||||||
|
@@ -1,126 +0,0 @@
|
|||||||
-- Create a table for public profiles
|
|
||||||
create table profiles (
|
|
||||||
id uuid references auth.users on delete cascade not null primary key,
|
|
||||||
updated_at timestamp with time zone,
|
|
||||||
email text unique,
|
|
||||||
full_name text,
|
|
||||||
avatar_url text,
|
|
||||||
provider text,
|
|
||||||
|
|
||||||
constraint full_name_length check (char_length(full_name) >= 3 and char_length(full_name) <= 50)
|
|
||||||
);
|
|
||||||
-- Set up Row Level Security (RLS)
|
|
||||||
-- See https://supabase.com/docs/guides/auth/row-level-security for more details.
|
|
||||||
alter table profiles
|
|
||||||
enable row level security;
|
|
||||||
|
|
||||||
create policy "Public profiles are viewable by everyone." on profiles
|
|
||||||
for select using (true);
|
|
||||||
|
|
||||||
create policy "Users can insert their own profile." on profiles
|
|
||||||
for insert with check ((select auth.uid()) = id);
|
|
||||||
|
|
||||||
create policy "Users can update own profile." on profiles
|
|
||||||
for update using ((select auth.uid()) = id);
|
|
||||||
|
|
||||||
-- This trigger automatically creates a profile entry when a new user signs up via Supabase Auth.
|
|
||||||
-- See https://supabase.com/docs/guides/auth/managing-user-data#using-triggers for more details.
|
|
||||||
create function public.handle_new_user()
|
|
||||||
returns trigger
|
|
||||||
set search_path = ''
|
|
||||||
as $$
|
|
||||||
begin
|
|
||||||
insert into public.profiles (id, email, full_name, avatar_url, provider, updated_at)
|
|
||||||
values (
|
|
||||||
new.id,
|
|
||||||
new.email,
|
|
||||||
new.raw_user_meta_data->>'full_name',
|
|
||||||
new.raw_user_meta_data->>'avatar_url',
|
|
||||||
new.raw_user_meta_data->>'provider',
|
|
||||||
now()
|
|
||||||
);
|
|
||||||
return new;
|
|
||||||
end;
|
|
||||||
$$ language plpgsql security definer;
|
|
||||||
create trigger on_auth_user_created
|
|
||||||
after insert on auth.users
|
|
||||||
for each row execute procedure public.handle_new_user();
|
|
||||||
|
|
||||||
-- Set up Storage!
|
|
||||||
insert into storage.buckets (id, name)
|
|
||||||
values ('avatars', 'avatars');
|
|
||||||
|
|
||||||
-- Set up access controls for storage.
|
|
||||||
-- See https://supabase.com/docs/guides/storage#policy-examples for more details.
|
|
||||||
create policy "Avatar images are publicly accessible." on storage.objects
|
|
||||||
for select using (bucket_id = 'avatars');
|
|
||||||
|
|
||||||
create policy "Anyone can upload an avatar." on storage.objects
|
|
||||||
for insert with check (bucket_id = 'avatars');
|
|
||||||
|
|
||||||
create policy "Anyone can update an avatar." on storage.objects
|
|
||||||
for update using (bucket_id = 'avatars');
|
|
||||||
|
|
||||||
create policy "Anyone can delete an avatar." on storage.objects
|
|
||||||
for delete using (bucket_id = 'avatars');
|
|
||||||
|
|
||||||
-- Create a table for public statuses
|
|
||||||
CREATE TABLE statuses (
|
|
||||||
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
||||||
user_id uuid REFERENCES public.profiles ON DELETE CASCADE NOT NULL,
|
|
||||||
updated_by_id uuid REFERENCES public.profiles ON DELETE SET NULL DEFAULT auth.uid(),
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
status text NOT NULL,
|
|
||||||
CONSTRAINT status_length CHECK (char_length(status) >= 3 AND char_length(status) <= 80)
|
|
||||||
);
|
|
||||||
|
|
||||||
-- Set up Row Level Security (RLS)
|
|
||||||
ALTER TABLE statuses
|
|
||||||
ENABLE ROW LEVEL SECURITY;
|
|
||||||
|
|
||||||
-- Policies
|
|
||||||
CREATE POLICY "Public statuses are viewable by everyone." ON statuses
|
|
||||||
FOR SELECT USING (true);
|
|
||||||
|
|
||||||
-- RECREATE it using the recommended sub-select form
|
|
||||||
CREATE POLICY "Authenticated users can insert statuses for any user."
|
|
||||||
ON public.statuses
|
|
||||||
FOR INSERT
|
|
||||||
WITH CHECK (
|
|
||||||
(SELECT auth.role()) = 'authenticated'
|
|
||||||
);
|
|
||||||
|
|
||||||
-- ADD an UPDATE policy so anyone signed-in can update *any* status
|
|
||||||
CREATE POLICY "Authenticated users can update statuses for any user."
|
|
||||||
ON public.statuses
|
|
||||||
FOR UPDATE
|
|
||||||
USING (
|
|
||||||
(SELECT auth.role()) = 'authenticated'
|
|
||||||
)
|
|
||||||
WITH CHECK (
|
|
||||||
(SELECT auth.role()) = 'authenticated'
|
|
||||||
);
|
|
||||||
|
|
||||||
-- Function to add first status
|
|
||||||
CREATE FUNCTION public.handle_first_status()
|
|
||||||
RETURNS TRIGGER
|
|
||||||
SET search_path = ''
|
|
||||||
AS $$
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO public.statuses (user_id, updated_by_id, status)
|
|
||||||
VALUES (
|
|
||||||
NEW.id,
|
|
||||||
NEW.id,
|
|
||||||
'Just joined!'
|
|
||||||
);
|
|
||||||
RETURN NEW;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql SECURITY DEFINER;
|
|
||||||
|
|
||||||
-- Create a separate trigger for the status
|
|
||||||
CREATE TRIGGER on_auth_user_created_add_status
|
|
||||||
AFTER INSERT ON auth.users
|
|
||||||
FOR EACH ROW EXECUTE PROCEDURE public.handle_first_status();
|
|
||||||
|
|
||||||
alter publication supabase_realtime add table profiles;
|
|
||||||
alter publication supabase_realtime add table statuses;
|
|
Reference in New Issue
Block a user