feat: add CPU and memory resource limits per app
All checks were successful
Check / check (pull_request) Successful in 3m24s
All checks were successful
Check / check (pull_request) Successful in 3m24s
- Add cpu_limit (REAL) and memory_limit (INTEGER) columns to apps table via migration 007 - Add CPULimit and MemoryLimit fields to App model with full CRUD support - Add resource limits fields to app edit form with human-friendly memory input (e.g. 256m, 1g, 512k) - Pass CPU and memory limits to Docker container creation via NanoCPUs and Memory host config fields - Extract Docker container creation helpers (buildEnvSlice, buildMounts, buildResources) for cleaner code - Add formatMemoryBytes template function for display - Add comprehensive tests for parsing, formatting, model persistence, and container options
This commit is contained in:
@@ -114,6 +114,38 @@
|
||||
>
|
||||
</div>
|
||||
|
||||
<hr class="border-gray-200">
|
||||
|
||||
<h3 class="text-lg font-medium text-gray-900">Resource Limits</h3>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div class="form-group">
|
||||
<label for="cpu_limit" class="label">CPU Limit (cores)</label>
|
||||
<input
|
||||
type="text"
|
||||
id="cpu_limit"
|
||||
name="cpu_limit"
|
||||
value="{{if .App.CPULimit.Valid}}{{.App.CPULimit.Float64}}{{end}}"
|
||||
class="input"
|
||||
placeholder="e.g. 0.5, 1, 2"
|
||||
>
|
||||
<p class="text-sm text-gray-500 mt-1">Number of CPU cores (e.g. 0.5 = half a core)</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="memory_limit" class="label">Memory Limit</label>
|
||||
<input
|
||||
type="text"
|
||||
id="memory_limit"
|
||||
name="memory_limit"
|
||||
value="{{if .App.MemoryLimit.Valid}}{{formatMemoryBytes .App.MemoryLimit.Int64}}{{end}}"
|
||||
class="input"
|
||||
placeholder="e.g. 256m, 1g"
|
||||
>
|
||||
<p class="text-sm text-gray-500 mt-1">Memory with unit suffix (k, m, g) or plain bytes</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-3 pt-4">
|
||||
<a href="/apps/{{.App.ID}}" class="btn-secondary">Cancel</a>
|
||||
<button type="submit" class="btn-primary">Save Changes</button>
|
||||
|
||||
Reference in New Issue
Block a user