From 60efac7a7e6c6ba9f452b187c2f9084a6e734116 Mon Sep 17 00:00:00 2001 From: abhishek Date: Thu, 27 Aug 2026 11:34:11 +0530 Subject: [PATCH] dockerfile added --- .gitignore | 3 +-- Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ nginx.conf | 25 +++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/.gitignore b/.gitignore index 11c21a4..bf6e7ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ node_modules dist -.env -.env.local + *.local .DS_Store .vscode diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0859b36 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# Stage 1: Build the React application +FROM node:22-alpine AS builder + +WORKDIR /app + +# Copy package.json and lockfile +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of your application code +COPY . . + +# Build the Vite application (this creates the /app/dist folder inside the container) +RUN npm run build + +# Stage 2: Serve the application with Nginx +FROM nginx:alpine + +# Set the default Hasura admin secret (can be overridden at runtime) +ENV HASURA_ADMIN_SECRET="nearle-admin-secret" + +# Move to Nginx's public folder +WORKDIR /usr/share/nginx/html + +# CRUCIAL: Remove Nginx's default "Welcome" page files completely +RUN rm -rf ./* + +# Copy the compiled static assets FROM THE BUILDER STAGE +COPY --from=builder /app/dist/ . + +# Copy your custom Nginx configuration into the conf.d directory so it gets included properly +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..10ba96f --- /dev/null +++ b/nginx.conf @@ -0,0 +1,25 @@ +server { + listen 80; + server_name localhost; + + # Serve the React App + location / { + root /usr/share/nginx/html; + index index.html index.htm; + # Force Nginx to pass routing back to React Router + try_files $uri $uri/ /index.html; + } + + # Proxy /hasura to the live API, exactly like Vite dev server does + location /hasura/ { + proxy_pass https://api.workolik.com/api/rest/; + proxy_set_header x-hasura-admin-secret "nearle-admin-secret"; + proxy_ssl_server_name on; + + # Pass standard proxy headers + proxy_set_header Host api.workolik.com; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +}