From 396e8dddc066128bb4eb0b5d1a21d14ba759f3f1 Mon Sep 17 00:00:00 2001 From: Kunthawat Date: Thu, 12 Mar 2026 13:21:42 +0700 Subject: [PATCH] fix: Switch to serve for hosting instead of astro preview - Use 'npx serve' for static file serving - Avoid Astro preview host restrictions - Serve all routes from dist/ folder - Fixes 403 forbidden errors - Better for static Astro sites with API endpoints --- Dockerfile | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0fedfe229..e693f7af8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,11 +7,9 @@ COPY package*.json ./ RUN npm install COPY . . - -# Create data directory for database RUN mkdir -p data -# Build the project +# Build project RUN npm run build # Production Stage @@ -22,11 +20,10 @@ WORKDIR /app # Install SQLite runtime RUN apk add --no-cache sqlite-libs -# Copy only production dependencies COPY package*.json ./ RUN npm install --production -# Copy built assets from builder +# Copy built assets COPY --from=builder /app/dist ./dist COPY --from=builder /app/data ./data @@ -40,5 +37,5 @@ ENV NODE_ENV=production ENV ASTRO_PORT=80 ENV ASTRO_HOST=0.0.0.0 -# Run preview command but allow all hosts via ENV instead of config -CMD ["sh", "-c", "npx astro preview --host 0.0.0.0 --port 80"] +# Serve static files using serve package with all-host access +CMD ["npx", "serve", "--listen", "80", "--single", "dist"]