LogoCyanPrint

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

(output)
index.ts
  • 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:

filename="Dockerfile"
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:

filename="cyan.ts"
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:

filename="blob.Dockerfile"
# blob.Dockerfile
FROM alpine:latest
# Copy template files to /templates/ in container
COPY cyan/templates/ /templates/

Then reference in template:

filename="cyan.ts"
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:

filename="cyan.ts"
files: [
{ root: '/templates', glob: '**/*.md', exclude: [], type: GlobType.Template }
]

Relative Paths

Relative paths are resolved from /workspace:

filename="cyan.ts"
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

filename="blob.Dockerfile"
# blob.Dockerfile
FROM alpine:latest
COPY cyan/templates/ /templates/
filename="cyan.ts"
files: [
{ root: '/templates', glob: '**/*', exclude: [], type: GlobType.Template }
]

Multiple Source Directories

filename="blob.Dockerfile"
# blob.Dockerfile
FROM alpine:latest
COPY cyan/templates/ /templates/
COPY cyan/static/ /static/
COPY cyan/configs/ /configs/
filename="cyan.ts"
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

filename="blob.Dockerfile"
# blob.Dockerfile
FROM alpine:latest
COPY cyan/templates/ /templates/
filename="cyan.ts"
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.json
Output: ./my-project/
├── README.md
├── src/
│ └── index.ts
└── package.json

Debugging Paths

Check Container Paths

# Run container and explore
docker run -it --rm my-template:dev sh
ls -la /
ls -la /templates

Common Issues

  1. Wrong root path - Files not found
  2. Missing COPY in blob - Templates not in container
  3. Case sensitivity - Linux containers are case-sensitive

Path Summary

PathLocationPurpose
/workspaceContainerWorking directory
/workspace/outputContainerGenerated files
/templatesContainer (from blob)Template source
root propertyContainerSource for file groups