Nija

Docker Deployment Guide for Railway/Render

Last Updated: January 19, 2026

This guide explains how to properly deploy the NIJA trading bot on Railway and Render using Docker.


✅ Correct Approach for Railway/Render

When deploying to Railway or Render, follow these best practices:

1. Use a Single Dockerfile

Your repository should contain one Dockerfile that the platform will build automatically.

Current Dockerfile (simplified for platform compatibility):

FROM python:3.11-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD ["bash", "start.sh"]

2. Let the Platform Build It

Railway Configuration (railway.json):

{
  "build": {
    "builder": "DOCKERFILE"
  }
}

Render Configuration (render.yaml):

services:
  - type: web
    env: docker
    dockerfilePath: ./Dockerfile

3. No Docker Commands Inside Your App


❌ What NOT to Do

1. Don’t Use docker-compose.yml

Docker Compose is designed for local multi-container development, not for cloud platform deployments.

Why it’s removed:

2. Don’t Build Docker Images in Your Code

Your application code should never execute Docker commands:

# ❌ BAD - Don't do this
import subprocess
subprocess.run(["docker", "build", "-t", "myapp", "."])

3. Don’t Access Docker Socket

Cloud platforms don’t expose the Docker socket to containers:

# ❌ BAD - Won't work on Railway/Render
import docker
client = docker.from_env()  # This will fail

🚀 Deployment Methods

Railway

  1. Connect your GitHub repository to Railway
  2. Railway automatically detects the Dockerfile
  3. Configure environment variables in the dashboard
  4. Deploy - Railway builds and runs your container

Configuration File: railway.json

Render

  1. Create a new Web Service and connect to GitHub
  2. Select “Docker” as the environment
  3. Set dockerfile path to ./Dockerfile
  4. Configure environment variables in the dashboard
  5. Deploy - Render builds and runs your container

Configuration File: render.yaml


🏠 Local Development

For local development, you have two options:

# Install dependencies
pip install -r requirements.txt

# Set environment variables
cp .env.example .env
# Edit .env with your credentials

# Run the bot
./start.sh

Option 2: Run with Docker

# Build the image (BuildKit is enabled by default for better performance)
docker build -t nija-bot .

# Run the container
docker run -d \
  --name nija \
  --env-file .env \
  -p 5000:5000 \
  nija-bot

# View logs
docker logs -f nija

# Stop the container
docker stop nija
docker rm nija

Note: For local Docker development, you can build and run directly. However:


🔧 Environment Variables

All configuration is done via environment variables, not config files in the container.

Setting Environment Variables:

Platform Method
Railway Dashboard → Variables → Add Variable
Render Dashboard → Environment → Add Environment Variable
Local Create .env file in repository root
Docker CLI Use --env-file .env or -e KEY=value flags

Required Variables:

See .env.example for a complete list.


📋 Dockerfile Best Practices

Current Simplified Dockerfile

The Dockerfile has been simplified to follow cloud platform best practices:

Before (Complex):

After (Simple):

Why This Matters

  1. Faster Builds: Fewer layers = faster builds on Railway/Render
  2. Better Caching: requirements.txt is copied first, enabling layer caching
  3. Easier to Maintain: Simple Dockerfile is easier to understand and update
  4. Platform Compatible: Follows Railway and Render best practices

🔍 Troubleshooting

Build Fails on Railway/Render

Symptom: Deployment fails during build phase

Solutions:

  1. Check that railway.json has "builder": "DOCKERFILE"
  2. Check that render.yaml has env: docker
  3. Verify all dependencies are in requirements.txt
  4. Check build logs for specific error messages

Container Starts But Crashes

Symptom: Build succeeds but container exits immediately

Solutions:

  1. Check application logs for Python errors
  2. Verify environment variables are set correctly
  3. Verify start.sh has executable permissions
  4. Check that required files exist in the container

Dependencies Missing

Symptom: Import errors or “module not found”

Solutions:

  1. Verify package is listed in requirements.txt
  2. Check package name spelling and version
  3. Clear build cache and redeploy
  4. Check that package is compatible with Python 3.11

📚 Additional Resources


🎯 Quick Reference

✅ DO:

❌ DON’T:


Questions? Check the troubleshooting section or review platform-specific documentation.