diff --git a/Dockerfile b/Dockerfile index 94f86dff8..2f5c8127a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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}"]