From abd7c2f07334f8372fc882b4fbf9a86d0d584c0b Mon Sep 17 00:00:00 2001 From: john Date: Sun, 18 May 2025 01:30:54 +0200 Subject: [PATCH] add dockerfile --- .env.production | 0 Caddyfile | 7 +++++++ Dockerfile | 25 +++++++++++++++++++++++++ src/hooks/useIntersectionLoad.ts | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .env.production create mode 100644 Caddyfile create mode 100644 Dockerfile diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..e69de29 diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..b0fb964 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,7 @@ +:80 + +root * /usr/share/caddy +file_server + +# Redirect all not-found routes to index.html (SPA fallback) +try_files {path} /index.html diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6bf56db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Stage 1: Build the Vite React app +FROM node:22-alpine AS builder + +WORKDIR /app + +# Install dependencies +COPY package.json /app +COPY yarn.lock /app +RUN yarn install + +COPY . . +RUN yarn build + +# Stage 2: Serve with Caddy +FROM caddy:alpine + +# Copy built app to the web root +COPY --from=builder /app/dist /usr/share/caddy + +# Add Caddyfile (for routing support) +COPY Caddyfile /etc/caddy/Caddyfile + +EXPOSE 80 + +CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] diff --git a/src/hooks/useIntersectionLoad.ts b/src/hooks/useIntersectionLoad.ts index f704131..8464e2f 100644 --- a/src/hooks/useIntersectionLoad.ts +++ b/src/hooks/useIntersectionLoad.ts @@ -48,7 +48,7 @@ export function useIntersectionLoad( observerRef.current = new IntersectionObserver( (entries) => { const entry = entries[0] - if (entry.isIntersecting) { + if (entry?.isIntersecting) { debouncedCallback() } },