Adeen commited on
Commit ·
03fbbd1
1
Parent(s): ae14296
fix: resolve Hugging Face deployment and environment variable issues
Browse files- .dockerignore +0 -1
- Dockerfile +31 -10
- src/integrations/supabase/client.ts +7 -0
.dockerignore
CHANGED
|
@@ -2,7 +2,6 @@ node_modules
|
|
| 2 |
dist
|
| 3 |
.git
|
| 4 |
.gitignore
|
| 5 |
-
.env
|
| 6 |
README.md
|
| 7 |
Dockerfile
|
| 8 |
.dockerignore
|
|
|
|
| 2 |
dist
|
| 3 |
.git
|
| 4 |
.gitignore
|
|
|
|
| 5 |
README.md
|
| 6 |
Dockerfile
|
| 7 |
.dockerignore
|
Dockerfile
CHANGED
|
@@ -1,23 +1,44 @@
|
|
| 1 |
# Build stage
|
| 2 |
FROM node:20-alpine AS build
|
| 3 |
WORKDIR /app
|
|
|
|
|
|
|
| 4 |
COPY package*.json ./
|
| 5 |
RUN npm install
|
|
|
|
|
|
|
| 6 |
COPY . .
|
| 7 |
-
|
| 8 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
RUN npm run build
|
| 10 |
|
| 11 |
# Production stage
|
| 12 |
FROM nginx:stable-alpine
|
| 13 |
COPY --from=build /app/dist /usr/share/nginx/html
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
EXPOSE 7860
|
| 23 |
CMD ["nginx", "-g", "daemon off;"]
|
|
|
|
| 1 |
# Build stage
|
| 2 |
FROM node:20-alpine AS build
|
| 3 |
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
# Install dependencies
|
| 6 |
COPY package*.json ./
|
| 7 |
RUN npm install
|
| 8 |
+
|
| 9 |
+
# Copy source and build
|
| 10 |
COPY . .
|
| 11 |
+
|
| 12 |
+
# Build-time arguments for Vite environment variables
|
| 13 |
+
ARG VITE_SUPABASE_URL
|
| 14 |
+
ARG VITE_SUPABASE_PUBLISHABLE_KEY
|
| 15 |
+
|
| 16 |
+
# Set them as environment variables so Vite picks them up during 'npm run build'
|
| 17 |
+
# if they are not already in a .env file copied in the step above
|
| 18 |
+
ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL
|
| 19 |
+
ENV VITE_SUPABASE_PUBLISHABLE_KEY=$VITE_SUPABASE_PUBLISHABLE_KEY
|
| 20 |
+
|
| 21 |
RUN npm run build
|
| 22 |
|
| 23 |
# Production stage
|
| 24 |
FROM nginx:stable-alpine
|
| 25 |
COPY --from=build /app/dist /usr/share/nginx/html
|
| 26 |
+
|
| 27 |
+
# Clean default configuration and create a new one for Hugging Face (port 7860)
|
| 28 |
+
RUN rm /etc/nginx/conf.d/default.conf && \
|
| 29 |
+
printf 'server {\n\
|
| 30 |
+
listen 7860;\n\
|
| 31 |
+
server_name localhost;\n\
|
| 32 |
+
location / {\n\
|
| 33 |
+
root /usr/share/nginx/html;\n\
|
| 34 |
+
index index.html;\n\
|
| 35 |
+
try_files $uri $uri/ /index.html;\n\
|
| 36 |
+
}\n\
|
| 37 |
+
error_page 500 502 503 504 /50x.html;\n\
|
| 38 |
+
location = /50x.html {\n\
|
| 39 |
+
root /usr/share/nginx/html;\n\
|
| 40 |
+
}\n\
|
| 41 |
+
}\n' > /etc/nginx/conf.d/default.conf
|
| 42 |
+
|
| 43 |
EXPOSE 7860
|
| 44 |
CMD ["nginx", "-g", "daemon off;"]
|
src/integrations/supabase/client.ts
CHANGED
|
@@ -5,6 +5,13 @@ import type { Database } from './types';
|
|
| 5 |
const SUPABASE_URL = import.meta.env.VITE_SUPABASE_URL;
|
| 6 |
const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
// Import the supabase client like this:
|
| 9 |
// import { supabase } from "@/integrations/supabase/client";
|
| 10 |
|
|
|
|
| 5 |
const SUPABASE_URL = import.meta.env.VITE_SUPABASE_URL;
|
| 6 |
const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;
|
| 7 |
|
| 8 |
+
if (!SUPABASE_URL || !SUPABASE_PUBLISHABLE_KEY) {
|
| 9 |
+
console.error(
|
| 10 |
+
"Missing Supabase environment variables! " +
|
| 11 |
+
"Ensure VITE_SUPABASE_URL and VITE_SUPABASE_PUBLISHABLE_KEY are set."
|
| 12 |
+
);
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
// Import the supabase client like this:
|
| 16 |
// import { supabase } from "@/integrations/supabase/client";
|
| 17 |
|