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:
Kunthawat Greethong
2026-03-03 10:10:47 +07:00
parent 4f39fa072a
commit f972f68875

View File

@@ -1,21 +1,4 @@
# Build Stage
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
# Astro Production Dockerfile
FROM node:20-alpine
WORKDIR /app
@@ -23,20 +6,17 @@ WORKDIR /app
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --production
# Install dependencies
RUN npm ci --omit=dev
# Copy built assets from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/public ./public
COPY --from=builder /app/astro.config.mjs ./
# Copy source code
COPY . .
# Build Astro project (includes public folder in dist)
RUN npm run build
# Expose port
EXPOSE 4321
# Health check
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
# Start Astro preview server
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "4321"]