Skip to main content

A production-grade CLI tool to generate deployment configuration files for Django/React projects.

Project description

deployfilegen

deployfilegen is a production-grade Python CLI library designed to automatically generate infrastructure-as-code for full-stack applications (Django + React/Next.js/Vite).

It automates the creation of Dockerfiles, docker-compose.yml, and GitHub Actions workflows, using secure, battle-tested defaults.

🚀 Key Features (v0.1.31+)

  • Zero-Config Dev Mode: Works with any existing .env file. No forced variable naming.
  • Smart Framework Detection: Automatically detects Vite (port 5173), Next.js (port 3000), or Create React App.
  • Flexible Deployment: Choose between SSH Build (default) or Registry Push strategies.
  • Production-Grade Defaults:
    • Security: Non-root users, unprivileged Nginx.
    • Reliability: Healthchecks, restart policies, race-condition prevention.
    • Optimization: Multi-stage builds, .dockerignore generation, layer caching.

📦 Quick Start

1. Install

pip install deployfilegen

2. Local Development (Zero Config)

# Generate dev config (auto-detects your stack)
deployfilegen init --mode dev

# Start your app
docker compose -f docker-compose.dev.yml up --build

# With a Postgres database
deployfilegen init --mode dev --with-db --force
docker compose -f docker-compose.dev.yml up --build

3. Production — SSH Build (Default, Recommended)

Build images directly on your server. No container registry needed.

# Generate production config
deployfilegen init --mode prod --deploy ssh

# Or just (ssh is the default):
deployfilegen init --mode prod

Required .env variables (only 2!):

DEPLOY_HOST=your_server_ip
DEPLOY_USER=ubuntu

Generated GitHub Actions workflow will:

SSH into server → git pull → docker compose build → docker compose up -d

4. Production — Registry Push (Advanced)

Push images to Docker Hub/GHCR, then pull on server. Use this for immutable deployments.

deployfilegen init --mode prod --deploy registry

Required .env variables:

# Server (always required)
DEPLOY_HOST=your_server_ip
DEPLOY_USER=ubuntu

# Registry (only required for --deploy registry)
DOCKER_USERNAME=your_username
BACKEND_IMAGE_NAME=user/backend
FRONTEND_IMAGE_NAME=user/frontend

Generated GitHub Actions workflow will:

Build images → Push to Registry → SSH into server → 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 with the right variables for your strategy:

# SSH mode (minimal — just 2 vars)
deployfilegen template

# Registry mode (includes image names)
deployfilegen template --deploy registry

📖 CLI Reference

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 in docker-compose

  # 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?

# Check which variables you need:
deployfilegen template              # SSH: just DEPLOY_HOST + DEPLOY_USER
deployfilegen template --deploy registry  # Registry: adds DOCKER_USERNAME + IMAGE_NAMEs

Frontend container exits immediately? Your dev server might not be binding to 0.0.0.0. Override the start command:

deployfilegen init --mode dev --start-command "serve" --force

Wrong port detected?

deployfilegen init --mode dev --frontend-port 8080 --force

Django project name wrong?

deployfilegen init --mode prod --project-name my_project --force

📄 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deployfilegen-0.1.32.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deployfilegen-0.1.32-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file deployfilegen-0.1.32.tar.gz.

File metadata

  • Download URL: deployfilegen-0.1.32.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for deployfilegen-0.1.32.tar.gz
Algorithm Hash digest
SHA256 c40436b92df9c918ab66b035bf9707ce44d3f66fbe5de05e8966160aeefbbb73
MD5 b21e7a1badf35d14641a107c6c489cb5
BLAKE2b-256 a740064d65148f44aea7e0a50b112a9978989955e807f2bf7230c69b9ba5df1b

See more details on using hashes here.

File details

Details for the file deployfilegen-0.1.32-py3-none-any.whl.

File metadata

  • Download URL: deployfilegen-0.1.32-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for deployfilegen-0.1.32-py3-none-any.whl
Algorithm Hash digest
SHA256 32579cffd9370c398404db6ffccb22a65be9c71fce31eb819a7d16678de0670b
MD5 b70dbfe2b912ee322befcbf178c8a20b
BLAKE2b-256 8c9983b950a956ef7a426a9d8dbaa409c73871b9273c4219294ea731487ac92c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page