Skip to content

Commit bae7621

Browse files
authored
feat: default log size per service (#20)
1 parent 8adaa67 commit bae7621

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

docs/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ Automatically generates and manages SSL certificates for local development.
3535

3636
### Automatic Host File Updates
3737
Manages your `/etc/hosts` file automatically — no manual editing required.
38+
39+
### Sensible Defaults
40+
Applies reasonable defaults to prevent common issues. For example, container logs are automatically limited to 10MB per service to prevent disk space exhaustion.

docs/logs.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,18 @@ devbox logs service1 service2
2626
# View logs from a specific project
2727
devbox --name project-name logs
2828
```
29+
30+
## Log Size Limits
31+
32+
DevBox automatically limits container logs to **10MB per service** to prevent disk space exhaustion. This is applied to all services that don't have explicit logging configuration.
33+
34+
To override for a specific service, add a `logging` section in your `docker-compose.yaml`:
35+
36+
```yaml
37+
services:
38+
verbose-service:
39+
logging:
40+
driver: "json-file"
41+
options:
42+
max-size: "50m"
43+
```

internal/project/project.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func New(ctx context.Context, projectName string, profiles []string) (*Project,
9292
applyHosts,
9393
applyCert,
9494
setupGracePeriod,
95+
applyDefaultLogging,
9596
applyLabels,
9697
mountSourceVolumes,
9798
}
@@ -287,6 +288,24 @@ func setupGracePeriod(p *Project) error {
287288
return nil
288289
}
289290

291+
func applyDefaultLogging(p *Project) error {
292+
for name, svc := range p.Services {
293+
if svc.Logging != nil {
294+
continue
295+
}
296+
297+
svc.Logging = &types.LoggingConfig{
298+
Options: map[string]string{
299+
"max-size": "10m",
300+
"max-file": "1",
301+
},
302+
}
303+
p.Services[name] = svc
304+
}
305+
306+
return nil
307+
}
308+
290309
func applyLabels(p *Project) error {
291310
for name, s := range p.Services {
292311
s.CustomLabels = map[string]string{

0 commit comments

Comments
 (0)