- 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)
42 lines
857 B
Docker
42 lines
857 B
Docker
# Build Stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
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
|
|
|
|
# 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"]
|