Skip to content

Commit 0e6a485

Browse files
authored
Merge pull request #33 from nullhack/V2/init
simplify: Docker consolidation and README badge cleanup
2 parents 8ed4ef1 + 111bbec commit 0e6a485

File tree

5 files changed

+70
-503
lines changed

5 files changed

+70
-503
lines changed

.opencode/templates/README.md.template

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77
[![MIT License][license-shield]][license-url]
88
[![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen?style=for-the-badge)](docs/coverage/index.html)
99

10-
[![CI Status](https://github.com/{{GITHUB_USERNAME}}/{{PROJECT_NAME}}/workflows/CI/badge.svg?style=for-the-badge)](https://github.com/{{GITHUB_USERNAME}}/{{PROJECT_NAME}}/actions/workflows/ci.yml)
11-
[![CodeQL](https://github.com/{{GITHUB_USERNAME}}/{{PROJECT_NAME}}/workflows/CodeQL%20Security%20Analysis/badge.svg?style=for-the-badge)](https://github.com/{{GITHUB_USERNAME}}/{{PROJECT_NAME}}/actions/workflows/codeql.yml)
12-
[![Python](https://img.shields.io/badge/python-3.12%20%7C%203.13-blue?style=for-the-badge)](https://www.python.org/downloads/)
13-
[![Code Style](https://img.shields.io/badge/code%20style-ruff-000000.svg?style=for-the-badge)](https://github.com/astral-sh/ruff)
14-
[![Security](https://img.shields.io/badge/security-ruff%20%2B%20CodeQL-green?style=for-the-badge)](https://docs.astral.sh/ruff/rules/#flake8-bandit-s)
10+
[![CI](https://img.shields.io/github/actions/workflow/status/{{GITHUB_USERNAME}}/{{PROJECT_NAME}}/ci.yml?style=for-the-badge&label=CI)](https://github.com/{{GITHUB_USERNAME}}/{{PROJECT_NAME}}/actions/workflows/ci.yml)
11+
[![Python](https://img.shields.io/badge/python-3.13-blue?style=for-the-badge)](https://www.python.org/downloads/)
1512

1613
> {{PROJECT_DESCRIPTION}}
1714

@@ -104,44 +101,18 @@ task mut-report # Mutation testing (optional)
104101

105102
## 🐳 Docker Usage
106103

107-
Modern Docker setup with multi-stage builds, distroless production images, and comprehensive development workflows.
108-
109-
### Development Environment
110-
111-
```bash
112-
# Start development environment with hot reload
113-
docker-compose up
114-
115-
# Run specific services
116-
docker-compose up app # Main application
117-
docker-compose up docs # Documentation server (localhost:8080)
118-
119-
# Development with profiles
120-
docker-compose --profile test up # Run test suite
121-
docker-compose --profile quality up # Code quality checks
122-
```
123-
124-
### Production Deployment
104+
Simple Docker setup for development with hot reload and integrated tooling.
125105

126106
```bash
127-
# Build production image (distroless, security-optimized)
128-
docker build --target production -t {{PROJECT_NAME}}:prod .
129-
130-
# Production testing environment
131-
docker-compose -f docker-compose.prod.yml up
132-
133-
# Security scanning
134-
docker-compose -f docker-compose.prod.yml --profile security up
135-
136-
# Load testing
137-
docker-compose -f docker-compose.prod.yml --profile load-test up
107+
# Development workflows
108+
docker-compose up # Hot reload development environment
109+
docker-compose --profile test up # Run complete test suite
110+
docker-compose --profile docs up # Documentation server (localhost:8080)
111+
docker-compose --profile quality up # Code quality checks (lint + typecheck)
112+
113+
# Build standalone image
114+
docker build -t {{PROJECT_NAME}} . # Build development image
138115
```
139-
140-
### Key Features
141-
142-
- **🔒 Security-First**: Distroless production images, non-root user, vulnerability scanning
143-
- **⚡ Performance**: BuildKit caching, uv package manager, optimized layer ordering
144-
- **📊 Monitoring**: Health checks, resource limits, comprehensive logging
145116
- **🛠️ Development**: Hot reload, separate services for testing/docs/quality checks
146117

147118

@@ -155,7 +126,7 @@ docker-compose -f docker-compose.prod.yml --profile load-test up
155126
| **Testing** | PyTest + Hypothesis (property-based testing), pytest-html-plus (BDD reports) |
156127
| **AI Integration** | OpenCode agents for development automation |
157128
| **Documentation** | pdoc with search functionality |
158-
| **Containerization** | Docker with distroless production, BuildKit caching, security scanning |
129+
| **Containerization** | Docker development environment with hot reload |
159130

160131
## 📈 Quality Metrics
161132

@@ -168,22 +139,18 @@ docker-compose -f docker-compose.prod.yml --profile load-test up
168139
## 🚀 Deployment Ready
169140

170141
```bash
171-
# Production container (distroless, security-hardened)
172-
docker build --target production -t {{PROJECT_NAME}}:latest .
173-
docker run {{PROJECT_NAME}}:latest
142+
# Build container image
143+
docker build -t {{PROJECT_NAME}} .
144+
docker run {{PROJECT_NAME}}
174145

175-
# Production environment testing
176-
docker-compose -f docker-compose.prod.yml up
146+
# Run with Docker Compose
147+
docker-compose up
177148

178149
# Build API documentation
179150
task doc-build # Generates docs/api/index.html
180151

181-
# Publish API docs to GitHub Pages
182-
task doc-publish # Pushes docs/api to gh-pages branch
183-
184-
# Smart release management
185-
@repo-manager /skill git-release
186-
# Creates versioned release: v1.2.20260315 "Creative Fox"
152+
# Serve documentation locally
153+
task doc-serve # http://localhost:8080
187154
```
188155

189156
## 🤝 Contributing

Dockerfile

Lines changed: 21 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,26 @@
11
# syntax=docker/dockerfile:1.7
2-
# Modern Dockerfile for python-project-template
3-
# Features: multi-stage build, distroless prod, security scanning, BuildKit caching
2+
# Simplified Dockerfile for python-project-template
3+
# Single-stage development-focused build
44

55
ARG PYTHON_VERSION=3.13.1
6-
ARG BUILDPLATFORM=linux/amd64
76

8-
# =============================================================================
9-
# Base stage: Python + uv package manager
10-
# =============================================================================
11-
FROM --platform=$BUILDPLATFORM python:${PYTHON_VERSION}-alpine AS base
7+
FROM python:${PYTHON_VERSION}-slim AS base
128

13-
# Install uv for ultra-fast Python package management
14-
RUN --mount=type=cache,target=/root/.cache/pip \
15-
pip install --upgrade pip uv
9+
# Install uv for fast Python package management
10+
RUN pip install --upgrade pip uv
1611

17-
# Create non-root user early
18-
RUN addgroup --system --gid 1001 appuser && \
19-
adduser --system --uid 1001 --ingroup appuser appuser
12+
# Create non-root user
13+
RUN groupadd --gid 1001 appuser && \
14+
useradd --uid 1001 --gid appuser --shell /bin/bash --create-home appuser
2015

2116
WORKDIR /app
2217

23-
# =============================================================================
24-
# Dependencies stage: Install and cache Python dependencies
25-
# =============================================================================
26-
FROM base AS deps
27-
28-
# Install build dependencies
29-
RUN apk add --no-cache \
30-
build-base \
31-
linux-headers \
32-
git
33-
3418
# Copy dependency files first (better layer caching)
35-
COPY pyproject.toml ./
19+
COPY pyproject.toml uv.lock* ./
3620

37-
# Install dependencies with uv (much faster than pip)
21+
# Install dependencies
3822
RUN --mount=type=cache,target=/root/.cache/uv \
39-
--mount=type=cache,target=/root/.cache/pip \
40-
uv pip install --system '.[dev]' taskipy
41-
42-
# =============================================================================
43-
# Test stage: Run linting and tests
44-
# =============================================================================
45-
FROM deps AS test
23+
uv sync --locked --dev
4624

4725
# Copy source code
4826
COPY . .
@@ -51,103 +29,23 @@ COPY . .
5129
RUN chown -R appuser:appuser /app
5230
USER appuser
5331

54-
# Set build arguments for conditional testing
55-
ARG TESTBUILD=true
56-
ENV TESTBUILD=$TESTBUILD
57-
58-
# Run quality checks and tests if enabled
59-
RUN if [ "$TESTBUILD" = "true" ]; then \
60-
echo "🔍 Running linting..." && \
61-
task lint && \
62-
echo "🧪 Running tests..." && \
63-
task test && \
64-
echo "✅ All quality checks passed!"; \
65-
fi
66-
67-
# =============================================================================
68-
# Build stage: Create wheel distribution
69-
# =============================================================================
70-
FROM test AS build
71-
72-
# Build wheel package
73-
RUN --mount=type=cache,target=/root/.cache/uv \
74-
uv build --wheel --out-dir dist
75-
76-
# =============================================================================
77-
# Security scanning stage (optional but recommended)
78-
# =============================================================================
79-
FROM aquasec/trivy:latest AS security-scan
80-
81-
# Copy built artifacts for scanning
82-
COPY --from=build /app/dist /scan/dist
83-
COPY --from=build /app/pyproject.toml /scan/
84-
85-
# Run security scan (will fail build on HIGH/CRITICAL vulnerabilities)
86-
RUN trivy fs --exit-code 1 --severity HIGH,CRITICAL /scan || \
87-
(echo "❌ Security vulnerabilities found! Check the output above." && exit 1)
88-
89-
# =============================================================================
90-
# Runtime preparation: Install wheel in clean Python environment
91-
# =============================================================================
92-
FROM python:${PYTHON_VERSION}-alpine AS runtime-prep
93-
94-
# Install the wheel package in a clean environment
95-
COPY --from=build /app/dist/*.whl /tmp/
96-
RUN pip install --prefix=/app/python /tmp/*.whl
97-
98-
# =============================================================================
99-
# Production stage: Minimal distroless runtime
100-
# =============================================================================
101-
FROM gcr.io/distroless/python3-debian12:latest AS production
102-
103-
# Copy installed Python packages from runtime prep
104-
COPY --from=runtime-prep /app/python /usr/local
105-
106-
# Set working directory
107-
WORKDIR /app
108-
109-
# Use non-root user (distroless default nonroot user)
110-
USER nonroot:nonroot
111-
112-
# Configure Python for production
32+
# Configure Python
33+
ENV PYTHONPATH=/app
11334
ENV PYTHONUNBUFFERED=1
11435
ENV PYTHONDONTWRITEBYTECODE=1
115-
ENV PYTHONHASHSEED=random
11636

117-
# Health check using module execution
37+
# Expose common ports
38+
EXPOSE 8000 8080 5678
39+
40+
# Health check
11841
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
11942
CMD python -m python_package_template.python_module_template || exit 1
12043

12144
# Default command
12245
CMD ["python", "-m", "python_package_template.python_module_template"]
12346

124-
# =============================================================================
125-
# Development stage: For local development with hot reload
126-
# =============================================================================
127-
FROM deps AS development
128-
129-
# Install development tools
130-
RUN --mount=type=cache,target=/root/.cache/uv \
131-
uv pip install --system watchdog
132-
133-
# Copy source code
134-
COPY . .
135-
136-
# Change ownership and switch to non-root user
137-
RUN chown -R appuser:appuser /app
138-
USER appuser
139-
140-
# Expose common development ports
141-
EXPOSE 8000 8080 5678
142-
143-
# Development command with auto-reload
144-
CMD ["python", "-m", "python_package_template.python_module_template"]
145-
146-
# =============================================================================
147-
# Metadata and labels
148-
# =============================================================================
47+
# Labels
14948
LABEL maintainer="eol"
150-
LABEL version="0.1.20260411"
151-
LABEL description="Python project template with modern Docker practices"
152-
LABEL org.opencontainers.image.source="https://github.com/nullhack/python-project-template"
153-
LABEL org.opencontainers.image.documentation="https://github.com/nullhack/python-project-template/tree/main/docs/api/"
49+
LABEL version="2.0.20260411"
50+
LABEL description="Python project template - simplified Docker setup"
51+
LABEL org.opencontainers.image.source="https://github.com/nullhack/python-project-template"

README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77
[![MIT License][license-shield]][license-url]
88
[![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen?style=for-the-badge)](docs/coverage/index.html)
99

10-
[![CI Status](https://github.com/nullhack/python-project-template/workflows/CI/badge.svg?style=for-the-badge)](https://github.com/nullhack/python-project-template/actions/workflows/ci.yml)
11-
[![CodeQL](https://github.com/nullhack/python-project-template/workflows/CodeQL%20Security%20Analysis/badge.svg?style=for-the-badge)](https://github.com/nullhack/python-project-template/actions/workflows/codeql.yml)
10+
[![CI](https://img.shields.io/github/actions/workflow/status/nullhack/python-project-template/ci.yml?style=for-the-badge&label=CI)](https://github.com/nullhack/python-project-template/actions/workflows/ci.yml)
1211
[![Python](https://img.shields.io/badge/python-3.13-blue?style=for-the-badge)](https://www.python.org/downloads/)
13-
[![Code Style](https://img.shields.io/badge/code%20style-ruff-000000.svg?style=for-the-badge)](https://github.com/astral-sh/ruff)
14-
[![Security](https://img.shields.io/badge/security-ruff%20%2B%20CodeQL-green?style=for-the-badge)](https://docs.astral.sh/ruff/rules/#flake8-bandit-s)
1512

1613
> **Ship production-ready Python projects faster with AI-powered development workflows**
1714
@@ -179,25 +176,24 @@ task doc-build # Static API documentation generation
179176

180177
```bash
181178
# Development workflows
182-
docker-compose up # Hot reload development
183-
docker-compose --profile test up # Complete test suite
184-
docker-compose --profile quality up # Code quality pipeline
185-
186-
# Production workflows
187-
docker build --target production -t app:prod . # Security-optimized build
188-
docker-compose -f docker-compose.prod.yml up # Production testing
189-
docker-compose -f docker-compose.prod.yml --profile security up # Vulnerability scan
179+
docker-compose up # Hot reload development environment
180+
docker-compose --profile test up # Run complete test suite
181+
docker-compose --profile docs up # Documentation server (localhost:8080)
182+
docker-compose --profile quality up # Code quality checks (lint + typecheck)
183+
184+
# Build standalone image
185+
docker build -t python-template . # Build development image
190186
```
191187

192188
## 📈 Quality Metrics & Standards
193189

194190
-**100% Test Coverage** - Branch and line coverage with pytest-cov
195-
-**Security Hardened** - Distroless containers, non-root execution, vulnerability scanning
191+
-**Container Ready** - Docker development environment with hot reload and debugging
196192
-**Static Type Safety** - Complete type hints with protocol-based interfaces
197193
-**Zero Linting Issues** - Automated Ruff formatting and style enforcement
198194
-**Property-Based Testing** - Hypothesis for robust edge case validation
199195
-**Architecture Compliance** - AI-enforced SOLID principles and Object Calisthenics
200-
-**Container Security** - Minimal attack surface with read-only production filesystems
196+
-**Development Friendly** - Hot reload, debugging support, and integrated tooling
201197

202198
## 🚀 Release Management
203199

@@ -221,8 +217,8 @@ docker run your-project:latest
221217
@repo-manager /skill git-release
222218
# Example: Creates v1.2.20260411 "Secure Fortress" (Docker security improvements)
223219

224-
# Deploy with confidence
225-
docker-compose -f docker-compose.prod.yml up --detach
220+
# Run your application
221+
docker-compose up --detach
226222
```
227223

228224
## 🤝 Contributing
@@ -255,9 +251,7 @@ Standing on the shoulders of giants:
255251
- [OpenCode](https://opencode.ai) - Revolutionary AI-powered development platform
256252
- [UV](https://astral.sh/uv/) - Blazing fast Python package and project manager
257253
- [Ruff](https://astral.sh/ruff/) - Extremely fast Python linter and formatter
258-
- [Docker](https://docker.com) - Industry-standard containerization platform
259-
- [Distroless](https://github.com/GoogleContainerTools/distroless) - Google's minimal container images
260-
- [Trivy](https://trivy.dev/) - Comprehensive security scanner
254+
- [Docker](https://docker.com) - Containerization for development environment
261255
- [Hypothesis](https://hypothesis.readthedocs.io/) - Property-based testing framework
262256

263257
---

0 commit comments

Comments
 (0)