# syntax=docker/dockerfile:1
# Build stage: install dependencies and build dist assets using gulp
FROM node:8-alpine AS builder
WORKDIR /app
# Install project dependencies
COPY package.json ./
RUN npm install --silent --no-audit --no-fund
# Copy the rest of the repository
COPY . .
# Build the JS and CSS assets (avoid gulp default watch in production)
RUN npx gulp js
RUN npx gulp css
# Ensure dist exists and copy a minimal index into dist for serving
RUN mkdir -p dist
RUN cp index.html dist/index.html || true
FROM node:8-alpine
WORKDIR /app
# Bring built artifacts from the builder stage
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/index.html /app/index.html
# Install a small HTTP server to serve the static assets
RUN apk add --no-cache bash
RUN npm install -g http-server
EXPOSE 8080
# Start the static server serving the built dist directory
CMD ["http-server", "dist", "-p", "8080"]