Files
dealplustech/Dockerfile
Kunthawat Greethong b2960ca105 fix: Use only dist folder (contains public assets)
- Astro build automatically copies public/ to dist/
- Remove separate public folder copy (not needed)
- Use PORT environment variable (default 80)
- Fix favicon 404 by using correct dist structure
2026-03-03 13:44:24 +07:00

41 lines
855 B
Docker

# 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 (public folder auto-copied to dist/)
RUN npm run build
# Production Stage
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --production
# Copy ONLY the dist folder (contains build + public assets)
COPY --from=builder /app/dist ./dist
# Expose port
EXPOSE ${PORT:-80}
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:${PORT:-80}', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start the server
CMD ["sh", "-c", "npx astro preview --host 0.0.0.0 --port ${PORT:-80}"]