Building Images
HYPR builds images from Dockerfiles using an isolated build process.Basic Build
Build Process
- Parse Dockerfile - Validate syntax, extract stages and instructions
- Resolve Base Image - Pull base image from registry if not cached
- Execute Instructions - Run each instruction in an isolated build VM
- Create Layers - Cache each layer for incremental builds
- Generate Squashfs - Compress final rootfs to squashfs format
- Store Manifest - Save image metadata (entrypoint, env, ports, etc.)
Supported Instructions
FROM
Set base image for the build stage.RUN
Execute commands during build.COPY
Copy files from build context or previous stage.ADD
Copy files with automatic extraction.ENV
Set environment variables.ARG
Define build-time variables.WORKDIR
Set working directory.USER
Set the user for subsequent instructions and runtime.EXPOSE
Document exposed ports.ENTRYPOINT
Set the executable.CMD
Set default arguments.VOLUME
Declare mount points.LABEL
Add metadata.HEALTHCHECK
Define health check command.SHELL
Set default shell.STOPSIGNAL
Set stop signal.Multi-Stage Builds
Use multiple FROM instructions to create smaller final images.Build Arguments
Define withARG in Dockerfile:
Build Cache
HYPR caches layers based on instruction content. Cache is invalidated when:- Dockerfile instruction changes
- Files copied by COPY/ADD change
- Base image changes
- Build argument values change
Image Storage
Built images are stored in/var/lib/hypr/images/ as squashfs files with accompanying manifest JSON.
List images:
Example Dockerfiles
Node.js Application
Go Application
Python Application
Managing Images
List local images:Compose Builds
Build images as part of stack deployment:Limitations
No Network During Build
Build VMs have no network access for security. All dependencies must be:- Included in the base image
- Added to the build context
- Downloaded in a previous multi-stage build
Platform-Specific
Images are built for the current platform (x86_64 or ARM64). Cross-platform builds are not supported.Not BuildKit
HYPR uses its own build implementation. Some advanced BuildKit features are not supported:- Secret mounts (
--mount=type=secret) - SSH mounts (
--mount=type=ssh) - Cache mounts (
--mount=type=cache) - Git context URLs
Best Practices
- Use multi-stage builds to minimize image size
- Order instructions by change frequency (stable first)
- Combine RUN commands to reduce layers
- Use
.dockerignoreto exclude unnecessary files - Set USER to avoid running as root
- Define HEALTHCHECK for container health monitoring
- Use specific tags instead of
latestfor reproducibility
Troubleshooting
Build Fails
- Check Dockerfile syntax
- View build output for error messages
- Verify base image is available
- Ensure context files exist
Out of Space
Cache Not Working
Cache is invalidated when instruction or context files change. Use--no-cache to force rebuild.