Write Workflow
This workflow uploads new strategy versions to the platform. You'll learn how to create a strategy, prepare your Docker image, and push it as a new version.
Overview
The write workflow follows these steps:
- Create a strategy - Set up a named container for your trading logic
- Prepare your Dockerfile - Ensure your strategy builds for the target platform
- Upload a version - Build and push your Docker image to the platform
Prerequisites
Before starting, ensure you have:
- The Tektii CLI installed (Installation)
- Your API key configured (Authentication)
- Docker installed and running
- A Dockerfile for your strategy
Step 1: Create a Strategy
If you don't have a strategy yet, create one:
tektii strategy create --name "my-strategy"
This displays the newly created strategy:
✓ Strategy created successfully ┌──────────────────────────────────────┬──────────────┬─────────────────────┐ │ ID │ Name │ Created │ ├──────────────────────────────────────┼──────────────┼─────────────────────┤ │ strat_abc123... │ my-strategy │ 2024-01-15 10:30 │ └──────────────────────────────────────┴──────────────┴─────────────────────┘
Note the strategy ID (strat_abc123...) - you'll need it for the next step.
If You Already Have a Strategy
List your existing strategies to find the ID:
tektii strategy list
Step 2: Prepare Your Dockerfile
Your strategy needs a Dockerfile that builds for the linux/amd64 platform. This is required because the Tektii engine runs on Cloud Run.
Example Dockerfile
FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt COPY . . CMD ["python", "main.py"]
Platform Requirements
Your Docker image must target linux/amd64. Images built for other platforms (like darwin/arm64 on Apple Silicon) will not work.
Step 3: Upload a Version
Navigate to your strategy repository and run:
cd /path/to/my-strategy tektii version upload strat_abc123
The CLI will:
- Validate that your Dockerfile exists
- Auto-detect your Git SHA (or generate a timestamp fallback)
- Create a version entry in the API
- Build the Docker image for
linux/amd64 - Push the image to the registry
Custom Paths
If your Dockerfile isn't in the default location, specify custom paths:
tektii version upload strat_abc123 \ --dockerfile ./docker/Dockerfile.prod \ --context ./src
Flags
| Flag | Default | Description |
|---|---|---|
--dockerfile <PATH> | ./Dockerfile | Path to your Dockerfile |
--context <PATH> | . | Docker build context directory |
--git-sha <SHA> | Auto-detected | Git commit SHA for this version |
Git SHA Detection
The CLI automatically detects your current Git commit SHA. If you're not in a Git repository, it generates a timestamp-based identifier like ts-1234567890.
To specify a SHA manually:
tektii version upload strat_abc123 --git-sha abc1234def
Apple Silicon (M1/M2/M3) Users
If you're on an Apple Silicon Mac, Docker builds natively target darwin/arm64, which is incompatible with Cloud Run. You have two options:
Option 1: Enable Rosetta in Docker Desktop (Recommended)
- Open Docker Desktop
- Go to Settings > General
- Enable "Use Rosetta for x86/amd64 emulation"
- Restart Docker Desktop
Option 2: Use Docker Buildx
Create a buildx builder that can cross-compile:
# Create and use a buildx builder docker buildx create --use # Build with explicit platform docker buildx build --platform linux/amd64 -t my-image .
Complete Example
Here's the full workflow from start to finish:
# Step 1: Create a strategy (if you don't have one) tektii strategy create --name "momentum-v1" # Note: Save the strategy ID from the output # Step 2: Navigate to your strategy code cd /path/to/momentum-strategy # Step 3: Verify Dockerfile exists ls Dockerfile # Step 4: Upload the version tektii version upload strat_abc123 # The CLI will build and push your Docker image # On success, you'll see the new version ID
Example Output
✓ Version created: ver_xyz789 Building Docker image for linux/amd64... Pushing to registry... ✓ Version uploaded successfully ┌──────────────────────────────────────┬─────────────┬─────────────────────┐ │ ID │ Git SHA │ Created │ ├──────────────────────────────────────┼─────────────┼─────────────────────┤ │ ver_xyz789... │ abc1234 │ 2024-01-15 11:00 │ └──────────────────────────────────────┴─────────────┴─────────────────────┘
Verify Your Upload
List versions for your strategy to confirm the upload:
tektii version list strat_abc123
Get details for a specific version:
tektii version get strat_abc123 ver_xyz789
Common Issues
Docker Not Running
Error: Docker not running
Solution: Start Docker Desktop or the Docker daemon.
Platform Mismatch
Error: Image platform mismatch (expected linux/amd64, got darwin/arm64)
Solution: See the Apple Silicon section above.
Git SHA Not Detected
Warning: Failed to detect git SHA, using timestamp fallback
This is not an error. If you're not in a Git repository, the CLI uses a timestamp-based identifier. To specify a SHA manually, use --git-sha.
Dockerfile Not Found
Error: Dockerfile not found at ./Dockerfile
Solution: Use --dockerfile to specify the correct path:
tektii version upload strat_abc123 --dockerfile ./docker/Dockerfile
Next Steps
- Read Workflow - Download backtest results
- Troubleshooting - More common errors and fixes