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
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
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"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func (d *DockerClient) CreateBackup(ctx context.Context, containerId string, backupDto dto.CreateBackupDTO) error {
|
|
d.cache.SetBackupState(ctx, containerId, enums.BackupStatePending)
|
|
|
|
log.Infof("Creating backup for container %s...", containerId)
|
|
|
|
d.cache.SetBackupState(ctx, containerId, enums.BackupStateInProgress)
|
|
|
|
err := d.commitContainer(ctx, containerId, backupDto.Snapshot)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = d.PushImage(ctx, backupDto.Snapshot, &backupDto.Registry)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
d.cache.SetBackupState(ctx, containerId, enums.BackupStateCompleted)
|
|
|
|
log.Infof("Backp (%s) for container %s created successfully", backupDto.Snapshot, containerId)
|
|
|
|
err = d.RemoveImage(ctx, backupDto.Snapshot, true)
|
|
if err != nil {
|
|
log.Errorf("Error removing image %s: %v", backupDto.Snapshot, err)
|
|
}
|
|
|
|
return nil
|
|
}
|