FROM node:lts AS builder
WORKDIR /workspace
# Copy the built static site by taking the book directory content as-is
COPY book dist
# Final runtime image: serve the static site with a tiny Node server
FROM node:lts
WORKDIR /app
# Copy the built assets from the builder stage
COPY --from=builder /workspace/dist ./dist
# Install a small static file server
RUN npm install -g http-server
# Expose port for the static server
EXPOSE 8080
# Healthcheck and start server
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD curl -f http://localhost:8080/index.html || exit 1
CMD ["http-server", "./dist", "-p", "8080"]