microcoreos 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. microcoreos/__init__.py +23 -0
  2. microcoreos/_template/.agent/skills/microcoreos-architecture/SKILL.md +24 -0
  3. microcoreos/_template/.agent/skills/microcoreos-architecture/agent.md +18 -0
  4. microcoreos/_template/.agent/workflows/feature-plan.md +111 -0
  5. microcoreos/_template/.agent/workflows/multi-domain-plan.md +96 -0
  6. microcoreos/_template/.agent/workflows/new-domain.md +201 -0
  7. microcoreos/_template/.agent/workflows/new-tool.md +72 -0
  8. microcoreos/_template/.dockerignore +23 -0
  9. microcoreos/_template/.env.example +96 -0
  10. microcoreos/_template/.gitignore +57 -0
  11. microcoreos/_template/AGENTS.md +175 -0
  12. microcoreos/_template/Dockerfile +35 -0
  13. microcoreos/_template/INSTRUCTIONS_FOR_AI.md +560 -0
  14. microcoreos/_template/dev_infra/cache_probe.py +176 -0
  15. microcoreos/_template/dev_infra/docker-compose.yml +137 -0
  16. microcoreos/_template/docs/CLI.md +187 -0
  17. microcoreos/_template/docs/CORE_INFRASTRUCTURE.md +372 -0
  18. microcoreos/_template/docs/ELASTIC_DEPLOYMENT.md +277 -0
  19. microcoreos/_template/docs/EVENT_BUS.md +288 -0
  20. microcoreos/_template/docs/HTTP_SERVER.md +98 -0
  21. microcoreos/_template/docs/INDEX.md +41 -0
  22. microcoreos/_template/docs/OBSERVABILITY.md +56 -0
  23. microcoreos/_template/docs/OBSERVABILITY_API.md +183 -0
  24. microcoreos/_template/docs/PARALLEL_DEVELOPMENT.md +494 -0
  25. microcoreos/_template/docs/PLAN_EVENT_LINTER.md +95 -0
  26. microcoreos/_template/docs/TECH_DEBT.md +388 -0
  27. microcoreos/_template/docs/translations/es/README.md +265 -0
  28. microcoreos/_template/domains/devtools/lint/plugin_sources.py +51 -0
  29. microcoreos/_template/domains/devtools/plugins/discovery_naming_linter_plugin.py +89 -0
  30. microcoreos/_template/domains/devtools/plugins/domain_isolation_linter_plugin.py +80 -0
  31. microcoreos/_template/domains/devtools/plugins/event_contract_linter_plugin.py +420 -0
  32. microcoreos/_template/domains/devtools/plugins/event_schemas_plugin.py +94 -0
  33. microcoreos/_template/domains/devtools/plugins/field_divergence_linter_plugin.py +178 -0
  34. microcoreos/_template/domains/devtools/plugins/plan_validator_plugin.py +581 -0
  35. microcoreos/_template/domains/devtools/plugins/route_collision_linter_plugin.py +51 -0
  36. microcoreos/_template/domains/devtools/plugins/table_ownership_linter_plugin.py +66 -0
  37. microcoreos/_template/domains/devtools/plugins/tool_doc_drift_linter_plugin.py +74 -0
  38. microcoreos/_template/domains/system/plugins/event_delivery_monitor_plugin.py +53 -0
  39. microcoreos/_template/domains/system/plugins/system_events_plugin.py +132 -0
  40. microcoreos/_template/domains/system/plugins/system_events_stream_plugin.py +46 -0
  41. microcoreos/_template/domains/system/plugins/system_logs_stream_plugin.py +47 -0
  42. microcoreos/_template/domains/system/plugins/system_metrics_plugin.py +85 -0
  43. microcoreos/_template/domains/system/plugins/system_status_plugin.py +66 -0
  44. microcoreos/_template/domains/system/plugins/system_traces_plugin.py +128 -0
  45. microcoreos/_template/domains/system/plugins/system_traces_stream_plugin.py +121 -0
  46. microcoreos/_template/domains/system/plugins/tool_health_plugin.py +53 -0
  47. microcoreos/_template/extras/available_domains/chaos/plugins/blocking_boot_plugin.py +19 -0
  48. microcoreos/_template/extras/available_domains/chaos/plugins/chaos_control_plugin.py +625 -0
  49. microcoreos/_template/extras/available_domains/chaos/plugins/failing_plugin.py +27 -0
  50. microcoreos/_template/extras/available_domains/chaos/plugins/stress_plugin.py +40 -0
  51. microcoreos/_template/extras/available_domains/ping/plugins/ping_plugin.py +36 -0
  52. microcoreos/_template/extras/available_domains/scheduler/migrations/001_scheduler_one_shots.sql +8 -0
  53. microcoreos/_template/extras/available_domains/scheduler/models/scheduler_one_shot.py +15 -0
  54. microcoreos/_template/extras/available_domains/scheduler/plugins/durable_one_shots_plugin.py +125 -0
  55. microcoreos/_template/extras/available_domains/users/migrations/001_create_users.sql +12 -0
  56. microcoreos/_template/extras/available_domains/users/models/user.py +31 -0
  57. microcoreos/_template/extras/available_domains/users/plugins/create_user_plugin.py +89 -0
  58. microcoreos/_template/extras/available_domains/users/plugins/get_me_plugin.py +63 -0
  59. microcoreos/_template/extras/available_domains/users/plugins/login_plugin.py +107 -0
  60. microcoreos/_template/extras/available_domains/users/plugins/logout_plugin.py +26 -0
  61. microcoreos/_template/extras/available_tools/auth/auth_tool.py +132 -0
  62. microcoreos/_template/extras/available_tools/chaos/chaos_tool.py +32 -0
  63. microcoreos/_template/extras/available_tools/kafka/kafka_driver.py +452 -0
  64. microcoreos/_template/extras/available_tools/postgresql/postgresql_tool.py +882 -0
  65. microcoreos/_template/extras/available_tools/rabbitmq/rabbitmq_driver.py +303 -0
  66. microcoreos/_template/extras/available_tools/redis_state/redis_state_tool.py +253 -0
  67. microcoreos/_template/extras/available_tools/s3/__init__.py +0 -0
  68. microcoreos/_template/extras/available_tools/s3/s3_tool.py +426 -0
  69. microcoreos/_template/extras/available_tools/scheduler/scheduler_tool.py +328 -0
  70. microcoreos/_template/main.py +9 -0
  71. microcoreos/_template/plans/PILOT.md +99 -0
  72. microcoreos/_template/plans/README.md +236 -0
  73. microcoreos/_template/plans/active_plan.md +25 -0
  74. microcoreos/_template/plans/active_plan.yaml +43 -0
  75. microcoreos/_template/tools/config/config_tool.py +110 -0
  76. microcoreos/_template/tools/context/authoring_guide.md +305 -0
  77. microcoreos/_template/tools/context/context_tool.py +161 -0
  78. microcoreos/_template/tools/context/renderers.py +118 -0
  79. microcoreos/_template/tools/context/scanners.py +267 -0
  80. microcoreos/_template/tools/event_bus/drivers.py +108 -0
  81. microcoreos/_template/tools/event_bus/envelope.py +55 -0
  82. microcoreos/_template/tools/event_bus/event_bus_tool.py +506 -0
  83. microcoreos/_template/tools/event_bus/redis_streams_driver.py +300 -0
  84. microcoreos/_template/tools/event_bus/sqlite_driver.py +316 -0
  85. microcoreos/_template/tools/http_server/context.py +120 -0
  86. microcoreos/_template/tools/http_server/http_server_tool.py +558 -0
  87. microcoreos/_template/tools/http_server/pipeline.py +267 -0
  88. microcoreos/_template/tools/logger/logger_tool.py +96 -0
  89. microcoreos/_template/tools/sqlite/errors.py +152 -0
  90. microcoreos/_template/tools/sqlite/migrations.py +140 -0
  91. microcoreos/_template/tools/sqlite/sqlite_tool.py +591 -0
  92. microcoreos/_template/tools/sqlite/transaction.py +189 -0
  93. microcoreos/_template/tools/state/state_tool.py +173 -0
  94. microcoreos/_template/tools/system/registry_tool.py +90 -0
  95. microcoreos/_template/tools/telemetry/__init__.py +0 -0
  96. microcoreos/_template/tools/telemetry/telemetry_tool.py +143 -0
  97. microcoreos/base_plugin.py +20 -0
  98. microcoreos/base_tool.py +48 -0
  99. microcoreos/catalog.py +268 -0
  100. microcoreos/cli.py +206 -0
  101. microcoreos/container.py +222 -0
  102. microcoreos/context.py +6 -0
  103. microcoreos/kernel.py +223 -0
  104. microcoreos/project_readme.md +107 -0
  105. microcoreos/registry.py +53 -0
  106. microcoreos/scaffold.py +218 -0
  107. microcoreos/upgrade.py +547 -0
  108. microcoreos-0.1.0.dist-info/METADATA +366 -0
  109. microcoreos-0.1.0.dist-info/RECORD +112 -0
  110. microcoreos-0.1.0.dist-info/WHEEL +4 -0
  111. microcoreos-0.1.0.dist-info/entry_points.txt +2 -0
  112. microcoreos-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,57 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ env/
8
+ build/
9
+ develop-eggs/
10
+ dist/
11
+ downloads/
12
+ eggs/
13
+ .eggs/
14
+ lib/
15
+ lib64/
16
+ parts/
17
+ sdist/
18
+ var/
19
+ wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+
24
+ # Virtual Environments
25
+ .venv/
26
+ venv/
27
+ ENV/
28
+
29
+ # Environment variables
30
+ .env
31
+
32
+ # Database
33
+ *.db
34
+ *.db-shm
35
+ *.db-wal
36
+ *.db-journal
37
+ *.sqlite3
38
+
39
+ # Logs and temporary files
40
+ *.log
41
+ doc_update*.log
42
+ verification*.log
43
+ *.txt
44
+
45
+ # OS files
46
+ .DS_Store
47
+ Thumbs.db
48
+
49
+ # Stray Node.js artifacts (this is a Python project โ€” these should never
50
+ # appear here; ignored defensively in case a tool/agent creates them again)
51
+ node_modules/
52
+ package-lock.json
53
+
54
+ # Leftover git worktrees from agent sessions. One of these was once committed
55
+ # as a submodule with no .gitmodules, and every checkout since failed its
56
+ # cleanup step with exit 128.
57
+ .claude/worktrees/
@@ -0,0 +1,175 @@
1
+ # MicroCoreOS โ€” AI Agent & Architecture Guide
2
+
3
+ This file is the single, absolute entry point for any AI agent (Gemini, Claude, GPT, etc.) working in this codebase. All development must strictly adhere to these principles to maintain the integrity of the Elastic Monolith.
4
+
5
+ ---
6
+
7
+ ## ๐Ÿ“– Reading Path (minimize token usage)
8
+
9
+ 1. **`plans/active_plan.md`** โ€” The checklist for your assigned task (the formal contract lives in `plans/active_plan.yaml`).
10
+ 2. **`AI_CONTEXT.md`** โ€” Contains the live inventory of active tools (with exact signatures) and domain tables/endpoints. **Read only the tools and tables you need.**
11
+ 3. **`domains/{domain}/models/{name}.py`** โ€” Entity model (DB mirror). *Advisory: Table structures are already mirrored in AI_CONTEXT.md.*
12
+ 4. **`INSTRUCTIONS_FOR_AI.md`** โ€” Read ONLY for advanced tasks (building new tools, testing in-depth, or changing kernel internals).
13
+ 5. **`docs/TECH_DEBT.md`** โ€” What is knowingly unfinished and what it would cost to finish. Read ONLY when scoping work that might overlap an open item.
14
+
15
+ ---
16
+
17
+ ## ๐Ÿงญ Pick the Right Workflow (scale ladder)
18
+
19
+ Match the request to its workflow BEFORE planning. Over-planning a small
20
+ request is a failure mode: **a plan must be proportional to its request**
21
+ (see "Plan sizing" in `docs/PARALLEL_DEVELOPMENT.md`).
22
+
23
+ | Request | Workflow | Expected plan size |
24
+ |---|---|---|
25
+ | Plugin(s) on an EXISTING domain | `.agent/workflows/feature-plan.md` | Mini-plan, ~10-15 YAML lines per plugin, no `phase_0` |
26
+ | ONE new domain (e.g. a few CRUDs) | `.agent/workflows/new-domain.md` | ~80-120 YAML lines, one pass |
27
+ | Several domains / cross-domain event chains | `.agent/workflows/multi-domain-plan.md` | Full formal plan |
28
+ | New infrastructure tool (or replacement) | `.agent/workflows/new-tool.md` | No YAML plan โ€” contract header + parity suite |
29
+
30
+ Omit every plan section that would be empty: no new tables โ†’ no `phase_0`;
31
+ no events โ†’ no `flows`. A CRUD-only plan has `features:` and nothing else.
32
+
33
+ ---
34
+
35
+ ## ๐Ÿ’ป Commands
36
+
37
+ ```bash
38
+ uv run main.py # Run the app (also regenerates AI_CONTEXT.md)
39
+ microcoreos # Same, if you installed the package (or: microcoreos run)
40
+ uv run -m pytest # Run all tests (always -m: the pytest binary is not exposed)
41
+ uv run -m pytest tests/test_file.py # Run a single test
42
+ docker compose -f dev_infra/docker-compose.yml up -d # Start dev infrastructure (PostgreSQL)
43
+ ```
44
+
45
+ ---
46
+
47
+ ## ๐Ÿ›ก๏ธ Non-Negotiable Rules
48
+
49
+ 1. **Never modify `main.py`** โ€” The Kernel auto-discovers everything.
50
+ 2. **1 file = 1 feature** โ€” Each plugin lives in `domains/{domain}/plugins/{feature}_plugin.py`.
51
+ 3. **No Framework Abstractions** โ€” No Routers, Controllers, or Services. Only Tools (infrastructure) and Plugins (business logic).
52
+ 4. **DI by parameter name** โ€” `__init__(self, http, db, logger)` injects tools named `http`, `db`, `logger`. No hardcoded imports.
53
+ 5. **Schemas inline** โ€” Request, response, and event payload schemas go at the top of the plugin file, never in `models/`.
54
+ 6. **No cross-domain imports** โ€” Domains communicate ONLY through the `event_bus`.
55
+ 7. **Return envelope** โ€” `{"success": bool, "data": ..., "error": ...}`: `success` always present, `data` on success, `error` on failure. Responses serialize **as-is** โ€” `response_model` does NOT backfill omitted keys, so an omitted key is absent from the JSON and consumers must never assume it exists.
56
+ 8. **SQL Placeholders & Verbatim Migrations** โ€” Always `$1, $2, $3...` (PostgreSQL style; SQLite converts internally). Migration SQL runs **verbatim** on the active engine (no dialect translation). Engine-specific SQL is a valid choice โ€” it commits you to that engine; portable SQL (e.g. `CURRENT_TIMESTAMP`, not `NOW()`) keeps the SQLiteโ†”PostgreSQL swap free. Either way, the swap includes a review pass (ELASTIC_DEPLOYMENT.md, Stage 1).
57
+ 9. **Event Envelope Contract** โ€” Subscribers receive `EventEnvelope` objects, not raw dicts. Access payload data via `event.payload`.
58
+ 10. **Typed Event Payloads** โ€” Define `XxxPayload(BaseModel)` in the PUBLISHER plugin and publish using `XxxPayload(...).model_dump()` (bare call, no args). Consumers must never import it; they declare their own model with only the fields they read (tolerant reader).
59
+ 11. **Protected Endpoints**: Pass `auth_validator=self.auth.validate_token` to `add_endpoint` for non-public routes. Check ownership via `data["_auth"]["sub"]` inside the handler.
60
+ 12. **CSRF Guard & Cookie Security**: HTTP mutations (POST/PUT/DELETE) using cookie auth require the `X-Requested-With` header. Cookies set via `context.set_cookie` default to `Secure=True`, `HttpOnly=True`, `SameSite=Lax`.
61
+ 13. **Core uses `print()`, not the logger** โ€” Core modules must not depend on the logging tool.
62
+
63
+ ---
64
+
65
+ ## โš–๏ธ Core Architectural Laws
66
+
67
+ ### The "No Hidden Magic" Rule (Kernel Level)
68
+ The Kernel (ToolProxy & Container) is infrastructure-blind:
69
+ 1. **NO Kernel Retries**: `ToolProxy` is forbidden from automatically retrying failed tool calls. Automatic, blind retries at the kernel level lead to non-idempotent operation duplicates (e.g., double payments, duplicate database records).
70
+ 2. **Explicit Resilience**: Resilience and idempotency are handled at the Tool level (connection pooling/locks) or Plugin level (business logic retry/compensation).
71
+ 3. **Reactive Health**: `ToolProxy` marks tools as `DEAD` reactively (immediately if `ToolUnavailableError` is raised, or after 5 consecutive failures). Success resets the status to `OK`.
72
+
73
+ ### Event Bus Mandates
74
+ 1. **Universal Envelope**: All messages travel inside `EventEnvelope` objects. Emitters publish standard dicts; subscribers receive the full envelope.
75
+ 2. **Decoupled Publication**: `publish()` is strictly fire-and-forget. Emitters must never know who consumes the event or when.
76
+ 3. **Idempotency by Design**: Since durable transports re-deliver events after a crash (at-least-once), all event subscribers must be designed as idempotent.
77
+
78
+ ### Security & Integrity
79
+ 1. **Safe Error Reporting**: Never return raw exception strings (`str(e)`) to the client to prevent leak of paths, SQL structure, or keys. Log technical errors internally; return generic messages ("Database error") to the external client.
80
+ 2. **Stateless JWT Logout**: By default, logout clears the cookie. JWTs remain valid until expiration. For critical revocation, use the `state` tool as a denylist.
81
+
82
+ ---
83
+
84
+ ## ๐Ÿ”„ Batch Parallel Execution Workflow (Coordinator Guidelines)
85
+
86
+ The canonical methodology (and its phase numbering) is `docs/PARALLEL_DEVELOPMENT.md`.
87
+ This is the coordinator's operational summary:
88
+
89
+ 1. **Phase 1 โ€” The Plan (contract)**: The formal YAML plan lives in `plans/active_plan.yaml`; the execution checklist (all tasks `[ ]`) in `plans/active_plan.md`. Validate with `POST /system/plan/validate` โ€” **zero `errors` before anything else runs**. An invalid plan is fixed in the plan, never patched in code.
90
+ 2. **Phase 0 โ€” Foundation (Serial)**: Write the tools (if any), then all domain models and SQL migrations sequentially, exactly as the plan's `columns:` declare them. Run `uv run main.py --boot-tool db` (or `microcoreos run --boot-tool db` if installed) to migrate and regenerate `AI_CONTEXT.md`.
91
+ 3. **Phase 2 โ€” Parallel Write Wave**: Spawn N subagents (one per plugin), each with the **canonical executor prompt**: a byte-identical shared prefix (`AI_CONTEXT.md` โ†’ `plans/active_plan.yaml`, in that order โ€” the manifest embeds the executor rules and templates as its "Plugin Authoring Guide" section) followed by ONE per-agent line at the end ("Implement feature `<PluginName>` from the plan above"). Subagents never open the plan or `AI_CONTEXT.md` themselves โ€” dispatch them **write-only, scoped to their two files** (write capability restricted to the exact paths the plan declares for the task โ€” `file:` + `test:`, or the flow's two test paths; no read/search/shell tools): the prefix is self-sufficient by construction (one complete template per deliverable type in `AI_CONTEXT.md` ยง Authoring Templates), so reading capability only invites redundant verification and guessed paths. The identical prefix lets any engine with prefix caching (local KV cache, hosted prompt caching) process the shared block once and reuse it for the whole wave โ€” dispatch the first agent, let it start responding, then fire the rest. Each agent writes exactly two files: its plugin and its unit test.
92
+ 4. **Phase 3 โ€” Bulk Verification**: Once all subagents finish writing, run the entire test suite in a single execution (`uv run -m pytest`), then boot and check `GET /system/lint`.
93
+ 5. **Cleanup & Reconstruct**:
94
+ * For passing plugins: Mark their checkbox as `[x]` in `plans/active_plan.md`.
95
+ * For failing plugins: **Delete** the created plugin and unit test files, keep their checkbox as `[ ]`, and spawn a new wave of clean agents to rewrite them from scratch.
96
+ * Repeat until all checkboxes are `[x]`.
97
+
98
+ ---
99
+
100
+ ## โšก Minimal Plugin Template
101
+
102
+ ```python
103
+ from typing import Optional
104
+ from pydantic import BaseModel, Field
105
+ from microcoreos import BasePlugin
106
+
107
+ class CreateThingRequest(BaseModel):
108
+ name: str = Field(min_length=1, max_length=100)
109
+
110
+ class ThingData(BaseModel):
111
+ id: int
112
+ name: str
113
+
114
+ class CreateThingResponse(BaseModel):
115
+ success: bool
116
+ data: Optional[ThingData] = None
117
+ error: Optional[str] = None
118
+
119
+ class CreateThingPlugin(BasePlugin):
120
+ def __init__(self, http, db, logger):
121
+ self.http = http
122
+ self.db = db
123
+ self.logger = logger
124
+
125
+ async def on_boot(self):
126
+ self.http.add_endpoint("/things", "POST", self.execute,
127
+ tags=["Things"], request_model=CreateThingRequest,
128
+ response_model=CreateThingResponse)
129
+
130
+ async def execute(self, data: dict, context=None):
131
+ try:
132
+ req = CreateThingRequest(**data)
133
+ new_id = await self.db.execute(
134
+ "INSERT INTO things (name) VALUES ($1) RETURNING id", [req.name]
135
+ )
136
+ return {"success": True, "data": {"id": new_id, "name": req.name}}
137
+ except Exception as e:
138
+ self.logger.error(f"Failed to create thing: {e}")
139
+ return {"success": False, "error": "Database error"}
140
+ ```
141
+
142
+ ---
143
+
144
+ ## ๐Ÿ”Ž Where to Find Examples
145
+
146
+ When writing a new feature, read these specific files under demand to copy their syntax:
147
+
148
+ | Pattern | File |
149
+ |---|---|
150
+ | **CRUD + Event Bus** | `extras/available_domains/users/plugins/create_user_plugin.py` |
151
+ | **Protected Endpoint (JWT)** | `extras/available_domains/users/plugins/get_me_plugin.py` |
152
+ | **Auth, Cookies & Session** | `extras/available_domains/users/plugins/login_plugin.py` |
153
+ | **Minimal Plugin (No DB)** | `extras/available_domains/ping/plugins/ping_plugin.py` |
154
+ | **Database Migrations** | `extras/available_domains/users/migrations/001_create_users.sql` |
155
+ | **Dynamic Introspection** | `domains/system/plugins/system_status_plugin.py` |
156
+ | **Black-Box Integration Tests** | `tests/domains/users/test_login_plugin.py` |
157
+
158
+ Both point into `extras/` because both are extras: readable in any project,
159
+ and `microcoreos add auth` / `add ping` is what moves them into `domains/`.
160
+ Reading them needs no install โ€” the files are there either way.
161
+
162
+ ---
163
+
164
+ ## ๐Ÿ”ง Common Infrastructure Operations
165
+
166
+ When tasked with infrastructure changes, read the specific guide in `docs/ELASTIC_DEPLOYMENT.md`:
167
+
168
+ | Operation | Guide Section |
169
+ |---|---|
170
+ | **Swap SQLite to PostgreSQL** | [ELASTIC_DEPLOYMENT.md (Stage 1)](file:///home/anibalos/Documents/Original/MicroCoreOS/docs/ELASTIC_DEPLOYMENT.md#L25-L90) |
171
+ | **Swap In-Memory State to Redis** | [ELASTIC_DEPLOYMENT.md (Section 2.1)](file:///home/anibalos/Documents/Original/MicroCoreOS/docs/ELASTIC_DEPLOYMENT.md#L98-L116) |
172
+ | **Scale Event Bus to Redis Streams** | [ELASTIC_DEPLOYMENT.md (Section 2.2)](file:///home/anibalos/Documents/Original/MicroCoreOS/docs/ELASTIC_DEPLOYMENT.md#L117-L141) |
173
+ | **Disable/Configure Scheduler on Replicas** | [ELASTIC_DEPLOYMENT.md (Section 2.3)](file:///home/anibalos/Documents/Original/MicroCoreOS/docs/ELASTIC_DEPLOYMENT.md#L142-L160) |
174
+ | **Production DB Migrations Pipeline** | [ELASTIC_DEPLOYMENT.md (Section 2.4)](file:///home/anibalos/Documents/Original/MicroCoreOS/docs/ELASTIC_DEPLOYMENT.md#L161-L177) |
175
+
@@ -0,0 +1,35 @@
1
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
2
+ # MicroCoreOS โ€” Production Dockerfile
3
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
4
+ #
5
+ # Build:
6
+ # docker build -t microcoreos .
7
+ #
8
+ # Run:
9
+ # docker run -p 5000:5000 --env-file .env microcoreos
10
+ #
11
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
12
+
13
+ FROM python:3.12-slim
14
+
15
+ # โ”€โ”€ uv (fast Python package manager) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
16
+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
17
+
18
+ WORKDIR /app
19
+
20
+ # โ”€โ”€ Dependencies (cached layer โ€” only rebuilds when lock file changes) โ”€โ”€
21
+ COPY pyproject.toml uv.lock ./
22
+ RUN uv sync --no-dev --frozen
23
+
24
+ # โ”€โ”€ Application source โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
25
+ COPY . .
26
+
27
+ # โ”€โ”€ Production defaults โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
28
+ # HTTP_HOST must be 0.0.0.0 in a container โ€” otherwise the server only
29
+ # listens on loopback and no external requests can reach it.
30
+ ENV HTTP_HOST=0.0.0.0
31
+ ENV HTTP_PORT=5000
32
+
33
+ EXPOSE 5000
34
+
35
+ CMD ["uv", "run", "main.py"]