add dockerfile

This commit is contained in:
john 2025-05-18 01:30:54 +02:00
parent dcaccc7ab8
commit abd7c2f073
4 changed files with 33 additions and 1 deletions

0
.env.production Normal file
View file

7
Caddyfile Normal file
View file

@ -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

25
Dockerfile Normal file
View file

@ -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"]

View file

@ -48,7 +48,7 @@ export function useIntersectionLoad(
observerRef.current = new IntersectionObserver( observerRef.current = new IntersectionObserver(
(entries) => { (entries) => {
const entry = entries[0] const entry = entries[0]
if (entry.isIntersecting) { if (entry?.isIntersecting) {
debouncedCallback() debouncedCallback()
} }
}, },