mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 15:51:26 +00:00
Git-sourced deploys never materialized a checkout: sourcePath was build_path resolved against the server cwd, so builds consumed the backend's own directory. Remote placement could only run registry-pulled images. - internal/source: per-deployment checkout (init/fetch/checkout) at branch or commit; GIT_ASKPASS keeps tokens out of argv, .git/config, and the build context; dumb-transport and SHA-refusal fallbacks; build_path validated inside the checkout. - BuildManager.PackageContext: produces the same tar context Build ships to the daemon — generated Dockerfile at tar root, .git excluded. Fixes nixpacks passing the Dockerfile path as content. - Agent artifact endpoint: GET /api/agents/artifacts/:id streams build contexts and docker-save tarballs behind agent-token auth; hex-validated ids, per-deployment cleanup, boot-time purge. - Agent commands: build_image (docker build -, --build-arg values via process env, not argv) and load_image (docker load for containr-* rollback tags no registry serves). - Deployment flow: remote git builds package context → artifact → node docker-builds the deployment tag; remote rollbacks of local tags export via SaveImage → artifact → node docker-loads. Verified end-to-end: agent-pinned git service built on the node (build_image → create_container → deployed) and rollback shipped a docker-save tarball (load_image → deployed). Artifact auth returns 401/404 correctly; workspaces and blobs are removed after deploy. Authored By: TDvorak <[email protected]>
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