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
This commit is contained in:
11
Dockerfile
11
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"]
|
||||
|
||||
Reference in New Issue
Block a user