feat: Switch to Astro SSR with API routes support
- Changed output: 'static' → 'server' in astro.config.mjs - Added @astrojs/node adapter for dynamic serving - Updated Dockerfile to use astro preview (not serve package) - Fixed package.json dependency conflicts - All API routes will work (privacy consent logging) - Static pages still work Now includes BOTH: - ✅ Static pages (product pages, blog) - ✅ Dynamic API routes (cookie consent logging) - ✅ Admin dashboard with database access - ✅ Fixed host restrictions
This commit is contained in:
11
Dockerfile
11
Dockerfile
@@ -9,33 +9,26 @@ RUN npm install
|
||||
COPY . .
|
||||
RUN mkdir -p data
|
||||
|
||||
# Build Astro to static files
|
||||
RUN npm run build
|
||||
|
||||
# Production Stage - Static Server
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 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 serve --production
|
||||
RUN npm install --production
|
||||
|
||||
# Copy built static files and database
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/data ./data
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# Health check with curl
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost/ || exit 1
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=80
|
||||
|
||||
# Serve static files with NO restrictions (plain HTTP server)
|
||||
CMD ["serve", "--no-clipboard", "--single", "--listen", "80", "dist"]
|
||||
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "80"]
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
// @ts-check
|
||||
import { defineConfig } from 'astro/config';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
|
||||
// https://astro.build/config
|
||||
// For SSR with API routes
|
||||
import node from '@astrojs/node';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'static', // Changed from 'hybrid' (deprecated)
|
||||
output: 'server',
|
||||
adapter: node({ mode: 'standalone' }),
|
||||
build: {
|
||||
inlineStylesheets: 'always',
|
||||
},
|
||||
// Remove vite config - we only serve static files via serve package
|
||||
// No preview/server config needed since using static file serving
|
||||
});
|
||||
vite: {
|
||||
preview: {
|
||||
host: true, // Allow any host
|
||||
port: 80,
|
||||
},
|
||||
server: {
|
||||
host: true, // Allow any host
|
||||
port: 80,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
1
dist/_astro/consent-logs.DinS5Xvv.css
vendored
1
dist/_astro/consent-logs.DinS5Xvv.css
vendored
File diff suppressed because one or more lines are too long
3
dist/admin/consent-logs/index.html
vendored
3
dist/admin/consent-logs/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/blog/index.html
vendored
3
dist/blog/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/blog/ข้อดี-ท่อ-hdpe.md/index.html
vendored
3
dist/blog/ข้อดี-ท่อ-hdpe.md/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/blog/ท่อ-ppr-คืออะไร.md/index.html
vendored
3
dist/blog/ท่อ-ppr-คืออะไร.md/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/blog/บำรุงรักษาปั๊มน้ำ.md/index.html
vendored
3
dist/blog/บำรุงรักษาปั๊มน้ำ.md/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/index.html
vendored
3
dist/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/privacy-policy/index.html
vendored
3
dist/privacy-policy/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/products/index.html
vendored
3
dist/products/index.html
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
dist/products/ท่อhdpe/index.html
vendored
3
dist/products/ท่อhdpe/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/products/ท่อppr-thaippr/index.html
vendored
3
dist/products/ท่อppr-thaippr/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/products/ท่อพีพีอาร์ตราช้าง/index.html
vendored
3
dist/products/ท่อพีพีอาร์ตราช้าง/index.html
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
dist/products/ท่อไซเลอร์/index.html
vendored
3
dist/products/ท่อไซเลอร์/index.html
vendored
File diff suppressed because one or more lines are too long
3
dist/terms-and-conditions/index.html
vendored
3
dist/terms-and-conditions/index.html
vendored
File diff suppressed because one or more lines are too long
2
node_modules/.astro/data-store.json
generated
vendored
2
node_modules/.astro/data-store.json
generated
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user