refactory-id-bootstrap-markdown
SUCCESS
4m 37s
History Source
SummaryIterations1Transcript6Dockerfile
Dockerfile39 lines · 1335 chars
FROM node:18-slim

# Create app directory
WORKDIR /app

# Install system dependencies needed for building and fetching dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        git ca-certificates python3 build-essential && \
    rm -rf /var/lib/apt/lists/*

# Install global tooling for building front-end assets
RUN npm install -g bower less

# Install project dependencies (package.json and bower.json are copied first to leverage Docker cache)
COPY package.json bower.json ./
RUN npm install && npm cache clean --force
RUN bower install --allow-root

# Copy the rest of the repository
COPY . .

# Build assets from source when possible. If Less is not available or fails, fall back to existing minified CSS.
RUN mkdir -p css && \
    if command -v lessc >/dev/null 2>&1; then \
        if lessc less/bootstrap-markdown.less css/bootstrap-markdown.css; then \
            echo "Less compiled successfully"; \
        else \
            echo "Less compilation failed, using prebuilt CSS"; \
            cp css/bootstrap-markdown.min.css css/bootstrap-markdown.css; \
        fi; \
    else \
        echo "lessc not found, using prebuilt CSS"; \
        cp css/bootstrap-markdown.min.css css/bootstrap-markdown.css; \
    fi

# Default command: drop into a shell for testing or usage
CMD ["bash"]