Skip to main content

tly deploy

Overview

The tly deploy command bundles your local project and deploys it to your Targetly instance. Targetly will build a Docker image and start your MCP server.

Usage

tly deploy [options]

How It Works

  1. Bundle - Zips your current directory (excluding .git, node_modules, etc.)
  2. Upload - Sends the bundle to your Targetly API
  3. Build - Targetly builds a Docker image from your Dockerfile
  4. Deploy - Starts a container and assigns a subdomain
  5. Output - Returns deployment details (ID, URL, status)

Requirements

Dockerfile Required

Your project must include a Dockerfile in the root directory. Targetly uses this to build your container image.

Example Dockerfile for a Python MCP server:

FROM python:3.11-slim

WORKDIR /app
COPY . .

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

CMD ["python", "server.py"]

Project Structure

Typical MCP server project structure:

my-mcp-tool/
├── Dockerfile # Required
├── server.py # Your MCP server code
├── requirements.txt # Dependencies
└── README.md

Options

Currently, tly deploy does not require options - it automatically detects your project and deploys it.

Examples

Basic Deployment

cd my-mcp-tool
tly deploy

Output:

📦 Bundling project...
✓ Created bundle (2.4 MB)

🚀 Deploying to Targetly...
✓ Upload complete

🔨 Building Docker image...
✓ Build successful

🎉 Deployment complete!
━━━━━━━━━━━━━━━━━━━━━━━━
📋 ID: abc123def456
🌐 URL: https://my-tool.prod.targetly.io
📊 Status: Running
━━━━━━━━━━━━━━━━━━━━━━━━

Check What Will Be Deployed

Before deploying, you can check which files will be included:

# Preview bundle contents
ls -la

# Ensure .gitignore excludes unwanted files
cat .gitignore

Excluded Files

The following are automatically excluded from the bundle:

  • .git/ - Git repository data
  • node_modules/ - Node.js dependencies (reinstalled during build)
  • __pycache__/, *.pyc - Python cache files
  • .env - Environment files (use Targetly dashboard for secrets)
  • *.log - Log files
  • .DS_Store - macOS system files
warning

Do not include secret files in your bundle. Use environment variables configured in the Targetly dashboard instead.

Deployment URL

Your deployment will be accessible at:

https://<deployment-id>.prod.targetly.io

Example:

https://abc123def456.prod.targetly.io

After Deployment

Once deployed, you can:

View Logs

tly logs abc123def456

Check Status

tly list

Stop Deployment

tly stop abc123def456

Troubleshooting

Dockerfile not found

Error: Error: Dockerfile not found in project root

Solution: Create a Dockerfile in your project's root directory.

Build failed

Error: Build failed: [error details]

Solutions:

  • Check your Dockerfile syntax
  • Verify all dependencies are specified correctly
  • Review build logs with tly logs <deployment-id>

Bundle too large

Error: Bundle size exceeds 100MB

Solutions:

  • Add large files to .gitignore
  • Minimize unnecessary assets
  • Remove node_modules/ and similar directories

Deployment timeout

Error: Deployment timed out

Solutions:

  • Check if image build is taking too long
  • Optimize your Dockerfile (use caching, multi-stage builds)
  • Contact support if issue persists

Best Practices

  • Optimize Dockerfile Use multi-stage builds and layer caching to speed up builds

  • Minimize Bundle Size Keep your bundle under 50MB when possible for faster uploads

  • Test Locally Build and test your Docker image locally before deploying

  • Use .dockerignore Create a .dockerignore file to exclude unnecessary files

  • tly list View all deployments

  • tly logs View deployment logs

  • tly stop Stop a deployment