FROM node:18-slim
# Install Python for a lightweight static server
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
# Copy package manifests first for caching
COPY package.json bower.json composer.json Gruntfile.js ./
# Install dependencies
RUN npm install
# Copy the rest of the source
COPY . .
# Build the project (generate dist with minified assets)
RUN ./node_modules/.bin/grunt copy uglify
# Ensure a minimal dist/index.html exists for smoke tests
RUN mkdir -p dist \
&& sh -c 'if [ ! -f dist/index.html ]; then printf "<html><body><h1>html5shiv</h1></body></html>" > dist/index.html; fi'
EXPOSE 8000
# Serve the built dist as a static site from /dist
CMD ["python3","-m","http.server","8000","--directory","/usr/src/app/dist"]