Initial commit: Complete project-bootstrap tool
- Bootstrap script for creating monorepo projects - FastAPI backend templates with uv, ruff, mypy, pytest - React frontend templates with TypeScript, ESLint, Prettier - Docker Compose setup with backend, frontend, and database - 9 development and CI scripts - Gitea Actions CI/CD workflows - Comprehensive documentation (8 files) - 45 template files for complete project structure - Automated verification script (all tests pass) - Based on coding-agent-rules standards
This commit is contained in:
16
templates/deploy/.env.example
Normal file
16
templates/deploy/.env.example
Normal file
@@ -0,0 +1,16 @@
|
||||
# Docker Compose Environment Variables
|
||||
|
||||
# Backend
|
||||
BACKEND_PORT=8000
|
||||
DEBUG=true
|
||||
LOG_LEVEL=INFO
|
||||
|
||||
# Frontend
|
||||
FRONTEND_PORT=3000
|
||||
REACT_APP_API_URL=http://localhost:8000
|
||||
|
||||
# Database
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
POSTGRES_DB=appdb
|
||||
POSTGRES_PORT=5432
|
||||
71
templates/deploy/README.md
Normal file
71
templates/deploy/README.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# Deployment Configuration
|
||||
|
||||
This directory contains deployment artifacts for the project.
|
||||
|
||||
## Structure
|
||||
|
||||
- **compose.yml** - Docker Compose configuration for local development and deployment
|
||||
- **.env.example** - Example environment variables
|
||||
- **docker/** - Dockerfiles and container documentation
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Local Development
|
||||
|
||||
1. Copy environment file:
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2. Start all services:
|
||||
```bash
|
||||
docker compose -f deploy/compose.yml up
|
||||
```
|
||||
|
||||
3. Access services:
|
||||
- Backend: http://localhost:8000
|
||||
- Frontend: http://localhost:3000
|
||||
- API Docs: http://localhost:8000/docs
|
||||
- Database: localhost:5432
|
||||
|
||||
### Stop Services
|
||||
|
||||
```bash
|
||||
docker compose -f deploy/compose.yml down
|
||||
```
|
||||
|
||||
### Rebuild Services
|
||||
|
||||
```bash
|
||||
docker compose -f deploy/compose.yml up --build
|
||||
```
|
||||
|
||||
### View Logs
|
||||
|
||||
```bash
|
||||
# All services
|
||||
docker compose -f deploy/compose.yml logs -f
|
||||
|
||||
# Specific service
|
||||
docker compose -f deploy/compose.yml logs -f backend
|
||||
```
|
||||
|
||||
## Production Deployment
|
||||
|
||||
For production deployments, consider:
|
||||
|
||||
1. Using separate compose files for different environments
|
||||
2. Implementing proper secret management
|
||||
3. Setting up reverse proxy (nginx/traefik)
|
||||
4. Configuring SSL/TLS certificates
|
||||
5. Setting up monitoring and logging
|
||||
6. Implementing backup strategies
|
||||
|
||||
## Kubernetes (Optional)
|
||||
|
||||
If deploying to Kubernetes, create a `k8s/` directory with:
|
||||
|
||||
- Deployment manifests
|
||||
- Service definitions
|
||||
- ConfigMaps and Secrets
|
||||
- Ingress configuration
|
||||
63
templates/deploy/compose.yml
Normal file
63
templates/deploy/compose.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
backend:
|
||||
build:
|
||||
context: ../backend
|
||||
dockerfile: ../deploy/docker/backend.Dockerfile
|
||||
container_name: backend
|
||||
ports:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
- DEBUG=true
|
||||
- LOG_LEVEL=INFO
|
||||
- API_HOST=0.0.0.0
|
||||
- API_PORT=8000
|
||||
- CORS_ORIGINS=http://localhost:3000
|
||||
volumes:
|
||||
- ../backend:/app
|
||||
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
|
||||
networks:
|
||||
- app-network
|
||||
depends_on:
|
||||
- database
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ../frontend
|
||||
dockerfile: ../deploy/docker/frontend.Dockerfile
|
||||
container_name: frontend
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- REACT_APP_API_URL=http://localhost:8000
|
||||
- REACT_APP_API_PREFIX=/api/v1
|
||||
volumes:
|
||||
- ../frontend:/app
|
||||
- /app/node_modules
|
||||
command: npm start
|
||||
networks:
|
||||
- app-network
|
||||
depends_on:
|
||||
- backend
|
||||
|
||||
database:
|
||||
image: postgres:16-alpine
|
||||
container_name: database
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DB=appdb
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
40
templates/deploy/docker/README.md
Normal file
40
templates/deploy/docker/README.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Docker Configuration
|
||||
|
||||
This directory contains Dockerfiles for building container images.
|
||||
|
||||
## Files
|
||||
|
||||
- **backend.Dockerfile** - Backend service (FastAPI)
|
||||
- **frontend.Dockerfile** - Frontend service (React)
|
||||
|
||||
## Building Images
|
||||
|
||||
### Backend
|
||||
|
||||
```bash
|
||||
docker build -f deploy/docker/backend.Dockerfile -t backend:latest ./backend
|
||||
```
|
||||
|
||||
### Frontend
|
||||
|
||||
```bash
|
||||
docker build -f deploy/docker/frontend.Dockerfile -t frontend:latest ./frontend
|
||||
```
|
||||
|
||||
## Running with Docker Compose
|
||||
|
||||
From the project root:
|
||||
|
||||
```bash
|
||||
docker compose -f deploy/compose.yml up
|
||||
```
|
||||
|
||||
## Production Builds
|
||||
|
||||
For production, consider:
|
||||
|
||||
1. Multi-stage builds to reduce image size
|
||||
2. Non-root user for security
|
||||
3. Health checks
|
||||
4. Proper secret management
|
||||
5. Optimized layer caching
|
||||
23
templates/deploy/docker/backend.Dockerfile
Normal file
23
templates/deploy/docker/backend.Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
# Backend Dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install uv
|
||||
RUN pip install --no-cache-dir uv
|
||||
|
||||
# Copy dependency files
|
||||
COPY pyproject.toml ./
|
||||
|
||||
# Install dependencies
|
||||
RUN uv pip install --system -e .
|
||||
RUN uv pip install --system -e ".[dev]"
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8000
|
||||
|
||||
# Run the application
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
19
templates/deploy/docker/frontend.Dockerfile
Normal file
19
templates/deploy/docker/frontend.Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
# Frontend Dockerfile
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# Run the application
|
||||
CMD ["npm", "start"]
|
||||
Reference in New Issue
Block a user