# syntax=docker/dockerfile:1
FROM node:slim AS builder
# Install build tools
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends build-essential python2 ca-certificates && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy package manifests first for better caching
COPY package.json package-lock.json ./
RUN npm ci
# Copy rest of source
COPY . .
# Build
RUN npm run build
# Production image
FROM node:slim
WORKDIR /app
# Copy only dist from builder
COPY --from=builder /app/dist ./dist
# Expose nothing; provide a minimal CMD to drop into shell
CMD ["/bin/sh"]
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
# Docker ignore rules node_modules/ dist/ coverage/ test/ .vscode/ .idea/ .git/ .gitignore .DS_Store npm-debug.log* yarn-error.log* npm-cache/ *.log log/ build/ docs/ docs/
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
const http = require('http');
const fs = require('fs');
const path = require('path');
// Simple static file server serving files from ./dist
const PORT = process.env.PORT || 8080;
const ROOT = path.resolve(__dirname, 'dist');
function getContentType(filePath) {
const ext = path.extname(filePath).toLowerCase();
switch (ext) {
case '.html': return 'text/html';
case '.js': return 'application/javascript';
case '.css': return 'text/css';
case '.json': return 'application/json';
case '.svg': return 'image/svg+xml';
case '.png': return 'image/png';
case '.jpg': case '.jpeg': return 'image/jpeg';
case '.gif': return 'image/gif';
case '.woff': return 'font/woff';
case '.woff2': return 'font/woff2';
default: return 'application/octet-stream';
}
}
const server = http.createServer((req, res) => {
// Only handle GET requests for simplicity
if (req.method !== 'GET') {
res.statusCode = 405;
return res.end('Method Not Allowed');
}
// Normalize URL and map to file under dist
let urlPath = decodeURIComponent(req.url.split('?')[0]);
if (urlPath === '/') {
urlPath = '/index.html';
}
// Try serving from dist directly
let filePath = path.join(ROOT, urlPath);
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) {
// If not found, try stripping leading '/'
filePath = path.join(ROOT, urlPath.replace(/^\//, ''));
}
if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {
const stat = fs.statSync(filePath);
res.setHeader('Content-Type', getContentType(filePath));
res.setHeader('Content-Length', stat.size);
const readStream = fs.createReadStream(filePath);
readStream.pipe(res);
} else {
res.statusCode = 404;
res.end('Not Found');
}
});
server.listen(PORT, () => {
console.log(`Static dist server listening on port ${PORT}`);
});
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
# syntax=docker/dockerfile:1
FROM node:slim AS builder
# Install build tools including Python 2 for node-sass compatibility
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends build-essential python2 ca-certificates && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy manifests first to leverage Docker cache
COPY package.json package-lock.json ./
RUN npm ci
# Copy the rest of the source and build
COPY . .
RUN npm run build
# Production/runtime image
FROM node:slim AS runtime
WORKDIR /app
# Copy the built artifacts from builder
COPY --from=builder /app/dist ./dist
# Copy a small static server to serve the dist directory
COPY server.js ./server.js
EXPOSE 8080
# Run the static server
CMD ["node", "server.js"]
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
FROM node:slim AS builder
WORKDIR /app
# Install build tools (Python 3 is used; some Node.js tooling may require Python 2, but this setup maps python to python3)
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends build-essential python3 g++ ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Provide a python alias for tools expecting 'python'
RUN ln -s /usr/bin/python3 /usr/bin/python 2>/dev/null || true
COPY package.json package-lock.json* ./
RUN npm ci --silent
COPY . .
# Build the project from source
RUN npm run build
# Create a minimal Node.js static server to expose the built dist for runtime usage
RUN bash -lc 'cat > /app/server.js << "JS"
const http = require("http");
const fs = require("fs");
const path = require("path");
const distDir = path.resolve(__dirname, "dist");
const mainFile = path.resolve(distDir, "vue-material.js");
const port = process.env.PORT || 8080;
const server = http.createServer((req, res) => {
fs.readFile(mainFile, (err, data) => {
if (err) {
res.statusCode = 404;
res.end("Not found");
return;
}
res.setHeader("Content-Type", "application/javascript");
res.end(data);
});
});
server.listen(port, () => {
console.log("Serving " + mainFile + " on http://0.0.0.0:" + port);
});
JS'
FROM node:slim as runtime
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/server.js ./server.js
EXPOSE 8080
CMD ["node", "server.js"]
# Ignore node_modules and build artefacts node_modules/ dist/ .vscode/ .env .env* *.log npm-debug.log* *.tmp .git .gitignore .gitmodules *.png *.jpg *.jpeg *.gif README.md docs/
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
# Multi-stage Dockerfile to build vue-material from source and serve dist
FROM node:slim AS builder
WORKDIR /app
# Install build dependencies (Python 2 and compilers required by node-sass)
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends build-essential python2 && \
rm -rf /var/lib/apt/lists/*
# Install dependencies deterministically
COPY package.json package-lock.json ./
RUN npm ci
# Copy source and build
COPY . .
RUN npm run build
FROM node:slim AS runtime
WORKDIR /app
# Minimal runtime: serve the generated dist with a tiny static server
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/dist ./dist
# Install a small static file server
RUN npm install -g http-server
EXPOSE 8080
CMD ["http-server", "dist", "-p", "8080"]
node_modules/ dist/ build/ .tmp/ .vscode/ .idea/ .git/ *.log coverage/ docs/
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
# Multi-stage Dockerfile to build vue-material from source and serve dist
FROM node:slim AS builder
WORKDIR /app
# Install build dependencies (Python 2 and compilers required by node-sass)
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends build-essential python2 && \
# Provide a python alias for Python 2 scripts that expect `python`
ln -s /usr/bin/python2 /usr/bin/python || true && \
rm -rf /var/lib/apt/lists/*
# Install dependencies deterministically
COPY package.json package-lock.json ./
RUN npm ci
# Copy source and build
COPY . .
RUN npm run build
FROM node:slim AS runtime
WORKDIR /app
# Minimal runtime: serve the generated dist with a tiny static server
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/dist ./dist
# Install a small static file server
RUN npm install -g http-server
EXPOSE 8080
CMD ["http-server", "dist", "-p", "8080"]
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
# Multi-stage Dockerfile to build vue-material from source and serve dist
FROM node:slim AS builder
WORKDIR /app
# Install build dependencies (Python 2 and compilers required by node-sass)
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends build-essential python2 && \
# Provide a python alias for Python 2 scripts that expect `python`
ln -s /usr/bin/python2 /usr/bin/python || true && \
rm -rf /var/lib/apt/lists/*
# Create a non-root user for building
RUN groupadd -r app && useradd -r -g app app
# Ensure app directory is owned by non-root user
RUN mkdir -p /app && chown -R app:app /app
USER app
WORKDIR /app
# Install dependencies deterministically
COPY --chown=app:app package.json package-lock.json ./
RUN npm ci
# Copy source and build
COPY --chown=app:app . .
RUN npm run build
FROM node:slim AS runtime
WORKDIR /app
# Create non-root user for runtime
RUN groupadd -r app && useradd -r -g app app
# Minimal runtime: serve the generated dist with a tiny static server
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/dist ./dist
# Install a small static file server (as root during build, but will be used by non-root at runtime)
RUN npm install -g http-server
USER app
EXPOSE 8080
CMD ["http-server", "dist", "-p", "8080"]
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock