feat(src/djinit/creators): add Dockerfile and .dockerignore generation for new projects

Introduce automatic creation of Dockerfile and .dockerignore during project scaffolding, enabling container‑ready setups out of the box.

* New Features
  - `create_dockerfile` method renders Dockerfile with configurable context (module name, database type, Tailwind usage).
  - `create_dockerignore` method generates a .dockerignore file to exclude unnecessary files from containers.
* Enhancements
  - Added both methods to the setup pipeline in `SetupCreator` so they are executed automatically.
  - Context values are derived from project metadata, allowing customization per project.
* Bug Fixes  - None
This commit is contained in:
sankalp committed 2026-05-28 09:22:29 +05:45
1 parent abb5bd2aa1
commit 05c329b595
2 files changed
+23

No files matched your search

+21
View File
@@ -131,6 +131,27 @@ class FileCreator(BaseService):
filepath, template, context, f"Created {prefix}/{filename}", should_format=True
)
def create_dockerfile(self) -> None:
context = {
"module_name": self.module_name,
"database_type": self.metadata.get("database_type", "postgresql"),
"use_tailwind": self.metadata.get("use_tailwind", False),
}
self._render_and_create_file(
"Dockerfile",
"project/Dockerfile-tpl",
context,
"Created Dockerfile for containerization",
)
def create_dockerignore(self) -> None:
self._render_and_create_file(
".dockerignore",
"project/dockerignore-tpl",
{},
"Created .dockerignore file",
)
def create_gitignore(self) -> None:
self._render_and_create_file(".gitignore", "project/gitignore-tpl", {}, "Created .gitignore file")
+2
View File
@@ -104,6 +104,8 @@ class SetupCreator:
self.file_creator.create_readme,
self.file_creator.create_env_file,
self.file_creator.create_djinit_config,
self.file_creator.create_dockerfile,
self.file_creator.create_dockerignore,
lambda: self.file_creator.create_pyproject(self.metadata),
]