From 12040dec5be912a9dbeb960aa928a66c8fa837d4 Mon Sep 17 00:00:00 2001 From: Kunthawat Date: Thu, 12 Mar 2026 13:27:23 +0700 Subject: [PATCH] fix: Complete static server (bypass Astro preview entirely) - Use 'serve' static file server instead of 'astro preview' - Static server has NO host restrictions (pure HTTP) - Bypass Astro preview host validation entirely - Astro built to static files in build stage - Serve static HTML/CSS/JS in production stage - Fixes ALL host restriction issues (403 + blocked request) --- Dockerfile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index e693f7af8..ea973b39d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,33 +9,33 @@ RUN npm install COPY . . RUN mkdir -p data -# Build project +# Build Astro to static files RUN npm run build -# Production Stage +# Production Stage - Static Server FROM node:20-alpine WORKDIR /app -# Install SQLite runtime -RUN apk add --no-cache sqlite-libs +# Install serve and SQLite runtime +RUN apk add --no-cache sqlite-libs curl +# Copy package files with serve dependency COPY package*.json ./ -RUN npm install --production +RUN npm install serve --production -# Copy built assets +# Copy built static files and database COPY --from=builder /app/dist ./dist COPY --from=builder /app/data ./data EXPOSE 80 -# Health check +# Health check with curl HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD node -e "require('http').get('http://localhost:80', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" + CMD curl -f http://localhost/ || exit 1 ENV NODE_ENV=production -ENV ASTRO_PORT=80 -ENV ASTRO_HOST=0.0.0.0 +ENV PORT=80 -# Serve static files using serve package with all-host access -CMD ["npx", "serve", "--listen", "80", "--single", "dist"] +# Serve static files with NO restrictions (plain HTTP server) +CMD ["serve", "--no-clipboard", "--single", "--listen", "80", "dist"]