mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
services.builder picks the build strategy per service: auto detects from repo contents (Dockerfile → railpack → nixpacks), explicit overrides force a builder, and static builds assets in a node stage then serves them from an nginx image (static_build_cmd/static_dir, port 80 default). - cpu_reserve/memory_reserve → Docker CPU shares + MemoryReservation; cpu/memory stay hard caps (NanoCPUs/Memory). Empty string clears. - app_settings.default_cpu/default_memory override service-create fallbacks; capacity_policy=block fails deploys whose requested memory exceeds node capacity (default warn logs via slog). - Resource specs are validated — "512mb" fails instead of silently dropping the limit. - Fixes: deployments.go hardcoded nixpacks (auto-detect was dead code); DockerfileBuilder passed the Dockerfile *path* as build-context content; BuildImage never drained the daemon stream so builds could abort and errors went unseen — stream is now consumed and errorDetail surfaced. - CLI: --builder/--cpu-reserve/--memory-reserve/--static-cmd/--static-dir on create+update; MCP args on services create/update; UI Build & Resources card; OpenAPI + llms.txt + CLI.md. Verified live: static build of a real repo → nginx image → deployed; reserves reach HostConfig (shares=256, MemoryReservation=128Mi); validation rejects bad specs; builder persists + clears. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Railpack Integration
This directory contains the build system for Containr, with Railpack as the primary build method.
Build Types
Railpack (Primary)
- Detection: Automatically detects supported frameworks (Node.js, Python, Go, Rust, Java, Ruby, PHP, Static)
- API: Uses https://api.railpack.app/v1/ for Dockerfile generation
- Fallback: Falls back to Nixpacks if Railpack cannot build the project
Nixpacks (Secondary)
- Detection: Used as fallback when Railpack detection fails
- Local: Runs locally without external API calls
Dockerfile
- Detection: Checks for existing Dockerfile in repository
- Priority: Highest priority if Dockerfile exists
Prebuilt
- Usage: For pre-built container images
- Configuration: Specified in service configuration
Supported Frameworks
Railpack supports the following frameworks:
- Node.js - package.json detection
- Python - requirements.txt detection
- Go - go.mod detection
- Rust - Cargo.toml detection
- Java - pom.xml or build.gradle detection
- Ruby - Gemfile detection
- PHP - composer.json detection
- Static - Static site detection
Usage
// Create build manager
buildManager := build.NewBuildManager("/tmp/builds", dockerClient)
// Build a project
response, err := buildManager.Build(ctx, &types.BuildRequest{
SourcePath: "/path/to/project",
ImageName: "my-app",
ImageTag: "latest",
})
API Endpoints
- Generate Dockerfile: POST https://api.railpack.app/v1/generate
- Build Plan: POST https://api.railpack.app/v1/plan
Configuration
Railpack can be configured with:
- Custom build commands
- Custom start commands
- Environment variables
- Build root directory