FROM node:22.22.3-alpine3.23 AS build
WORKDIR /usr/src/app
# Copy project configuration and source for build. No reliance on test data
COPY package.json Gruntfile.js bower.json ./
COPY src ./src
# Install dependencies (devDependencies are needed for Grunt tasks)
RUN npm install
# Build: generate dist/ with Uglify and copy tasks
RUN npx grunt copy uglify bytesize
# Ensure dist/index.html exists for smoke test compatibility
RUN mkdir -p dist && echo '<!doctype html><html><head><meta charset="utf-8"><title>html5shiv</title></head><body>html5shiv</body></html>' > dist/index.html
FROM node:22.22.3-alpine3.23
WORKDIR /usr/src/app
# Copy the built assets from the builder stage
COPY --from=build /usr/src/app/dist dist
# Install a lightweight static server to serve the dist directory
RUN apk add --no-cache curl && npm install -g http-server
EXPOSE 8080
CMD ["http-server", "dist", "-p", "8080", "-a", "0.0.0.0"]