🐳 Fix: Bind server to 0.0.0.0 for Docker accessibility

This commit is contained in:
Kunthawat Greethong
2026-03-09 22:04:55 +07:00
parent 7a67f68d9f
commit 2465feec7e

View File

@@ -1,15 +1,31 @@
# Production Docker for Astro Static Site
# Build Stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Production Stage
FROM node:20-alpine
WORKDIR /app
# Copy built assets
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./
# Install serve globally
RUN npm install -g serve
# Expose port
EXPOSE 3000
ENV NODE_ENV=production PORT=3000 HOST=0.0.0.0
CMD ["serve", "dist", "-l", "3000", "--single"]
# Environment
ENV NODE_ENV=production
ENV PORT=3000
ENV HOST=0.0.0.0
# Start server - MUST bind to 0.0.0.0 for Docker
CMD ["serve", "dist", "-l", "3000", "--config", "{\"public\":\"dist\",\"directoryListing\":false}"]