fix: Simplify Dockerfile - let Astro handle public folder
- Remove manual public folder copy - Astro build automatically includes public/ in dist/ - This ensures favicons and other static assets are served Fixes favicon 404 error.
This commit is contained in:
@@ -1,21 +1,4 @@
|
|||||||
# Build Stage
|
# Astro Production Dockerfile
|
||||||
FROM node:20-alpine AS builder
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy package files
|
|
||||||
COPY package*.json ./
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN npm ci
|
|
||||||
|
|
||||||
# Copy source code
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Build the project
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# Production Stage
|
|
||||||
FROM node:20-alpine
|
FROM node:20-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -23,20 +6,17 @@ WORKDIR /app
|
|||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install production dependencies only
|
# Install dependencies
|
||||||
RUN npm ci --production
|
RUN npm ci --omit=dev
|
||||||
|
|
||||||
# Copy built assets from builder
|
# Copy source code
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY . .
|
||||||
COPY --from=builder /app/public ./public
|
|
||||||
COPY --from=builder /app/astro.config.mjs ./
|
# Build Astro project (includes public folder in dist)
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 4321
|
EXPOSE 4321
|
||||||
|
|
||||||
# Health check
|
# Start Astro preview server
|
||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
||||||
CMD node -e "require('http').get('http://localhost:4321', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
|
||||||
|
|
||||||
# Start the server
|
|
||||||
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "4321"]
|
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "4321"]
|
||||||
|
|||||||
Reference in New Issue
Block a user