Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix next build public env vars

Tomas Valentada2f878ecb06
diff --git a/Dockerfile b/Dockerfile
index 0ef08a8a0..5cb3d2953 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -8,6 +8,10 @@ RUN npm ci
COPY . .
+ARG NEXT_PUBLIC_SIGN_IN_EMAIL
+ARG NEXT_PUBLIC_SIGN_IN_PASSWORD
+ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
+
ENV NEXT_TELEMETRY_DISABLED 1
ENV BUILD docker
RUN npm run build
@@ -16,6 +20,7 @@ RUN npm run build
FROM node:lts-slim AS runner
WORKDIR /app
+
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV PORT 3000
diff --git a/db/credentials.ts b/db/credentials.ts
index 821fff452..29f8d5345 100644
--- a/db/credentials.ts
+++ b/db/credentials.ts
@@ -1,8 +1,13 @@
+export const serverCreds = {
+ supabaseUrl: process.env.SUPABASE_URL,
+ supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY,
+}
+
const baseURL = typeof window !== 'undefined'
- ? `${window.location.protocol}//${window.location.host}`
- : '<THIS-SHOULD-BE-URL>'
+ && `${window.location.protocol}//${window.location.host}`
-export const credentials = {
- supabaseUrl: process.env.SUPABASE_URL || `${baseURL}/api/supabase`,
- supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
+// The SUPABASE_URL is actually not used but we need a valid URL for the SSR render.
+export const clientCreds = {
+ supabaseUrl: baseURL ? `${baseURL}/api/supabase` : process.env.SUPABASE_URL,
+ supabaseKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
}
diff --git a/docker-compose.yml b/docker-compose.yml
index 6440d4a1b..ef2c570e6 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -22,18 +22,19 @@ services:
image: e2b/app-dev:latest
build:
context: ./
+ args:
+ NEXT_PUBLIC_SIGN_IN_EMAIL: [email protected]
+ NEXT_PUBLIC_SIGN_IN_PASSWORD: [email protected]
+ NEXT_PUBLIC_SUPABASE_ANON_KEY: ${NEXT_PUBLIC_SUPABASE_ANON_KEY}
external_links:
- supabase_kong_workspace
- supabase_db_workspace
environment:
- NODE_ENV=development
- SUPABASE_URL=http://supabase_kong_workspace:8000
- API_URL=http://api:49155
- SUPABASE_POSTGRES_URL=postgresql://postgres:postgres@supabase_db_workspace:5432/postgres
- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}
- - NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}
ports:
- 3000:3000
networks:
diff --git a/pages/[projectID].tsx b/pages/[projectID].tsx
index cb7faa03f..fd077fc63 100644
--- a/pages/[projectID].tsx
+++ b/pages/[projectID].tsx
@@ -7,7 +7,7 @@ import { prisma, projects } from 'db/prisma'
import Editor from 'components/Editor'
import { StoreProvider } from 'state/StoreProvider'
import { Database } from 'db/supabase'
-import { credentials } from 'db/credentials'
+import { serverCreds } from 'db/credentials'
interface PathProps extends ParsedUrlQuery {
projectID: string
@@ -21,7 +21,7 @@ export const getServerSideProps: GetServerSideProps<Props, PathProps> = async (c
}
}
- const supabase = createServerSupabaseClient(ctx, credentials)
+ const supabase = createServerSupabaseClient(ctx, serverCreds)
const {
data: { session },
} = await supabase.auth.getSession()
diff --git a/pages/_app.tsx b/pages/_app.tsx
index bdc0b699b..6816f875f 100644
--- a/pages/_app.tsx
+++ b/pages/_app.tsx
@@ -11,7 +11,7 @@ import 'styles/global.css'
import Header from 'components/Header'
import { Database } from 'db/supabase'
-import { credentials } from 'db/credentials'
+import { clientCreds } from 'db/credentials'
const inter = Inter({
subsets: ['latin'],
@@ -20,7 +20,7 @@ const inter = Inter({
function App({ Component, pageProps }: AppProps<{ initialSession: Session, project?: projects }>) {
const router = useRouter()
- const [supabaseClient] = useState(() => createBrowserSupabaseClient<Database>(credentials))
+ const [supabaseClient] = useState(() => createBrowserSupabaseClient<Database>(clientCreds))
const isSignIn = router.pathname === '/sign' && router.query.signup !== 'true'
const isSignUp = router.pathname === '/sign' && router.query.signup === 'true'
diff --git a/pages/api/project.ts b/pages/api/project.ts
index d1f3142d8..bc759b95b 100644
--- a/pages/api/project.ts
+++ b/pages/api/project.ts
@@ -2,7 +2,7 @@ import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'
import { NextApiRequest, NextApiResponse } from 'next'
import { prisma } from 'db/prisma'
-import { credentials } from 'db/credentials'
+import { serverCreds } from 'db/credentials'
export interface PostProjectBody {
id: string
@@ -14,7 +14,7 @@ async function postProject(req: NextApiRequest, res: NextApiResponse) {
} = req.body as PostProjectBody
try {
- const supabase = createServerSupabaseClient({ req, res }, credentials)
+ const supabase = createServerSupabaseClient({ req, res }, serverCreds)
const { data: { session } } = await supabase.auth.getSession()
if (!session) {
return res.status(401).json({
@@ -75,7 +75,7 @@ async function deleteProject(req: NextApiRequest, res: NextApiResponse) {
const { id } = req.body as PostProjectBody
try {
- const supabase = createServerSupabaseClient({ req, res }, credentials)
+ const supabase = createServerSupabaseClient({ req, res }, serverCreds)
const { data: { session } } = await supabase.auth.getSession()
if (!session) {
return res.status(401).json({
diff --git a/pages/index.tsx b/pages/index.tsx
index 63c465cd4..0157b7fb2 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -8,10 +8,10 @@ import ItemList from 'components/ItemList'
import Text from 'components/Text'
import { prisma, projects } from 'db/prisma'
import Button from 'components/Button'
-import { credentials } from 'db/credentials'
+import { serverCreds } from 'db/credentials'
export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {
- const supabase = createServerSupabaseClient(ctx, credentials)
+ const supabase = createServerSupabaseClient(ctx, serverCreds)
const {
data: { session },
} = await supabase.auth.getSession()
diff --git a/pages/settings.tsx b/pages/settings.tsx
index 34cc57907..4519a78bf 100644
--- a/pages/settings.tsx
+++ b/pages/settings.tsx
@@ -7,10 +7,10 @@ import { useSupabaseClient, useUser } from '@supabase/auth-helpers-react'
import Button from 'components/Button'
import Text from 'components/Text'
import { Database } from 'db/supabase'
-import { credentials } from 'db/credentials'
+import { serverCreds } from 'db/credentials'
export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {
- const supabase = createServerSupabaseClient<Database>(ctx, credentials)
+ const supabase = createServerSupabaseClient<Database>(ctx, serverCreds)
const {
data: { session },
} = await supabase.auth.getSession()