Slack API Docker Project with Makefile Automation
Jun 09, 2025, 12:00 AM

⚡ Streamlining Slack Bot Development: Docker & Makefile Automation for Slack Command APIs

Building a Slack API service or custom Slash Command handler is exciting, but managing environment variables, local webhook tunnels, container builds, and deployment workflows can quickly get messy.

In this post, we'll explore Slack Command API, a production-ready, containerized Slack API starter with Makefile automation for effortless building, local testing, and multi-platform deployment.


🔗 Quick Links


🌟 Why Containerize & Automate Your Slack Bot?

When developing webhooks for Slack, you often face common bottlenecks:

  1. Environment Drift: Works on your local machine, breaks in production.
  2. Repetitive Commands: Typing docker build -t ..., docker run -p ..., and docker push ... repeatedly.
  3. Webhook Tunneling: Safely exposing local ports via ngrok for Slack interactivity.
  4. Secret Management: Guarding bot tokens and signing secrets across environments.

This setup solves these challenges using Docker for consistency, GNU Make for one-word CLI shortcuts, and ngrok for fast local development.


✨ Key Features

  • 🐳 Containerized Environment: Consistent runtime across development, staging, and production.
  • 🛠️ Makefile Automation: Single-word commands like make build, make run, make deploy, and make logs.
  • 🔒 Secure Configuration: Centralized .env handling with token safety practices.
  • 🌐 Local Webhook Testing: Built-in support for ngrok tunneling.
  • 🚀 Docker Hub & Kubernetes Ready: Streamlined image publishing and optional K8s deployment manifests.

🚀 Quick Start Guide

1. Clone the Repository

git clone https://github.com/SarinHem/slack-command-api.git
cd slack-command-api

2. Configure Environment Variables

Copy the example configuration file and fill in your Slack and Docker details:

cp .env.example .env

Example .env structure:

# Docker & App Configuration
IMAGE_NAME=your-dockerhub-username/slack-api
TAG=latest
CONTAINER_NAME=slack-api-container
PORT=8181

# Slack Credentials
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_SIGNING_SECRET=your-signing-secret
SLACK_APP_TOKEN=xapp-your-app-token

# Environment
NODE_ENV=development
LOG_LEVEL=info

Restrict permissions on your secrets:

chmod 600 .env

🔨 Powerful Makefile Shortcuts

Forget complex CLI flags! Here are the core Makefile commands that make development a breeze:

Local Development

CommandAction
make buildBuilds the Docker image locally
make runRuns the container in detached mode
make logsStreams real-time container logs
make shellOpens an interactive shell inside the container
make stopStops the running container
make healthChecks app health endpoint

Deployment & Cleanup

CommandAction
make pushPushes built image to Docker Hub
make deployAutomates build, push, and remote update
make cleanRemoves local Docker images
make check-envValidates required .env variables

💻 Local Testing with Slack Webhooks

Since Slack requires a public HTTPS endpoint for Slash Commands and Interactivity:

  1. Start the local container:

    make build && make run
    
  2. Expose port 8181 via ngrok:

    ngrok http 8181
    
  3. Copy the generated https://xxxx.ngrok-free.app URL into your Slack App Settings under Request URL.


🚢 Deployment Options

Option 1: Docker Hub Deployment

# Login to registry
docker login

# Build & push with one command
make deploy

Option 2: Kubernetes Deployment

The repository includes ready-to-use Kubernetes manifests with replica scaling and LoadBalancer services:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: slack-api
spec:
  replicas: 2
  template:
    spec:
      containers:
      - name: slack-api
        image: your-username/slack-api:latest
        ports:
        - containerPort: 8181

🔒 Security Best Practices

  • Always ignore .env files: Keep tokens out of Git repositories.
  • Token Rotation: Periodically rotate your xoxb- bot tokens and signing secrets.
  • Non-Root Execution: Containers are configured to run with unprivileged user permissions.

💡 Conclusion

By standardizing your Slack bot workflow with Docker and Makefile shortcuts, you eliminate friction and focus strictly on building awesome Slack features.

Check out the repository, clone it for your next Slack app project, and enjoy streamlined bot development! 🤖