### Quick Start: Initialize and Configure Starter Kit Source: https://thedecipherist.com/articles/claude-code-mastery-project-starter-kit This section outlines the initial steps to get started with the starter kit. It includes cloning the repository, initializing a new Git repository, installing global configurations, setting up the project, and starting the development environment. It also covers converting an existing project to use the starter kit. ```bash # 1. Clone git clone https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit my-project cd my-project && rm -rf .git && git init # 2. Install global config (one-time, never overwrites existing) claude /install-global # 3. Configure your project claude /setup # 4. Start building claude ``` ```bash claude "/convert-project-to-starter-kit ~/my-existing-project" ``` -------------------------------- ### Example .env.example File for Project Setup Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 An example `.env.example` file demonstrating how to define required environment variables with placeholder values. Committing this file to version control helps new team members set up their local development environment correctly. ```dotenv # .env.example (committed to git) POSTGRES_USER=myapp POSTGRES_PASSWORD=change_me_locally POSTGRES_DB=myapp_dev NODE_ENV=development REDIS_URL=redis://redis:6379 JWT_SECRET=any_random_string_for_dev ``` -------------------------------- ### Automated MongoDB Setup and Initialization Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Commands to prepare the environment, execute the installation script, and configure replica set nodes. These commands handle directory creation, permission management, and service execution. ```bash # Create a directory for MongoDB setup files mkdir -p mongodb-setup && cd mongodb-setup # Create the installation script nano mongodb-install.sh # Make executable chmod +x mongodb-install.sh # Run with sudo sudo ./mongodb-install.sh ``` -------------------------------- ### StrictDB Basic Usage Example (Node.js) Source: https://thedecipherist.com/articles/strictDB A quick start example demonstrating how to initialize StrictDB, discover schemas, perform read and write operations, update, delete, and inspect query plans. It covers the essential workflow for interacting with a database via StrictDB. ```javascript import { StrictDB } from 'strictdb'; const db = await StrictDB.create({ uri: process.env.DATABASE_URL }); // Discover const schema = await db.describe('users'); // Read const user = await db.queryOne('users', { email: 'tim@example.com' }); // Write const receipt = await db.insertOne('users', { email: 'new@example.com', name: 'New User' }); // Update await db.updateOne('users', { email: 'tim@example.com' }, { $set: { role: 'admin' } }); // Delete await db.deleteOne('users', { email: 'old@example.com' }); // What runs under the hood const plan = await db.explain('users', { filter: { role: 'admin' }, limit: 50 }); await db.close(); ``` -------------------------------- ### Start Service with Fixed Port Source: https://thedecipherist.com/articles/claude-code-guide-v5 Demonstrates how to explicitly define a port when starting a development server to avoid default port conflicts. ```bash # CORRECT npx next dev -p 3002 # WRONG - never let it default npx next dev ``` -------------------------------- ### Install PaaS Platforms via Shell Script Source: https://thedecipherist.com/articles/docker-swarm-guide Installation commands for self-hosted PaaS solutions Dokploy and Coolify using their respective bootstrap scripts. ```bash # Install Dokploy curl -sSL https://dokploy.com/install.sh | sh # Install Coolify curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash ``` -------------------------------- ### RuleCatch MCP Server Setup (JSON) Source: https://thedecipherist.com/articles/rulecatch This JSON configuration sets up the RuleCatch MCP server. It specifies the command to run ('npx'), arguments for installation ('-y', '@rulecatch/mcp-server'), and environment variables for API key and region. ```json { "mcpServers": { "rulecatch": { "command": "npx", "args": ["-y", "@rulecatch/mcp-server"], "env": { "RULECATCH_API_KEY": "rc_your_key", "RULECATCH_REGION": "us" } } } } ``` -------------------------------- ### Start Multi-Service Development Environment Source: https://thedecipherist.com/articles/claude-code-guide-v5 A template for starting multiple services simultaneously with assigned ports and environment variables, ensuring previous instances are terminated first. ```bash # ALWAYS kill first lsof -ti:4000,4010,4020,4030,4040 | xargs kill -9 2>/dev/null # Then start PORT=4000 pnpm --filter website dev & PORT=4010 pnpm --filter api dev & PORT=4020 pnpm --filter dashboard dev & PORT=4030 NEXT_PUBLIC_APP_MODE=admin pnpm --filter dashboard dev & PORT=4040 pnpm --filter analytics dev & ``` -------------------------------- ### Node.js Docker Build Stage Setup Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 This Dockerfile stage installs build tools like python3, make, and g++ required for compiling native Node.js modules. It then copies package.json and package-lock.json to leverage Docker's layer caching for efficient dependency installation using 'npm ci --omit=dev'. Build tools are removed before the next stage. ```dockerfile FROM node:20-bookworm-slim AS builder WORKDIR /app # Install the construction equipment. # python3, make, and g++ are needed because packages like # bcrypt and sharp contain C/C++ code that must be compiled # during npm install. These tools are ~300MB. They will NOT # be in our final image. RUN apt-get update && \ apt-get install -y --no-install-recommends \ python3 \ make \ g++ \ && apt-get clean && \ rm -rf /var/lib/apt/lists/* # Copy ONLY the package files first. # Why not copy everything? Because of layer caching. # Docker caches each layer. If nothing in this layer changed # (same package.json, same lock file), Docker reuses the cache # and skips the expensive npm install below. # If we copied ALL source code here, changing one line of # JavaScript would invalidate this cache and force a full # npm install every single time. COPY package.json package-lock.json ./ # Install ONLY production dependencies. # --omit=dev means: skip jest, eslint, nodemon, prettier, # and every other devDependency. They're for your laptop, # not for production. # npm ci (clean install) is faster and more reliable than # npm install - it deletes node_modules first and installs # exactly what's in the lock file. RUN npm ci --omit=dev # At this point, this stage has: # Yes Compiled, production-ready node_modules # No python3, make, g++ (300+ MB of build tools) # No apt cache and package lists # We want the node_modules. We don't want anything else. ``` -------------------------------- ### Install Docker Engine on Ubuntu Source: https://thedecipherist.com/articles/docker-swarm-guide Removes legacy packages, configures the official Docker repository, and installs the latest Docker Engine, CLI, and Compose plugins. ```bash for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg done sudo apt-get update sudo apt-get install ca-certificates curl gnupg sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo groupadd docker sudo usermod -aG docker $USER ``` -------------------------------- ### Combine apt-get Install Commands in Dockerfile Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 Reduces Docker image layers by consolidating multiple `apt-get install` commands into a single `RUN` instruction. This improves build cache efficiency and reduces the overall image size by performing updates, installations, and cleanup within one layer. ```dockerfile RUN apt-get update && \ apt-get install -y --no-install-recommends python3 make g++ && \ rm -rf /var/lib/apt/lists/* ``` -------------------------------- ### Multi-Stage Dockerfile for Non-Root User Production Build Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 This multi-stage Dockerfile demonstrates building a Node.js application. The first stage ('builder') runs as root to install build tools and dependencies. The second stage starts from a clean Node.js image, copies artifacts from the builder stage, sets ownership to the 'node' user, switches to the 'node' user, and exposes port 3000. The application is then run using 'node server.js'. ```dockerfile # Stage 1: Build as root (needs compiler tools) FROM node:20-bookworm-slim AS builder WORKDIR /app RUN apt-get update && apt-get install -y python3 make g++ && \ apt-get clean && rm -rf /var/lib/apt/lists/* COPY package.json package-lock.json ./ RUN npm ci --omit=dev # Stage 2: Production as non-root FROM node:20-bookworm-slim WORKDIR /app ENV NODE_ENV=production COPY --from=builder --chown=node:node /app/node_modules ./node_modules COPY --chown=node:node . . USER node EXPOSE 3000 ENTRYPOINT ["node", "server.js"] ``` -------------------------------- ### Install StrictDB and Database Drivers (Node.js) Source: https://thedecipherist.com/articles/strictDB This snippet shows how to install the core StrictDB package and common database drivers using npm. Users should install only the drivers they intend to use, as they are optional peer dependencies. ```bash npm install strictdb # Install whatever driver(s) you need npm install mongodb # MongoDB npm install pg # PostgreSQL npm install mysql2 # MySQL ``` -------------------------------- ### Install DNS Utilities for Debian/Alpine Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 Installs DNS resolution utilities required for network troubleshooting. 'dnsutils' is for Debian-based systems, and 'bind-tools' is for Alpine Linux. ```bash # Debian apt-get update && apt-get install -y dnsutils # Alpine apk add bind-tools ``` -------------------------------- ### MongoDB 8.0 Production Installation Script (Bash) Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide A bash script designed for automated installation and configuration of MongoDB 8.0 on Ubuntu 22.04/24.04. It includes sections for node configuration, data drive setup, security settings, and replica set initialization. Users must edit the CONFIGURATION section before execution. ```bash #!/bin/bash #=============================================================================== # MongoDB 8.0 Production-Ready Installation Script # # This script automates the installation and configuration of MongoDB 8.0 # following production best practices for Ubuntu 22.04/24.04. # # Usage: # 1. Edit the CONFIGURATION section below # 2. Run: sudo bash mongodb-install.sh #=============================================================================== set -e # Exit on any error #=============================================================================== # CONFIGURATION - EDIT THESE VALUES #=============================================================================== # Node Configuration NODE_HOSTNAME="mongodb1.yourdomain.com" # This node's FQDN NODE_IP="10.10.1.122" # This node's private IP REPLICA_SET_NAME="rs0" # Replica set name # Other Replica Set Members (for /etc/hosts) OTHER_NODES=( "10.10.1.175 mongodb2.yourdomain.com mongodb2" "10.10.1.136 mongodb3.yourdomain.com mongodb3" ) # Data Drive Configuration DATA_DRIVE="/dev/nvme1n1" # Set to "" to skip formatting DATA_PATH="/data/mongodb" # MongoDB Configuration MONGODB_VERSION="8.0" WIREDTIGER_CACHE_GB="2" # 50% of RAM - 1GB recommended MONGODB_PORT="27017" # Security GENERATE_KEYFILE="true" KEYFILE_PATH="/keys/mongodb.key" # Admin User (leave ADMIN_PASSWORD empty to skip) ADMIN_USER="adminUser" ADMIN_PASSWORD="" # Replica Set Init (set true only on PRIMARY, after all nodes installed) INIT_REPLICA_SET="false" NODE_PRIORITY="2" #=============================================================================== # COLOR OUTPUT #=============================================================================== RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; } log_warn() { echo -e "${YELLOW}[WARNING]${NC} $1"; } log_error() { echo -e "${RED}[ERROR]${NC} $1"; } #=============================================================================== # PRE-FLIGHT CHECKS #=============================================================================== preflight_checks() { log_info "Running pre-flight checks..." if [[ $EUID -ne 0 ]]; then log_error "This script must be run as root (use sudo)" exit 1 fi if [[ -f /etc/os-release ]]; then . /etc/os-release if [[ "$ID" != "ubuntu" ]]; then log_error "This script is designed for Ubuntu. Detected: $ID" exit 1 fi log_success "Ubuntu $VERSION_ID detected" fi if [[ -n "$DATA_DRIVE" && ! -b "$DATA_DRIVE" ]]; then log_error "Data drive $DATA_DRIVE not found!" lsblk exit 1 fi if ! ping -c 1 repo.mongodb.org &> /dev/null; then log_error "Cannot reach repo.mongodb.org" exit 1 fi log_success "Pre-flight checks passed" } #=============================================================================== # HOSTNAME CONFIGURATION #=============================================================================== configure_hostname() { log_info "Configuring hostname..." hostnamectl set-hostname "$NODE_HOSTNAME" sed -i '/mongodb[0-9]/d' /etc/hosts echo "$NODE_IP $NODE_HOSTNAME ${NODE_HOSTNAME%%.*}" >> /etc/hosts for node in "${OTHER_NODES[@]}"; do echo "$node" >> /etc/hosts done log_success "Hostname configured: $NODE_HOSTNAME" } #=============================================================================== ``` -------------------------------- ### Start and Enable MongoDB Service Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Starts the MongoDB service, enables it to start automatically on boot, and checks its current status. This ensures MongoDB is running and persistent. ```shell sudo systemctl start mongod sudo systemctl enable mongod sudo systemctl status mongod ``` -------------------------------- ### Install MongoDB Server Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Updates the package list and installs the MongoDB server package. This command ensures that the latest available version from the added repository is installed. ```shell sudo apt-get update sudo apt-get install -y mongodb-org ``` -------------------------------- ### Install Dockge Docker Compose Manager Source: https://thedecipherist.com/articles/docker-swarm-guide Installs Dockge, a lightweight Docker Compose stack manager. This involves creating directories, downloading the compose file, and starting the service using Docker Compose. ```bash mkdir -p /opt/stacks /opt/dockge cd /opt/dockge curl -O https://raw.githubusercontent.com/louislam/dockge/master/compose.yaml docker compose up -d ``` -------------------------------- ### Complete Docker Deployment Script Example Source: https://thedecipherist.com/articles/docker-swarm-guide A comprehensive bash script for building and deploying Docker services. It reads version information, exports environment variables, builds images using Docker Compose, and deploys the stack. ```bash #!/bin/bash set -e # Configuration REGISTRY="yourregistry" SERVICE="nodeserver" COMPOSE_FILE="docker-compose.yml" # Read version BUILD_VERSION=$(cat ./globals/_versioning/buildVersion.txt) LONG_COMMIT=$(git rev-parse HEAD) SHORT_COMMIT=$(git rev-parse --short HEAD) # Export for docker-compose export BUILD_VERSION export LONG_COMMIT export DOCKER_BUILD_VERSION="${BUILD_VERSION}" echo "Building version ${BUILD_VERSION} (commit: ${SHORT_COMMIT})" # Build images docker compose -f $COMPOSE_FILE build ``` -------------------------------- ### Docker Init: Generate Docker Configuration Files Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 Initializes a Dockerfile, docker-compose.yml, and .dockerignore file tailored to your project's detected language or framework. It provides a starting point for containerizing your application. Run this command in your project's root directory. ```bash docker init ``` -------------------------------- ### Update System Packages on Ubuntu Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Updates the package list and upgrades installed packages on Ubuntu systems. This is a standard maintenance step before installing new software. ```bash sudo apt-get update && sudo apt-get upgrade -y ``` -------------------------------- ### GET /db/getProfilingStatus Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Retrieves the current profiling configuration for the active database. ```APIDOC ## GET /db/getProfilingStatus ### Description Returns the current profiling status, including the active level, the slow query threshold, and the sampling rate. ### Method GET ### Response #### Success Response (200) - **was** (integer) - Current profiling level. - **slowms** (integer) - Threshold in milliseconds for slow queries. - **sampleRate** (float) - The fraction of slow operations to record. #### Response Example { "was": 1, "slowms": 100, "sampleRate": 1.0 } ``` -------------------------------- ### Initialize Multi-Stage Docker Build Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 The starting syntax for a multi-stage Docker build, which allows for separating build-time tools from the final production image. ```dockerfile # syntax=docker/dockerfile:1 # ============================================ # STAGE 1: The construction zone # This stage exists ONLY to compile dependencies. # Nothing from this stage ships in the final image # except what we explicitly copy out. ``` -------------------------------- ### Install XFS Filesystem Tools Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Installs the `xfsprogs` package, which provides utilities for managing XFS filesystems. XFS is recommended for MongoDB's WiredTiger storage engine for better performance. ```bash sudo apt-get install xfsprogs -y ``` -------------------------------- ### Correct CI/CD Deployment Pattern (Docker Image) Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 This snippet illustrates the recommended CI/CD deployment pattern using Docker. The CI environment handles building and pushing the Docker image to a registry. The deployment step then connects to the production server and instructs it to update the service with the new image. This ensures that all build and compilation steps occur in the CI environment, not on the production server. ```yaml # The RIGHT pattern build: steps: - docker build -t myapp:${VERSION} . - docker push myapp:${VERSION} deploy: steps: - ssh production-server - docker service update --image myapp:${VERSION} mystack_nodeserver ``` -------------------------------- ### Install MongoDB from Official Repositories Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Adds the official MongoDB APT repository to the system and installs the mongodb-org package. It automatically detects the Ubuntu version to select the correct repository codename. ```bash install_mongodb() { log_info "Installing MongoDB $MONGODB_VERSION..." apt-get update apt-get install -y gnupg curl curl -fsSL "https://www.mongodb.org/static/pgp/server-${MONGODB_VERSION}.asc" | \ gpg --dearmor -o /usr/share/keyrings/mongodb-server-${MONGODB_VERSION}.gpg . /etc/os-release case "$VERSION_ID" in "24.04") CODENAME="noble" ;; *) CODENAME="jammy" ;; esac echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-${MONGODB_VERSION}.gpg ] https://repo.mongodb.org/apt/ubuntu ${CODENAME}/mongodb-org/${MONGODB_VERSION} multiverse" | \ tee /etc/apt/sources.list.d/mongodb-org-${MONGODB_VERSION}.list apt-get update apt-get install -y mongodb-org log_success "MongoDB $MONGODB_VERSION installed" } ``` -------------------------------- ### Install AI-Pooler CLI Tool Source: https://thedecipherist.com/articles/rulecatch This command installs the AI-Pooler command-line interface tool. It requires an API key for initialization and sets up necessary hooks and configuration files. ```bash npx @rulecatch/ai-pooler init --api-key=YOUR_KEY ``` -------------------------------- ### GET /db/system.profile Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Queries the system.profile collection to identify slow or inefficient database operations. ```APIDOC ## GET /db/system.profile ### Description Retrieves performance data from the capped system.profile collection. ### Method GET ### Endpoint db.system.profile.find(query) ### Parameters #### Query Parameters - **ts** (date) - Optional - Filter by timestamp. - **ns** (string) - Optional - Filter by namespace (database.collection). - **millis** (integer) - Optional - Filter by execution time. ### Request Example { "millis": { "$gt": 100 } } ### Response #### Success Response (200) - **op** (string) - Operation type - **ns** (string) - Namespace - **millis** (integer) - Execution time - **planSummary** (string) - Execution plan (e.g., COLLSCAN) #### Response Example { "op": "query", "ns": "mydb.users", "millis": 2, "planSummary": "IXSCAN { email: 1 }" } ``` -------------------------------- ### Scaffold New Projects via CLI Source: https://thedecipherist.com/articles/claude-code-mastery-project-starter-kit Command-line interface for initializing new projects based on pre-configured stack profiles. It supports various technology stacks including Go, SvelteKit, and clean infrastructure templates. ```bash /new-project my-app go # Go API with standard layout /new-project my-app clean # Just the Claude infrastructure /new-project my-app sveltekit # SvelteKit full-stack app ``` -------------------------------- ### Configure Firewall Rules for MongoDB Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Examples of restricting MongoDB access to specific private network ranges using UFW and iptables. ```bash # UFW example sudo ufw default deny incoming sudo ufw allow from 10.0.0.0/8 to any port 27017 sudo ufw allow from 172.16.0.0/12 to any port 27017 sudo ufw deny 27017 sudo ufw enable # iptables example iptables -A INPUT -p tcp --dport 27017 -s 10.0.0.0/8 -j ACCEPT iptables -A INPUT -p tcp --dport 27017 -j DROP ``` -------------------------------- ### Application Logging Best Practices (Node.js) Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 Illustrates recommended practices for logging within a Node.js application. It shows how to correctly log to stdout/stderr using `console.log` and `console.error`, and how to use a structured logging library like Pino. It also contrasts this with the incorrect practice of writing logs to files within the container, which Docker's drivers do not capture. ```javascript // GOOD - Docker captures this console.log('Server started on port 3000'); console.error('Database connection failed:', err.message); // GOOD - structured logging to stdout const pino = require('pino'); const logger = pino({ level: process.env.LOG_LEVEL || 'info' }); logger.info({ port: 3000 }, 'Server started'); logger.error({ err }, 'Database connection failed'); // BAD - Docker never sees this, lost when container dies const fs = require('fs'); fs.appendFileSync('/app/logs/app.log', 'Server started\n'); ``` -------------------------------- ### Install and Run MongoDB Exporter Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Steps to download, extract, and run the MongoDB Exporter for Prometheus, including specifying the MongoDB connection URI. ```bash # Install mongodb_exporter wget https://github.com/percona/mongodb_exporter/releases/download/v0.40.0/mongodb_exporter-0.40.0.linux-amd64.tar.gz tar xvzf mongodb_exporter-0.40.0.linux-amd64.tar.gz # Run exporter ./mongodb_exporter --mongodb.uri="mongodb://monitor:password@localhost:27017/admin" ``` -------------------------------- ### Implementing Semantic Versioning for Docker Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 Shows how to tag Docker images with semantic version numbers and how to automate this process by reading version strings from a file. ```bash docker build -t myapp:1.4.72 . docker push myapp:1.4.72 ``` ```bash # buildVersion.txt 1.4.72 # Build script BUILD_VERSION=$(cat ./globals/_versioning/buildVersion.txt) docker build -t myapp:${BUILD_VERSION} . docker push myapp:${BUILD_VERSION} ``` -------------------------------- ### Prometheus Alerting Rules for MongoDB Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Example Prometheus alerting rules to monitor MongoDB replication lag, high connection usage, and instance availability. ```yaml # Prometheus alerting rules groups: - name: mongodb rules: - alert: MongoDBReplicationLag expr: mongodb_rs_members_optimeDate{state="SECONDARY"} - mongodb_rs_members_optimeDate{state="PRIMARY"} > 60 for: 5m labels: severity: critical annotations: summary: "MongoDB replication lag > 60 seconds" - alert: MongoDBConnectionsHigh expr: mongodb_ss_connections{conn_type="current"} / mongodb_ss_connections{conn_type="available"} > 0.8 for: 5m labels: severity: warning annotations: summary: "MongoDB connections > 80% of max" - alert: MongoDBDown expr: up{job="mongodb"} == 0 for: 1m labels: severity: critical annotations: summary: "MongoDB instance is down" ``` -------------------------------- ### MongoDB Networking in Docker (Docker Compose) Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Illustrates different Docker networking strategies for MongoDB. The 'BAD' example uses the default bridge network, which prevents container-to-container resolution. The 'GOOD' examples show custom bridge and overlay networks, essential for replica set communication and client access. ```yaml # ❌ BAD: Default bridge network (containers can't resolve each other) networks: - default ``` ```yaml # ✅ GOOD: Custom bridge network (development) networks: mongo-cluster: driver: bridge ``` ```yaml # ✅ GOOD: Overlay network (Swarm production) networks: mongo-net: driver: overlay attachable: true ``` -------------------------------- ### Configure MongoDB Profiling Levels Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Demonstrates how to safely enable and disable database profiling. It includes examples of using thresholds and sampling to minimize production overhead. ```javascript // ❌ DANGEROUS: Low threshold, no sampling db.setProfilingLevel(1, { slowms: 10 }); // ❌ NEVER IN PRODUCTION db.setProfilingLevel(2); // ✅ SAFER: High threshold db.setProfilingLevel(1, { slowms: 100 }); // ✅ SAFEST: High threshold + sampling (MongoDB 4.0+) db.setProfilingLevel(1, { slowms: 50, sampleRate: 0.1 }); // ✅ BEST: Profile briefly, then disable db.setProfilingLevel(1, { slowms: 100 }); // ... collect data for 5-10 minutes ... db.setProfilingLevel(0); ``` -------------------------------- ### Local Development Workflow Comparison Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 Comparison of local development commands between Docker Swarm and Kubernetes environments. ```bash # Your entire local dev workflow docker compose up -d # Edit code, see changes via bind mounts # Done ``` -------------------------------- ### Clone and Initialize Claude Code Starter Kit Source: https://thedecipherist.com/articles/best_claude_code_guide_2026 This snippet provides the commands to clone the official Claude Code mastery project starter kit from GitHub and initialize the environment using the /setup slash command. ```bash git clone https://github.com/TheDecipherist/claude-code-mastery-project-starter-kit.git cd claude-code-mastery-project-starter-kit # Open Claude Code and run /setup ``` -------------------------------- ### MongoDB Authentication with Docker Secrets (Docker Compose) Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Demonstrates secure password and keyfile management for MongoDB using Docker secrets. The 'BAD' example stores the password in plain text within the environment variables. The 'GOOD' example utilizes Docker secrets for sensitive information, enhancing security in Swarm environments. ```yaml # ❌ BAD: Password in plain text in compose file environment: - MONGO_INITDB_ROOT_PASSWORD=mysecretpassword ``` ```yaml # ✅ GOOD: Use Docker secrets (Swarm) secrets: - mongodb-keyfile - mongodb-root-password ``` -------------------------------- ### Configure Hostnames on Ubuntu Servers Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Sets the hostname for each MongoDB node using the `hostnamectl` command. This is crucial for replica set member identification starting from MongoDB 5.0. ```bash # On mongodb1 sudo hostnamectl set-hostname mongodb1.yourdomain.com # On mongodb2 sudo hostnamectl set-hostname mongodb2.yourdomain.com # On mongodb3 sudo hostnamectl set-hostname mongodb3.yourdomain.com ``` -------------------------------- ### Image-Based Workflow Visualization Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 This diagram illustrates the recommended image-based workflow. It shows the flow of code from a developer's machine, through building and testing a Docker image, to pushing it to a registry, and finally deploying it to a production environment. The key takeaway is that the production environment only interacts with immutable Docker images. ```text Developer machine Registry Production | | | |- Write code | | |- docker compose up (test locally)| | |- docker compose build | | |- Run tests against the image | | |- docker compose push ----------> | Image stored | | | (myapp:1.4.72) | | | | |- docker stack deploy ---------------------------------------> | | (or CI/CD triggers deploy) | | | | <---- docker pull ---------| | | (pulls myapp:1.4.72) | | | |- Container starts | | |- Health check passes | | |- Old container stops | | | | | | (It's running the | | | exact same image | | | you tested locally) ``` -------------------------------- ### Basic Docker Container and Image Management Commands Source: https://thedecipherist.com/articles/the_docker_developer_workflow_guide_2026 A quick reference for essential Docker commands related to container lifecycle management, logging, inspection, and execution. Includes commands for listing, stopping, removing, and interacting with containers and images. ```bash docker ps docker ps -a docker logs docker logs --tail 100 -f docker logs -t docker inspect docker exec -it /bin/sh docker run --rm -it --entrypoint /bin/sh docker stop docker kill docker rm docker rm -f ``` -------------------------------- ### MongoDB Configuration Variables Source: https://thedecipherist.com/articles/the-mongo-replicaset-guide Configuration settings for the automated installation script, including node identification, replica set naming, and resource allocation for the WiredTiger storage engine. ```bash # Node Configuration NODE_HOSTNAME="mongodb1.yourdomain.com" NODE_IP="10.10.1.122" REPLICA_SET_NAME="rs0" # Other Replica Set Members OTHER_NODES=( "10.10.1.175 mongodb2.yourdomain.com mongodb2" "10.10.1.136 mongodb3.yourdomain.com mongodb3" ) # Data Drive DATA_DRIVE="/dev/nvme1n1" DATA_PATH="/data/mongodb" # MongoDB Settings WIREDTIGER_CACHE_GB="2" INIT_REPLICA_SET="false" ADMIN_PASSWORD="" ``` -------------------------------- ### Install Node.js, Yarn, and Python Tools in Dockerfile Source: https://thedecipherist.com/articles/docker-swarm-guide This Dockerfile instruction installs Node.js (version 20.x), essential Python tools like pip and pipenv, and Chromium. It configures the NodeSource repository and cleans up apt cache afterwards to minimize image size. ```dockerfile # Install Node.js, Yarn, and Python tools RUN \ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \ wget -qO- https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ apt-get update && \ apt-get install -y --no-install-recommends \ chromium \ nodejs && \ pip install -U pip && pip install pipenv && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* ```