<p align="center"> <a href="https://www.npmjs.com/package/@nx-tools/nx-container"> <img alt="NPM Version" src="https://img.shields.io/npm/v/@nx-tools/nx-container"/> </a> <a href="https://www.npmjs.com/package/@nx-tools/nx-container"> <img a
npm install @nx-tools/nx-containerThe @nx-tools/nx-container plugin streamlines container image workflows in Nx monorepos by providing a unified interface for multiple container build engines and automated image management capabilities.
- Multi-Engine Support: Build container images using your preferred container engine:
- Docker Buildx with Moby BuildKit for advanced build features
- Podman for rootless and daemonless container builds
- Automated Image Management: Intelligent tag generation and OCI Image Format Specification compliant labeling
- Project Scaffolding: Code generators to quickly configure container builds for your applications
To add the @nx-tools/nx-container plugin to your Nx workspace, run the following command:
``package-install`
npx nx add @nx-tools/nx-container
This command will:
- Install the plugin package
- Configure the plugin in your nx.json file
- Set up default configurations for your workspace
The plugin automatically detects projects suitable for containerization and adds a container task to any project containing a Dockerfile. This intelligent inference eliminates the need for manual task configuration in most cases.
To inspect the automatically inferred tasks for any project:
- Using Nx Console: Open the project details view for comprehensive task visualization
- Using CLI: Execute nx show project to display project configuration and available tasks
Configure the @nx-tools/nx-container plugin in your workspace's nx.json file within the plugins array:
`json title="nx.json"`
{
"plugins": [
{
"plugin": "@nx-tools/nx-container",
"options": {
"defaultEngine": "docker",
"defaultRegistry": "docker.io"
}
}
]
}
You can customize the default build engine and registry to match your infrastructure requirements:
`json title="nx.json"`
{
"plugins": [
{
"plugin": "@nx-tools/nx-container",
"options": {
"defaultEngine": "podman",
"defaultRegistry": "ghcr.io"
}
}
]
}
Supported Engines:
- docker (default) - Standard Docker builds with BuildKitpodman
- - Rootless container builds
Common Registries:
- docker.io - Docker Hub (default)ghcr.io
- - GitHub Container Registrygcr.io
- - Google Container Registry
- Custom registry URLs
`bash`
nx container appName
To use a different engine, you need to update the options.engine property of your project target or use the INPUT_ENGINE environment variable. All possible values are docker (the default) and podman`
> [!IMPORTANT]
> You can set docker or podman engine in your project.json targets to use in your dev machine, and use INPUT_ENGINE env variable to use docker in your CI/CD pipelines.
- Advanced usage:
- Multi-platform image
- Push to multi-registries
- Cache
- Local registry
- Export image to Docker
- Handle tags and labels
- Usage with CI
Here is a list of all the executors and generators available from this package:
- build: Builds an image using instructions from the Dockerfile and a specified build context directory.
- init: Initialize Container settings for your workspace.
- configuation: Configure Container builds for your application.
Join the growing Nx Tools community! We believe in building together and welcome contributors of all experience levels.
- Report Issues: Found a bug or have a suggestion? Open an issue on GitHub
- Ask Questions: Need help or clarification? Start a conversation in GitHub Discussions
- Contribute Code: Pull requests are welcome! Check our contribution guidelines to get started
- Share Your Work: Built something with Nx Tools? Share it with the community in the Showcase discussion
- Spread the Word: Star the repository, share on social media, or write about your experience
- GitHub Repository - Source code, issues, and project management
- GitHub Discussions - Community conversations and support
- NPM Package - Latest releases and installation information
- Documentation - Comprehensive guides and API reference
- Code of Conduct - Our community standards and expectations
Your feedback and contributions help make Nx Tools better for everyone!
MIT License © Gustavo Perdomo