This guide explains how to compile and deploy the MagicTradeBot Bot Instance using two supported methods: Docker for containerized environments and Systemd for traditional Linux-based service management.
🛠️ 1. Compiling the Bot Instance (Golang)
MagicTradeBot’s bot core is written in Go and can be compiled for different environments.
🔧 Compile for Local (Systemd)
go build -o magictradebot main.go
This will produce an executable magictradebot
in the current directory.
🐳 Compile and Build for Docker
Create a Dockerfile
in your project root:
# Dockerfile
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o magictradebot main.go
# Final image
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/magictradebot .
COPY config.yaml .
CMD ["./magictradebot"]
Then build the image:
docker build -t magictradebot-bot-instance .
🐳 2. Deploying Bot Instance via Docker
Step 1: Prepare Configuration
Make sure your config.yaml
file is in the same directory or mounted during runtime.
Step 2: Run Container
docker run -d \
--name=bot-bybit-01 \
-v $(pwd)/config.yaml:/app/config.yaml \
--restart=always \
magictradebot-bot-instance
Use docker logs -f bot-bybit-01
to view real-time logs.
Optional: Docker Compose
version: '3.9'
services:
tradingbot:
image: magictradebot-bot-instance
container_name: bot-bybit-01
restart: always
volumes:
- ./config.yaml:/app/config.yaml
🧩 3. Deploying Bot Instance via Systemd
Step 1: Move Executable
sudo mv magictradebot /usr/local/bin/
sudo chmod +x /usr/local/bin/magictradebot
Step 2: Create Systemd Unit File
sudo nano /etc/systemd/system/magictradebot.service
[Unit]
Description=MagicTradeBot Instance
After=network.target
[Service]
ExecStart=/usr/local/bin/magictradebot
WorkingDirectory=/opt/magictradebot
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
User=ubuntu
[Install]
WantedBy=multi-user.target
Step 3: Enable & Start the Service
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable magictradebot
sudo systemctl start magictradebot
Check Logs
journalctl -u magictradebot -f
✅ Recommendations
- 📁 Keep separate
config.yaml
per bot instance for scaling - 🔐 Use HTTPS for API and secure secret management via environment variables
- 📦 Prefer Docker for isolation and portability
- 🛡️ Monitor bot activity via integrated logging tools (LogDNA, Grafana Loki, etc.)