|
| 1 | +# Dalec - Package and Container Builder |
| 2 | + |
| 3 | +Dalec is a Docker BuildKit frontend for building system packages (RPM, DEB) and containers from declarative YAML specifications. It supports multiple Linux distributions and Windows containers. |
| 4 | + |
| 5 | +Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. |
| 6 | + |
| 7 | +## Working Effectively |
| 8 | + |
| 9 | +### Bootstrap and Basic Development |
| 10 | +- Download Go dependencies: `go mod download` -- takes ~5 seconds |
| 11 | +- Run unit tests: `go test --test.short --timeout=10m ./...` -- takes ~52 seconds. NEVER CANCEL. Set timeout to 15+ minutes. |
| 12 | +- Generate source files: `go generate` -- takes ~1 second |
| 13 | +- Run custom linters: `go run ./cmd/lint ./...` -- takes ~3 seconds |
| 14 | +- Validate generated files are up to date: `git diff --exit-code` after running `go generate` |
| 15 | + |
| 16 | +### Building CLI Tools |
| 17 | +- Build frontend binary: `go build -o /tmp/frontend ./cmd/frontend` -- takes ~1 second |
| 18 | +- Build dalec-redirectio: `go build -o /tmp/dalec-redirectio ./cmd/dalec-redirectio` -- takes ~1 second |
| 19 | +- Generate JSON schema: `go run ./cmd/gen-jsonschema` -- takes ~0.2 seconds |
| 20 | +- All other CLI tools in `cmd/` can be built with `go build` or run with `go run` |
| 21 | + |
| 22 | +### Docker Frontend Build System |
| 23 | +**IMPORTANT**: Docker builds may fail in some environments due to TLS certificate issues with proxy.golang.org. This is an environmental limitation, not a code issue. |
| 24 | + |
| 25 | +- Build frontend image: `docker buildx bake frontend` -- takes ~2-5 minutes when working. NEVER CANCEL. Set timeout to 15+ minutes. |
| 26 | +- **Alternative when Docker builds fail**: Use host-compiled binaries for development and testing |
| 27 | +- The frontend requires Docker BuildKit with buildx support |
| 28 | + |
| 29 | +### Integration Testing |
| 30 | +- Run specific distro tests: `go test -timeout=59m -v ./test -run=TestMariner2` -- takes 30+ minutes. NEVER CANCEL. Set timeout to 75+ minutes. |
| 31 | +- Run all integration tests: `go test -timeout=59m -v ./test` -- takes 45+ minutes. NEVER CANCEL. Set timeout to 75+ minutes. |
| 32 | +- Tests require Docker and BuildKit to be working properly |
| 33 | +- Tests cover multiple Linux distributions: Mariner2, Azlinux3, Jammy, Noble, Bullseye, Bookworm, etc. |
| 34 | + |
| 35 | +## Validation |
| 36 | + |
| 37 | +### Always Run Before Committing |
| 38 | +- `go test --test.short ./...` -- validates unit tests pass |
| 39 | +- `go run ./cmd/lint ./...` -- validates custom linting rules |
| 40 | +- `go generate && git diff --exit-code` -- validates generated files are up to date |
| 41 | +- Consider running integration tests for your target distribution if making significant changes |
| 42 | + |
| 43 | +### Manual Validation Scenarios |
| 44 | +- **CLI Tool Testing**: Build and run `go build -o /tmp/frontend ./cmd/frontend` then test with `--help` flag |
| 45 | +- **Schema Generation**: Run `go run ./cmd/gen-jsonschema` and verify JSON schema output is valid |
| 46 | +- **Example Spec Validation**: Use `docs/examples/go-md2man.yml` as a test case for spec validation |
| 47 | + |
| 48 | +### Docker Build Validation (When Working) |
| 49 | +- Build example: `docker build -t go-md2man:test -f docs/examples/go-md2man.yml --target=azlinux3/rpm --output=_output .` |
| 50 | +- Container example: `docker build -t go-md2man:test -f docs/examples/go-md2man.yml --target=azlinux3 .` |
| 51 | + |
| 52 | +## Common Tasks |
| 53 | + |
| 54 | +### Repo Structure |
| 55 | +``` |
| 56 | +. |
| 57 | +├── cmd/ # CLI tools and binaries |
| 58 | +│ ├── frontend/ # Main BuildKit frontend |
| 59 | +│ ├── gen-jsonschema/ # JSON schema generator |
| 60 | +│ ├── lint/ # Custom linters |
| 61 | +│ └── ... # Other tools |
| 62 | +├── docs/examples/ # Example Dalec specs |
| 63 | +├── test/ # Integration tests |
| 64 | +├── targets/ # Target-specific implementations |
| 65 | +├── website/ # Documentation (Docusaurus) |
| 66 | +├── docker-bake.hcl # Docker Buildx configuration |
| 67 | +├── Dockerfile # Frontend container definition |
| 68 | +└── go.mod # Go module definition |
| 69 | +``` |
| 70 | + |
| 71 | +### Key Files to Monitor |
| 72 | +- Always regenerate files after modifying source variants: `go generate` |
| 73 | +- Always run linting after changes: `go run ./cmd/lint ./...` |
| 74 | +- Check `docker-bake.hcl` for Docker build targets and configurations |
| 75 | +- Check `docs/examples/go-md2man.yml` for canonical example of Dalec spec format |
| 76 | + |
| 77 | +### Important Directories |
| 78 | +- `cmd/` - All CLI tools and main binaries |
| 79 | +- `test/` - Comprehensive integration test suite |
| 80 | +- `targets/` - Platform-specific build logic (Linux RPM/DEB, Windows) |
| 81 | +- `frontend/` - Core BuildKit frontend implementation |
| 82 | +- `website/docs/` - User documentation and examples |
| 83 | + |
| 84 | +## Development Environment Requirements |
| 85 | + |
| 86 | +### Required Tools |
| 87 | +- Go 1.23+ (check with `go version`) |
| 88 | +- Docker with BuildKit support (check with `docker buildx version`) |
| 89 | +- Standard Unix tools (git, make, etc.) |
| 90 | + |
| 91 | +### Optional but Recommended |
| 92 | +- Node.js 18+ for documentation site (`cd website && npm start`) |
| 93 | +- golangci-lint for additional linting (though custom linter is primary) |
| 94 | + |
| 95 | +### Environment Limitations |
| 96 | +- Docker builds may fail due to network/certificate issues in some environments |
| 97 | +- Integration tests require full Docker functionality |
| 98 | +- Host-based Go builds always work and are sufficient for most development |
| 99 | + |
| 100 | +### Time Expectations |
| 101 | +- Unit tests: ~1 minute |
| 102 | +- Custom linting: ~3 seconds |
| 103 | +- Code generation: ~1 second |
| 104 | +- Frontend binary build: ~1 second |
| 105 | +- Docker frontend build: 2-5 minutes (when working) |
| 106 | +- Integration test suite: 45+ minutes for full suite, 30+ minutes for single distro |
| 107 | + |
| 108 | +Remember: NEVER CANCEL long-running commands. Build and test operations can legitimately take 30-60+ minutes. |
0 commit comments