Files
runtime/apps/runner/pkg/docker/resize.go
zeekay ea80dc3638 feat: Add new Dockerfiles and improve containerization
- Add main Dockerfile for production builds
- Add Dockerfile.runtime for secure code execution
- Add Dockerfile.runtime.fixed with improved configuration
- Include .dockerignore for build optimization
- Add integration documentation and publishing guides
- Update API and CLI components for better runtime support
- Enhance sandbox and container management features
2025-08-16 23:03:39 -05:00

29 lines
859 B
Go

// Copyright 2025 Hanzo Industries Inc.
// SPDX-License-Identifier: AGPL-3.0
package docker
import (
"context"
"github.com/hanzoai/runner/pkg/api/dto"
"github.com/hanzoai/runner/pkg/models/enums"
"github.com/docker/docker/api/types/container"
)
func (d *DockerClient) Resize(ctx context.Context, sandboxId string, sandboxDto dto.ResizeSandboxDTO) error {
d.cache.SetSandboxState(ctx, sandboxId, enums.SandboxStateResizing)
_, err := d.apiClient.ContainerUpdate(ctx, sandboxId, container.UpdateConfig{
Resources: container.Resources{
CPUQuota: sandboxDto.Cpu * 100000, // Convert CPU cores to quota (1 core = 100000)
CPUPeriod: 100000,
Memory: sandboxDto.Memory * 1024 * 1024 * 1024, // Convert GB to bytes
MemorySwap: sandboxDto.Memory * 1024 * 1024 * 1024, // Set swap equal to memory to disable swap
},
})
return err
}