FROM node:18-slim # Create app directory WORKDIR /app # Install app dependencies # Copy package manifests first to leverage Docker cache COPY package.json package-lock.json ./ RUN npm ci # Copy the rest of the application code COPY . . # Build the project (assets, pug, scss, scripts, etc.) RUN npm run build # Expose the port BrowserSync serves on (default 3000) EXPOSE 3000 # Start the development server (builds on startup as per package.json) CMD ["npm", "start"]
# Node modules and build artifacts node_modules dist .DS_Store .git "
FROM node:18-slim # Create app directory WORKDIR /app # Install app dependencies # Copy package manifests first to leverage Docker cache COPY package.json package-lock.json ./ RUN npm ci # Copy the rest of the application code COPY . . # Build the project (assets, pug, scss, scripts, etc.) RUN npm run build # Expose the port BrowserSync serves on (default 3000) EXPOSE 3000 # Start the development server (builds on startup as per package.json) CMD ["npm", "start"]
Concerns: Assumes npm start launches a long-running web server; if start script exits, container will terminate., If the project has native dependencies, npm ci may fail on node:18-slim due to missing build tools; may require additional build dependencies in the image., The build step npm run build runs at image build time; ensure this does not rely on environment-specific assets or files not present in all environments. Smoke [FAIL]: curl -sSf http://localhost:3000/ >/dev/null Output: sh: 1: curl: not found
FROM node:18-slim # Create app directory WORKDIR /app # Install app dependencies # Copy package manifests first to leverage Docker cache COPY package.json package-lock.json ./ RUN npm ci # Install runtime utilities (e.g., curl) required by smoke tests RUN apt-get update && apt-get install -y curl ca-certificates && rm -rf /var/lib/apt/lists/* # Copy the rest of the application code COPY . . # Build the project (assets, pug, scss, scripts, etc.) RUN npm run build # Expose the port BrowserSync serves on (default 3000) EXPOSE 3000 # Start the development server (builds on startup as per package.json) CMD ["npm", "start"]
Concerns: Potentially copying host node_modules into the image because there is no .dockerignore; consider adding a .dockerignore to exclude node_modules to keep image size small and ensure reproducible builds., No non-root user specified; the container runs as root. Consider adding a non-root user for security. Smoke [FAIL]: curl -sS --fail http://localhost:3000/ >/dev/null Output: curl: (7) Failed to connect to localhost port 3000 after 0 ms: Couldn't connect to server Smoke [FAIL]: pgrep -x node >/dev/null Output: sh: 1: pgrep: not found
FROM node:18-slim # Create app directory WORKDIR /app # Install app dependencies # Copy package manifests first to leverage Docker cache COPY package.json package-lock.json ./ RUN npm ci # Install runtime utilities and tools required for smoke tests and serving RUN apt-get update && apt-get install -y curl ca-certificates procps && rm -rf /var/lib/apt/lists/* # Install a simple static server to serve built assets RUN npm i -g http-server # Copy the rest of the application code COPY . . # Build the project (assets, pug, scss, scripts, etc.) RUN npm run build # Expose the port the static server will use EXPOSE 3000 # Start a simple static server serving the dist directory CMD ["http-server", "dist", "-p", "3000"]
FROM node:slim # Create app directory WORKDIR /app # Install dependencies COPY package.json package-lock.json ./ RUN npm ci # Install curl for smoke tests RUN apt-get update && apt-get install -y curl ca-certificates && rm -rf /var/lib/apt/lists/* # Copy application source COPY . . # Expose the port BrowserSync will serve on (default 3000) EXPOSE 3000 # Start the development server (builds on startup as per package.json) CMD ["npm", "start"]
Concerns: No HEALTHCHECK defined (could add one), COPY . . may copy unnecessary files; consider using a .dockerignore to avoid bloating the image, Assumes BrowserSync serves on port 3000; if the config changes port, the default tests should be updated Smoke [FAIL]: curl -sSf http://localhost:3000/ >/dev/null && echo 'server-up' || echo 'server-down Output: sh: 1: Syntax error: Unterminated quoted string Smoke [PASS]: curl -sI http://localhost:3000/ | head -n 1
# Node modules and build artifacts node_modules Dist dist .git .DS_Store npm-debug.log* yarn.lock .env
# Build and run Start Bootstrap Simple Sidebar FROM node:slim # Create app directory WORKDIR /app # Install dependencies COPY package.json package-lock.json ./ RUN npm ci # Copy source files COPY . . # Build assets RUN npm run build # Expose port for BrowserSync EXPOSE 3000 # Start the dev server (BrowserSync) to serve dist CMD ["npm","start"]
# Dockerignore for build node_modules dist .git .DS_Store npm-debug.log*
Concerns: Requires package-lock.json to be present in build context; without it, 'npm ci' will fail., Using node:slim may lack build tools required for native modules; builds could fail if dependencies require compilation., COPY . . may bring in unnecessary or sensitive files; consider adding a .dockerignore to limit context and reduce image size. Smoke [PASS]: test -f /app/dist/index.html Smoke [PASS]: ls -la /app/dist