Files
runtime/apps/runner/pkg/docker/create_backup.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

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
}