# Stage 1: Build assets (static project, but simulates a build step)
FROM node:18-alpine AS builder
WORKDIR /build
# Copy all repository contents so we can produce a dist for runtime
COPY . /build
RUN mkdir -p /build/dist \
&& cp -r jquery.onepage-scroll.js jquery.onepage-scroll.min.js onepage-scroll.css Demo /build/dist/
# Stage 2: Runtime image serving static assets via nginx
FROM nginx:stable-alpine-perl
# Copy built assets into the nginx document root
COPY --from=builder /build/dist /usr/share/nginx/html
# Provide a simple index.html at root that redirects to the Demo page
RUN printf '%s\n' '<!doctype html>' '<html>' '<head>' '<meta http-equiv="refresh" content="0; url=/Demo/demo.html" />' '</head>' '<body>' '</body>' '</html>' > /usr/share/nginx/html/index.html
EXPOSE 80
# Run nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]