6 min read

How We Made Blogteq CLI Docker Image 2025

Blogteq Logo

Tech Insights & Digital Productivity

How We Made Blogteq CLI Docker Image

We recently containerized the Blogteq CLI tool and published it to Docker Hub, making it easier for users to run without installing dependencies locally. This post walks through how we did it and why Dockerizing CLI tools is worth the effort.

🎯 Why Containerize a CLI Tool?

When we first built Blogteq CLI, users had to:

  • Install Node.js and npm
  • Install project dependencies
  • Configure environment variables
  • Deal with version conflicts

By containerizing it, we eliminated all these friction points. Now users can run:

docker run skisord/blogteq-cli

That's it. No setup, no dependencies, no version conflicts.

🐳 Step 1: Creating the Dockerfile

The first step was creating a Dockerfile that packages our CLI tool:

# Use Node.js LTS as base image
FROM node:18-alpine

# Set working directory
WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm ci --only=production

# Copy application code
COPY . .

# Make CLI executable
RUN chmod +x bin/blogteq-cli

# Set entrypoint
ENTRYPOINT ["node", "bin/blogteq-cli"]

Key decisions:

  • Alpine Linux: Smaller image size (~50MB vs ~200MB)
  • Production-only: Only installs runtime dependencies
  • Non-root user: Better security (we added this later)

📦 Step 2: Building the Image Locally

Before publishing, we tested locally:

# Build the image
docker build -t blogteq-cli:latest .

# Test it works
docker run blogteq-cli:latest --help

Pro tip: Use .dockerignore to exclude unnecessary files:

node_modules
.git
*.md
.env

This reduces build time and image size.

🚀 Step 3: Publishing to Docker Hub

3.1 Create Docker Hub Account

If you don't have one, sign up at hub.docker.com.

3.2 Login to Docker Hub

docker login

Enter your Docker Hub username and password.

3.3 Tag the Image

Tag your image with your Docker Hub username:

docker tag blogteq-cli:latest skisord/blogteq-cli:latest

Tagging strategy:

  • latest: Always points to the most recent stable version
  • v1.0.0: Specific version tags for reproducibility
  • v1.0: Minor version tags

3.4 Push to Docker Hub

docker push skisord/blogteq-cli:latest

That's it! Your image is now publicly available at hub.docker.com/r/skisord/blogteq-cli.

🔧 Step 4: Optimizing the Image

Multi-stage Builds

For production, we switched to multi-stage builds:

# Build stage
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Production stage
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./
ENTRYPOINT ["node", "dist/index.js"]

This reduces final image size by excluding build tools.

Security Improvements

We also added:

# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
    adduser -S nodejs -u 1001

USER nodejs

📊 Results

MetricBeforeAfter
Setup time5-10 minutes10 seconds
Image sizeN/A~80MB
Dependency conflictsCommonNone
Cross-platformIssuesWorks everywhere

🎓 Key Lessons Learned

  1. Start simple: Get it working first, optimize later
  2. Test thoroughly: Test on different systems before publishing
  3. Version tags matter: Use semantic versioning for reproducibility
  4. Documentation is crucial: Add a README on Docker Hub explaining usage
  5. Monitor image size: Smaller images pull faster and use less storage

🔗 Using the Blogteq CLI Docker Image

Now anyone can use our CLI tool with:

# Basic usage
docker run skisord/blogteq-cli

# With environment variables
docker run -e API_KEY=your-key skisord/blogteq-cli

# Mount volumes for file access
docker run -v $(pwd):/data skisord/blogteq-cli process /data/file.txt

🚀 Next Steps

We're planning to:

  • Add automated builds via GitHub Actions
  • Set up version tags for each release
  • Add health checks to the Dockerfile
  • Create a Docker Compose file for complex workflows

💡 Conclusion

Containerizing Blogteq CLI was one of the best decisions we made. It eliminated support requests about installation issues and made the tool accessible to users who don't want to manage Node.js environments.

If you're building a CLI tool, consider Dockerizing it early. The initial setup is minimal, and the benefits compound over time.

🔗 Try It Yourself

Check out the Blogteq CLI Docker image on Docker Hub and let us know what you think!

📧 Contact

For questions or custom Docker setups: Contact HVTEQ