mirror of
https://github.com/hanzoai/runtime.git
synced 2026-10-30 18:23:13 +00:00
- 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
29 lines
859 B
Go
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
|
|
}
|