A lightweight Go service that acts as a secure deployment gateway for HashiCorp Nomad clusters. This service provides a simple REST API for triggering and monitoring service deployments through Nomad.
- Secure Authentication: API key-based authentication for deployment requests
- Deployment Tracking: SQLite database for tracking deployment status and history
- Health Monitoring: Built-in health check endpoint
- Service Validation: Optional whitelist of allowed services for enhanced security
- Monitoring Integration: Optional New Relic integration
- Docker Ready: Full containerization support with Docker Compose
- Hot Reload Development: Development environment with hot reload capabilities
GET /healthReturns the service health status.
POST /deploy
Content-Type: application/json
X-Secret-Key: your-64-character-secret-key
{
"service_name": "my-service",
"tag_id": "sha-id"
}Triggers a deployment for the specified service.
POST /deploy/job
Content-Type: multipart/form-data
X-Secret-Key: your-64-character-secret-key
Form data:
- tag_id: sha-id-123
- job_file: (Nomad job file upload, max 1MB)Uploads and deploys a custom Nomad job file.
GET /status/{tag_id}
X-Secret-Key: your-64-character-secret-keyReturns the status of a specific deployment by its tag ID.
Comprehensive documentation and examples are available in the docs/ directory:
- Nomad Deployment Guide - How to deploy Shipper itself in Nomad clusters
- API Usage Examples - Practical API usage examples and integration patterns
- Example Job Files - Sample Nomad job files for various application types
- Production Templates - Production-ready Nomad job templates for Shipper
The service is configured through environment variables. Copy .env.example to .env and modify as needed:
cp .env.example .env| Variable | Description | Default | Required |
|---|---|---|---|
NOMAD_URL |
Nomad API URL | https://your-nomad-cluster:4646 |
β |
NOMAD_TOKEN |
Nomad API token | - | β |
RPC_SECRET |
Secret key for API authentication (64 chars) | - | β |
PORT |
Server port | 16166 |
β |
SKIP_TLS_VERIFY |
Skip TLS verification for Nomad API | false |
β |
LOG_LEVEL |
Logging level (debug, info, warn, error) | info |
β |
LOG_FORMAT |
Log format (json, text) | json |
β |
NEW_RELIC_ENABLED |
Enable New Relic monitoring | false |
β |
NEW_RELIC_LICENSE_KEY |
New Relic license key | - | β |
NEW_RELIC_APP_NAME |
New Relic application name | shipper-deployment |
β |
- Go 1.24+ (for local development)
- Docker and Docker Compose (for containerized deployment)
- Access to a Nomad cluster
-
Clone the repository
git clone <repository-url> cd bastion-deployment
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration -
Run locally
make run
For development with hot reload (using Air inside Docker):
make devThis starts the service with Docker Compose and automatically reloads on code changes using the .air.toml configuration.
-
Build the Docker image
make docker-build
-
Run with Docker Compose
make docker-run
For deploying the Shipper service itself in a Nomad cluster:
-
Basic Nomad Deployment
# Use the provided Nomad job file nomad job run docs/nomad-jobs/shipper-basic.nomad -
Production Nomad Deployment
# For production with high availability nomad job run docs/nomad-jobs/shipper-production.nomad -
Configure Nomad Variables
# Set up secrets using Nomad variables nomad var put nomad/jobs/shipper-deployment \ nomad_token="your-nomad-token" \ rpc_secret="your-64-character-secret"
π For detailed Nomad deployment instructions, see docs/nomad-deployment.md
The project includes comprehensive tests covering models, configuration, database operations, handlers, and integration scenarios:
make testTests are located in the test/ directory and include:
- Unit tests: Config, models, database operations
- Handler tests: API endpoint functionality with mocked dependencies
- Integration tests: Full HTTP server testing with authentication
The project includes comprehensive GitHub Actions workflows:
- Test Suite (
test.yml): Runs tests, checks coverage, formatting, and security - Build Matrix (
build-matrix.yml): Tests compatibility across Go versions and OS platforms - Docker Build (
docker.yml): Builds and publishes Docker images
All workflows run on:
- Every push to
main/masterbranches - Every pull request
- Support for Go 1.22, 1.23, and 1.24
- Cross-platform testing (Linux, macOS, Windows)
make build # Build the application binary
make run # Run the application locally
make dev # Start development environment with hot reload
make test # Run tests
make fmt # Format code
make tidy # Tidy Go modules
make clean # Clean build artifacts
make docker-build # Build Docker image
make docker-run # Run with Docker Compose
make docker-stop # Stop Docker Compose.
βββ .github/
β βββ workflows/ # CI/CD workflows
βββ cmd/
β βββ shipper/ # Application entry point
βββ docs/ # Comprehensive documentation
β βββ examples/ # Sample Nomad job files
β βββ nomad-jobs/ # Shipper deployment templates
β βββ api-usage.md # API documentation and examples
β βββ integration-patterns.md # CI/CD integration patterns
β βββ nomad-deployment.md # Nomad deployment guide
β βββ README.md # Documentation index
βββ internal/
β βββ config/ # Configuration management
β βββ database/ # Database operations
β βββ handlers/ # HTTP handlers
β βββ logger/ # Logging setup
β βββ models/ # Data models
β βββ newrelic/ # New Relic integration
β βββ nomad/ # Nomad client
β βββ server/ # HTTP server setup
βββ test/ # Comprehensive test suite
βββ .env.example # Environment variables template
βββ .golangci.yml # Linting configuration
βββ docker-compose.yml # Production Docker Compose
βββ docker-compose.dev.yml # Development Docker Compose
βββ Makefile # Build automation
- Change Default Secrets: Always use a secure 64-character secret key in production
- TLS Verification: Keep
SKIP_TLS_VERIFY=falsein production environments - Network Security: Ensure proper network policies for Nomad cluster access
- Environment Variables: Never commit
.envfiles with real credentials
The service includes optional New Relic integration for application performance monitoring. Enable by setting:
NEW_RELIC_ENABLED=true
NEW_RELIC_LICENSE_KEY=your-license-key
NEW_RELIC_APP_NAME=shipper-deployment- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
-
Connection to Nomad fails
- Verify
NOMAD_URLandNOMAD_TOKENare correct - Check network connectivity to Nomad cluster
- Verify TLS settings with
SKIP_TLS_VERIFY
- Verify
-
Authentication errors
- Ensure
RPC_SECRETis exactly 64 characters - Verify the secret key matches in deployment requests
- Ensure
-
Service deployment fails
- Verify Nomad token has sufficient permissions
- Check Nomad cluster status and resources