A lightweight continuous deployment tool using pure TCP for real-time communication. Deploy applications from Git repositories to Docker containers with live log streaming.
- Pure TCP Protocol - Fast, persistent connections for real-time updates
- Real-time Logging - Stream deployment logs as they happen
- Docker Integration - Automatic container building and deployment
- Environment Variables - Inject configuration and secrets into containers
- Interactive CLI - User-friendly interface with colored output and progress bars
- API Authentication - Secure server access with API keys
- SSH Key Support - Server-side SSH key configuration for private repositories
curl -L -o cd-cli https://github.com/RestartFU/cd/releases/latest/download/cd-cli-linux-amd64
chmod +x cd-cligit clone https://github.com/RestartFU/cd.git
cd cd
make buildBinaries will be in bin/:
bin/cd-server- Server componentbin/cd-cli- CLI client
Create config.toml:
listen_addr = ':8080'
api_key = 'your-secret-api-key'
ssh_key_path = '' # Optional: path to SSH private key for git cloning./bin/cd-serverThe server will:
- Listen on the configured port (default: 8080)
- Accept authenticated TCP connections
- Clone repositories and build Docker containers
Interactive Mode:
./bin/cd-cliDirect Deployment:
./bin/cd-cli \
-server=localhost:8080 \
-key=your-secret-api-key \
-git=git@github.com:user/repo.gitWith Environment Variables:
./bin/cd-cli \
-server=localhost:8080 \
-key=your-secret-api-key \
-git=git@github.com:user/repo.git \
-env=production \
-env-vars="API_KEY=value,DEBUG=false" \
-secrets-file=.secrets-server string Server address (default "localhost:8080")
-key string API key for authentication
-git string Git repository URL
-env string Environment name (default "production")
-env-file string Path to environment variables file (.env format)
-env-vars string Comma-separated environment variables (KEY=VALUE)
-secrets-file string Path to secrets file (.env format)
-secrets string Comma-separated secrets (KEY=VALUE)
-diagnose Run Docker diagnostics
-help Show help message
SSH keys are configured on the server side in config/config.toml:
ssh_key_path = '/home/user/.ssh/id_ed25519'Fallback behavior:
- If
ssh_key_pathis set, the server uses that key - If empty or not set, defaults to
/home/restart/.ssh/id_ed25519
This allows the server to clone private repositories without exposing SSH keys to clients.
Create .env file:
NODE_ENV=production
PORT=3000
API_URL=https://api.example.com
Deploy:
./bin/cd-cli -env-file=.env -git=git@github.com:user/repo.git./bin/cd-cli -env-vars="PORT=3000,DEBUG=true" -git=git@github.com:user/repo.gitSeparate secrets from environment variables:
./bin/cd-cli \
-env-file=.env.production \
-secrets-file=.secrets \
-git=git@github.com:user/repo.gitSecrets override environment variables with the same name and are masked in logs.
Your repository must contain a Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]The server will:
- Clone the repository
- Build the Docker image
- Start a container with environment variables injected
The client and server communicate using JSON messages over TCP:
Authentication:
{"type":"auth","timestamp":"2024-01-01T00:00:00Z","data":{"api_key":"secret"}}Deploy Request:
{
"type":"deploy",
"timestamp":"2024-01-01T00:00:00Z",
"data":{
"git_url":"git@github.com:user/repo.git",
"environment":"production",
"env_vars":{"PORT":"3000"},
"secrets":{"DB_PASSWORD":"secret"},
"ssh_key_path":"/path/to/key"
}
}Server Responses:
{"type":"log","data":{"level":"info","message":"Cloning repository","source":"git"}}
{"type":"status","data":{"stage":"building","progress":50,"message":"Building image"}}
{"type":"result","data":{"success":true,"message":"SUCCESS","duration":"45s"}}
{"type":"error","data":{"code":"DEPLOY_FAILED","message":"Build failed"}}┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ CLI Client │◄───TCP──►│ CD Server │────────►│ Docker │
│ │ │ │ │ Daemon │
│ • Auth │ │ • Git clone │ │ │
│ • Deploy │ │ • Build │ │ • Build │
│ • Stream │ │ • Deploy │ │ • Run │
└─────────────┘ └─────────────┘ └─────────────┘
# Build both components
make build
# Build separately
go build -o bin/cd-server ./cmd/server
go build -o bin/cd-cli ./cmd/cli
# Format code
make fmt
# Run tests
make test
# Clean build artifacts
make cleanRun the CD server in Docker:
docker run -d \
--name cd-server \
-p 8080:8080 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd)/config:/app/config \
-v ~/.ssh:/root/.ssh:ro \
cd-server:latestRun diagnostics:
./bin/cd-cli -diagnoseVerify key permissions:
chmod 600 ~/.ssh/id_ed25519
ssh-add ~/.ssh/id_ed25519Test Git access:
ssh -T git@github.comCheck server is running:
netstat -tuln | grep 8080Test connection:
telnet localhost 8080MIT License - see LICENSE file for details.