Metadata-Version: 2.4
Name: deployfilegen
Version: 0.1.33
Summary: A production-grade CLI tool to generate deployment configuration files for Django/React projects.
Author-email: Shankarsan Sahoo <shankarsansahoo2001@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Shankarsan Sahoo
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/Shankarsan-Sahoo/deployfilegen
Project-URL: Repository, https://github.com/Shankarsan-Sahoo/deployfilegen.git
Project-URL: Issues, https://github.com/Shankarsan-Sahoo/deployfilegen/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer[all]
Requires-Dist: python-dotenv
Requires-Dist: pytest
Dynamic: license-file

# deployfilegen

[![PyPI version](https://img.shields.io/pypi/v/deployfilegen.svg)](https://pypi.org/project/deployfilegen/)
[![Downloads](https://img.shields.io/pypi/dm/deployfilegen.svg)](https://pypi.org/project/deployfilegen/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)

**deployfilegen** is a production-grade Python CLI that auto-generates **Dockerfiles**, **docker-compose.yml**, and **GitHub Actions** workflows for Django + React/Next.js/Vite projects.

**One command. Zero config. Production-ready.**

```bash
pip install deployfilegen
deployfilegen init --mode dev     # Dev environment — just works
deployfilegen init --mode prod    # Production — hardened & optimized
```

---

## ⚡ Demo

```bash
$ deployfilegen init --mode dev

Generating Backend Dockerfile...
Generated backend/Dockerfile
Generating Frontend Dockerfile...
Generated frontend/Dockerfile
Generating Docker Compose...
Generated docker-compose.dev.yml
Deployment configuration generated successfully!

$ docker compose -f docker-compose.dev.yml up --build
# ✅ Backend at http://localhost:8000
# ✅ Frontend at http://localhost:5173 (Vite auto-detected)
```

---

## 📁 Expected Project Structure

```
my-project/
├── .env                    # Your environment variables
├── backend/
│   ├── manage.py           # Django project
│   └── requirements.txt
├── frontend/
│   ├── package.json        # React/Vite/Next.js
│   └── src/
│
│── # Generated by deployfilegen ──────────
├── backend/Dockerfile      ← generated
├── frontend/Dockerfile     ← generated
├── docker-compose.dev.yml  ← generated (dev mode)
├── docker-compose.prod.yml ← generated (prod mode)
└── .github/workflows/
    └── deploy.yml          ← generated (prod mode)
```

---

## 🚀 Key Features

- **Zero-Config Dev Mode**: Works with *any* existing `.env` file. No forced variable naming.
- **Smart Framework Detection**: Auto-detects **Vite** (port 5173), **Next.js** (port 3000), or **CRA**.
- **Flexible Deployment**: SSH Build (default) or Registry Push — you choose.
- **Production-Grade Defaults**:
    - Non-root users, unprivileged Nginx
    - Healthchecks, restart policies
    - Multi-stage builds, `.dockerignore` generation

---

## 📦 Deployment Strategies

### SSH Build (Default — No Registry Needed)

```bash
deployfilegen init --mode prod --deploy ssh
```

**Required `.env` (only 2 variables!):**
```ini
DEPLOY_HOST=your_server_ip
DEPLOY_USER=ubuntu
```

**CI/CD workflow:** `SSH → git pull → docker compose build → up -d`

### Registry Push (Advanced — Immutable Deployments)

```bash
deployfilegen init --mode prod --deploy registry
```

**Required `.env`:**
```ini
# Always required
DEPLOY_HOST=your_server_ip
DEPLOY_USER=ubuntu

# Only for --deploy registry
DOCKER_USERNAME=your_username
BACKEND_IMAGE_NAME=user/backend
FRONTEND_IMAGE_NAME=user/frontend
```

**CI/CD workflow:** `Build → Push to Registry → SSH → docker compose pull → up -d`

---

## 🛠 Supported Stacks

| Component | Framework | Auto-Detected |
|:---|:---|:---|
| **Backend** | Django | Project name from `manage.py` |
| **Frontend** | Vite | Port `5173`, `--host` binding |
| **Frontend** | Next.js | Port `3000`, `-H` binding |
| **Frontend** | CRA | Port `3000`, `HOST` env |

---

## ⚙️ Configuration

Generate a boilerplate `.env`:
```bash
deployfilegen template                    # SSH mode (minimal)
deployfilegen template --deploy registry  # Registry mode (full)
```

---

## 📖 CLI Reference

```text
Usage: deployfilegen init [OPTIONS]

Options:
  --mode [dev|prod]       Generation mode (Default: prod)
  --deploy [ssh|registry] Deployment strategy (Default: ssh)
  --force, -f             Overwrite existing files
  --with-db               Include a Postgres service

  # Scope Control
  --docker-only           Generate only Dockerfiles
  --compose-only          Generate only docker-compose.yml
  --github-only           Generate only GitHub Actions (Prod only)
  --backend-only          Only generate backend assets
  --frontend-only         Only generate frontend assets

  # Override Detection
  --frontend-port INT     Override detected frontend dev port
  --start-command TEXT    Override detected frontend start command
  --project-name TEXT     Override detected Django project name

  --help                  Show this message
```

---

## 🔧 Troubleshooting

**"Missing required variables" error in prod mode?**
```bash
deployfilegen template              # SSH: just DEPLOY_HOST + DEPLOY_USER
deployfilegen template --deploy registry  # Registry: adds DOCKER_USERNAME + IMAGE_NAMEs
```

**Frontend container exits immediately?**
```bash
deployfilegen init --mode dev --start-command "serve" --force
```

**Wrong port detected?**
```bash
deployfilegen init --mode dev --frontend-port 8080 --force
```

**Django project name wrong?**
```bash
deployfilegen init --mode prod --project-name my_project --force
```

---

## 📄 License
MIT
