Build
make buildComplete guide to setting up Mend for local development.
Install Go 1.21+
brew install gogo version # Verify installationwget https://go.dev/dl/go1.21.0.linux-amd64.tar.gzsudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gzexport PATH=$PATH:/usr/local/go/bingo versionDownload and install from go.dev/dl
Install Redis
brew install redisbrew services start redisredis-cli ping # Should return PONGsudo apt-get install redis-serversudo systemctl start redisredis-cli pingdocker run -d -p 6379:6379 --name redis redis:7-alpineInstall FFmpeg
brew install ffmpegffmpeg -versionsudo apt-get install ffmpegffmpeg -versionDownload from ffmpeg.org
Add to PATH environment variable
Clone and Initialize
cd /path/to/your/projectsgit clone https://github.com/yourusername/mend.gitcd mend
# Download Go dependenciesgo mod downloadgo mod tidyConfigure Application
# Copy example configurationcp config.example.yaml config.yamlcp .env.example .envEdit Configuration Files
server: port: 8080 mode: debug # Use 'debug' for development api_keys: - "${API_KEY_1}"
redis: addr: localhost:6379 password: "" db: 0
s3: region: us-east-1 access_key_id: "${AWS_ACCESS_KEY_ID}" secret_access_key: "${AWS_SECRET_ACCESS_KEY}"
worker: concurrency: 5 # Adjust based on CPU cores
processing: temp_dir: /tmp/mend ffmpeg_path: ffmpeg# AWS CredentialsAWS_ACCESS_KEY_ID=your_access_keyAWS_SECRET_ACCESS_KEY=your_secret_keyAWS_REGION=us-east-1
# API KeyAPI_KEY_1=$(openssl rand -hex 32)s3: region: us-east-1 endpoint: "http://localhost:9000" access_key_id: "minioadmin" secret_access_key: "minioadmin" use_path_style: trueCreate Temp Directory
mkdir -p /tmp/mendTerminal 1 - API Server:
go run cmd/api/main.goTerminal 2 - Worker:
go run cmd/worker/main.go# Build binariesmake build
# Run API (Terminal 1)./bin/api
# Run Worker (Terminal 2)./bin/worker# Start all servicesdocker-compose up -d
# View logsdocker-compose logs -f
# Stop servicesdocker-compose downcurl http://localhost:8080/healthOpen in your browser:
http://localhost:8080/swagger/index.htmlStart MinIO
docker-compose up -d minioAccess MinIO Console
minioadminminioadminCreate a Bucket
test-bucketUpload Test Image
Test Resize Endpoint
curl -X POST http://localhost:8080/api/v1/jobs/image/resize \ -H "Content-Type: application/json" \ -H "X-API-Key: your_api_key_here" \ -d '{ "source_bucket": "test-bucket", "source_key": "test-image.jpg", "dest_bucket": "test-bucket", "dest_key": "resized-image.jpg", "width": 800, "height": 600 }'# Run all testsgo test ./...
# Run with coveragego test -cover ./...
# Run specific packagego test ./internal/processor/image
# Generate coverage reportgo test -coverprofile=coverage.out ./...go tool cover -html=coverage.out# Format codego fmt ./...
# Run lintergolangci-lint run
# Install linter if neededbrew install golangci-lint# Install swaggo install github.com/swaggo/swag/cmd/swag@latest
# Generate docsswag init -g cmd/api/main.go -o docs
# Docs available at /swagger/index.html# Install Airgo install github.com/cosmtrek/air@latest
# Run with hot reloadairbrew install go# or download from go.devbrew services start redisdocker run -d -p 6379:6379 redis:7-alpineredis-cli ping# Should return: PONG# Install FFmpegbrew install ffmpeg
# Or specify full path in config.yamlprocessing: ffmpeg_path: /usr/local/bin/ffmpeg# Verify credentials are setecho $AWS_ACCESS_KEY_IDecho $AWS_SECRET_ACCESS_KEY
# Test with AWS CLIaws s3 lsCheck Redis is running:
redis-cli pingCheck worker logs for errors
Verify queue configuration in config.yaml
Check Redis queue length:
redis-cli LLEN asynq:queues:imageserver: port: 8081 # Use different portBuild
make buildTest
make testClean
make cleanDocker Up
make docker-upRecommended Extensions:
Project should work out of the box:
Read API Docs
Explore the API Reference
Try Examples
Check the examples/ directory for sample code
Deploy
See the Deployment Guide
Architecture
Understand the Architecture