+8
-6
@@ -1,4 +1,4 @@
|
||||
# Build: generates /dist (Astro static site + Sanity Studio SPA)
|
||||
# Build: generates /dist (Astro SSR build + Sanity Studio SPA)
|
||||
FROM node:22-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
@@ -6,9 +6,11 @@ RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Frontend: Nginx serving the static site + Sanity Studio SPA
|
||||
FROM nginx:alpine AS frontend
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
# Server: Node.js running the Astro SSR server
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/dist ./dist
|
||||
ENV PORT=80
|
||||
EXPOSE 80
|
||||
CMD ["node", "./dist/server/entry.mjs"]
|
||||
+5
-1
@@ -5,6 +5,8 @@ import sanity from '@sanity/astro';
|
||||
import react from '@astrojs/react';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
|
||||
import netlify from '@astrojs/netlify';
|
||||
|
||||
const env = loadEnv(process.env.NODE_ENV ?? 'development', process.cwd(), '');
|
||||
|
||||
// https://astro.build/config
|
||||
@@ -22,4 +24,6 @@ export default defineConfig({
|
||||
vite: {
|
||||
plugins: [tailwindcss()],
|
||||
},
|
||||
});
|
||||
|
||||
adapter: netlify(),
|
||||
});
|
||||
Generated
+7224
-180
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/check": "^0.9.9",
|
||||
"@astrojs/netlify": "^7.0.9",
|
||||
"@astrojs/react": "^5.0.4",
|
||||
"@lucide/astro": "^1.14.0",
|
||||
"@portabletext/to-html": "^5.0.2",
|
||||
@@ -20,6 +21,8 @@
|
||||
"@sanity/vision": "^3.0.0",
|
||||
"@tailwindcss/vite": "^4.2.4",
|
||||
"astro": "^6.2.1",
|
||||
"node-addon-api": "^8.7.0",
|
||||
"node-gyp": "^12.3.0",
|
||||
"react": "^19.2.5",
|
||||
"react-dom": "^19.2.5",
|
||||
"react-is": "^19.0.0",
|
||||
|
||||
@@ -9,6 +9,8 @@ import { urlFor } from '../sanity/imageUrl';
|
||||
import { theaterHomepageQuery } from '../sanity/queries';
|
||||
import { MapPin } from '@lucide/astro';
|
||||
|
||||
export const prerender = false
|
||||
|
||||
const content = await sanityClient.fetch(theaterHomepageQuery) ?? {};
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
interface CacheEntry {
|
||||
data: unknown;
|
||||
expiresAt: number;
|
||||
}
|
||||
|
||||
const store = new Map<string, CacheEntry>();
|
||||
const DEFAULT_TTL = 60 * 1000; // 1 minute
|
||||
|
||||
function cacheKey(query: string, params: Record<string, unknown>): string {
|
||||
const p = Object.keys(params).sort().map(k => `${k}=${JSON.stringify(params[k])}`).join('&');
|
||||
return `${query}${p ? `?${p}` : ''}`;
|
||||
}
|
||||
|
||||
export function get(key: string): unknown | null {
|
||||
const entry = store.get(key);
|
||||
if (!entry) return null;
|
||||
if (Date.now() > entry.expiresAt) {
|
||||
store.delete(key);
|
||||
return null;
|
||||
}
|
||||
return entry.data;
|
||||
}
|
||||
|
||||
export function set(key: string, data: unknown, ms?: number): void {
|
||||
store.set(key, { data, expiresAt: Date.now() + (ms ?? DEFAULT_TTL) });
|
||||
}
|
||||
+14
-1
@@ -1 +1,14 @@
|
||||
export { sanityClient } from 'sanity:client'
|
||||
import { sanityClient } from 'sanity:client';
|
||||
import { get, set } from './cache';
|
||||
|
||||
export async function fetchWithCache<T>(query: string, params?: Record<string, unknown>): Promise<T | null> {
|
||||
const key = `sanity:${query}:${JSON.stringify(params ?? {})}`;
|
||||
const cached = get(key) as T | null;
|
||||
if (cached) return cached;
|
||||
|
||||
const data = await sanityClient.fetch(query, params);
|
||||
if (data != null) set(key, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
export { sanityClient };
|
||||
|
||||
Reference in New Issue
Block a user