A production-ready template for building applications with Python 3 and FastAPI. This template includes everything you need for both development and production deployment.
- 🐍 Python 3.11 - Modern Python runtime
- ⚡ FastAPI - High-performance web framework
- 🐳 Docker Support - Production-ready Dockerfile
- 💻 DevContainer - Complete development environment with VS Code/Cursor support
- 🔧 Development Tools - Pre-configured with essential dev tools (git, curl, build tools, etc.)
- 🐚 Fish Shell - Fish shell configured as default with proper environment setup
- 🔐 GitHub CLI Integration - Automatic token loading via fish function wrapper
- ☁️ AWS CLI - Architecture-aware AWS CLI installation
- 🧪 Testing - Pytest configured with async support
- ✅ Type Hints - Full type hint support
- Click "Use this template" on GitHub to create a new repository
- Clone your new repository
- Open in VS Code/Cursor with DevContainers extension
- The container will automatically set up your development environment
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
make install-dev
# Run the application
make run
# Run tests
make testThis repository includes a fully configured DevContainer that sets up:
- Base Image:
python:3.11-slim- Official Python runtime - Development Tools: Git, curl, wget, build tools, Python, fish shell, vim, nano, and more
- GitHub CLI: With automatic token loading (see below)
- AWS CLI: Architecture-aware installation (amd64/arm64)
- Fish Shell: Configured as default shell with proper environment variables
- Open the repository in VS Code/Cursor
- When prompted, click "Reopen in Container"
- The setup script will automatically:
- Install all development tools
- Configure fish shell
- Set up GitHub CLI (if token file exists)
- Install development dependencies
To use GitHub CLI in the container:
-
On your Mac, get your GitHub token:
gh auth token
-
Create the token file:
echo "your_token_here" > ~/.config/gh/gh_token chmod 600 ~/.config/gh/gh_token
-
The token file is automatically mounted into the container, and the fish function wrapper will use it automatically.
-
For Mac users with fish shell, copy the wrapper function:
mkdir -p ~/.config/fish/functions cp .devcontainer/gh.fish ~/.config/fish/functions/gh.fish
Now gh commands will automatically use your token in both Mac and container environments!
The included Dockerfile is optimized for production:
# Build the image
docker build -t python-app .
# Run the container
docker run -p 8080:8080 python-appFeatures:
- Uses Python 3.11 slim image (minimal size)
- Installs only production dependencies
- Runs your application with
python main.py - Includes health check endpoint
The deploy.yaml is configured for AWS Faragate deployment. Update the configuration values and run:
make deployThis uses the deploy package installed via pip from the git repository in requirements.txt.
.
├── .devcontainer/ # DevContainer configuration
│ ├── devcontainer.json # Container settings and mounts
│ └── setup-dev.sh # Development environment setup script
├── .github/
│ └── workflows/
│ └── ci.yml # CI/CD workflow
├── main.py # Application entry point
├── test_main.py # Test suite
├── requirements.txt # Production dependencies
├── requirements-dev.txt # Development dependencies
├── pytest.ini # Pytest configuration
├── Makefile # Common commands (make install, make test, etc.)
├── scripts/
│ └── deploy.py # Deploy script wrapper
├── Dockerfile # Production Docker image
├── deploy.yaml # Deployment configuration
└── README.md # This file
The setup script automatically installs:
- Core Tools: git, curl, wget, gnupg, openssh-client
- Build Tools: build-essential, make, cmake, pkg-config
- Development Libraries: libssl-dev, zlib1g-dev, libbz2-dev, etc.
- Languages: Python 3.11, pip, venv
- Shells: bash, zsh, fish
- Editors: vim, nano
- Utilities: htop, strace, jq, rsync, unzip, zip
make help # Show all available commands
make install # Install production dependencies
make install-dev # Install development dependencies
make test # Run tests
make test-cov # Run tests with coverage
make run # Run the application
make deploy # Deploy using deploy.yaml
make clean # Clean up generated filesmake testmake test-covmake runThe application will be available at http://localhost:8080
GET /- Root endpoint returning a greetingGET /health- Health check endpoint for monitoring
PORT- Server port (default: 8080)HOST- Server host (default: 0.0.0.0)
The DevContainer automatically sets:
XDG_CONFIG_HOME=/root/.local/config- For fish shell configurationGH_TOKEN- Automatically loaded from~/.config/gh/gh_token(if present)
- Fish Shell: The default shell is fish. Universal variables are stored in
/root/.local/config/fish/to work with the read-only mounted config directory. - GitHub CLI: The fish function wrapper automatically loads tokens from the mounted file, making authentication seamless.
- Health Check: The
/healthendpoint is available for health checks and monitoring. - FastAPI: The application uses FastAPI which provides automatic API documentation at
/docsand/redocwhen running.
This is a template repository. Feel free to:
- Use it as a starting point for your projects
- Customize the setup scripts for your needs
- Add your own development tools and configurations
This template is provided as-is for use in your projects.