Container Paths
Understanding path mechanics in template containers
Container Paths
Templates run in Docker containers with specific path conventions. Understanding these paths is essential for correct file references.
Container Structure
Default Paths
- workspace/ - Working directory where generated files are written
- templates/ - Template source files (from blob)
- cyan/ - Template code
Working Directory
The default working directory is /workspace:
WORKDIR /workspace
Generated files are written here.
Path Variables
root in File Groups
The root property in file groups refers to paths inside the container:
files: [{ root: 'templates', glob: '**/*', exclude: [], type: GlobType.Template }// root: 'templates' -> /templates/ in container]
This path is relative to the container filesystem, not your development machine.
Blob Image Paths
The blob Dockerfile defines where template files are placed:
# blob.DockerfileFROM alpine:latest# Copy template files to /templates/ in containerCOPY cyan/templates/ /templates/
Then reference in template:
files: [{ root: '/templates', glob: '**/*', exclude: [], type: GlobType.Template }// or simply 'templates' (relative to /workspace)]
Output Path
Generated files are written to the output directory specified by the user:
cyanprint create myorg/template:1.0.0 ./my-project# ^^^^^^^^^^^# Output directory
Inside the container, this maps to /workspace/output.
Path Resolution
Absolute Paths
Use absolute paths for clarity:
files: [{ root: '/templates', glob: '**/*.md', exclude: [], type: GlobType.Template }]
Relative Paths
Relative paths are resolved from /workspace:
files: [{ root: 'templates', glob: '**/*.md', exclude: [], type: GlobType.Template }// Resolves to /workspace/templates]
If your blob image places files at /templates, use /templates (absolute) to avoid confusion.
Common Patterns
Single Templates Directory
# blob.DockerfileFROM alpine:latestCOPY cyan/templates/ /templates/
files: [{ root: '/templates', glob: '**/*', exclude: [], type: GlobType.Template }]
Multiple Source Directories
# blob.DockerfileFROM alpine:latestCOPY cyan/templates/ /templates/COPY cyan/static/ /static/COPY cyan/configs/ /configs/
files: [{ root: '/templates', glob: '**/*.md', exclude: [], type: GlobType.Template },{ root: '/static', glob: '**/*', exclude: [], type: GlobType.Copy },{ root: '/configs', glob: '**/*.json', exclude: [], type: GlobType.Template }]
Feature-Based Organization
# blob.DockerfileFROM alpine:latestCOPY cyan/templates/ /templates/
files: [// Base files{ root: '/templates/base', glob: '**/*', exclude: [], type: GlobType.Template },// Conditional features...(typescript ? [{ root: '/templates/typescript', glob: '**/*', exclude: [], type: GlobType.Template }] : []),...(docker ? [{ root: '/templates/docker', glob: '**/*', exclude: [], type: GlobType.Template }] : [])]
Output Structure
The output structure mirrors the paths inside the templates directory:
Container: /templates/├── README.md├── src/│ └── index.ts└── package.jsonOutput: ./my-project/├── README.md├── src/│ └── index.ts└── package.json
Debugging Paths
Check Container Paths
# Run container and exploredocker run -it --rm my-template:dev shls -la /ls -la /templates
Common Issues
- Wrong root path - Files not found
- Missing COPY in blob - Templates not in container
- Case sensitivity - Linux containers are case-sensitive
Path Summary
| Path | Location | Purpose |
|---|---|---|
/workspace | Container | Working directory |
/workspace/output | Container | Generated files |
/templates | Container (from blob) | Template source |
root property | Container | Source for file groups |
Related
- Project Structure - Template organization
- Dockerfiles Reference - Docker configuration
- Globbing Reference - File patterns