AbpSandbox.Docker
0.2.1
dotnet add package AbpSandbox.Docker --version 0.2.1
NuGet\Install-Package AbpSandbox.Docker -Version 0.2.1
<PackageReference Include="AbpSandbox.Docker" Version="0.2.1" />
<PackageVersion Include="AbpSandbox.Docker" Version="0.2.1" />
<PackageReference Include="AbpSandbox.Docker" />
paket add AbpSandbox.Docker --version 0.2.1
#r "nuget: AbpSandbox.Docker, 0.2.1"
#:package AbpSandbox.Docker@0.2.1
#addin nuget:?package=AbpSandbox.Docker&version=0.2.1
#tool nuget:?package=AbpSandbox.Docker&version=0.2.1
AbpSandbox
Untrusted work in containers, for ABP applications on .NET 10. Unpack and check an uploaded package, run a script an agent wrote, convert a file someone brought in: in a container that has no network, a read-only root, no privileges and a user that isn't root, within limits of time, memory, CPU, processes and bytes, and that is removed when it's done.
Preview. 0.x versions may change their API in any minor version (SemVer). Pin an exact version.
Not a Volosoft project. ABP Framework is made and owned by Volosoft. AbpSandbox is an independent enhancement that works on ABP: this repository and its packages don't belong to Volosoft, and aren't affiliated with or endorsed by them.
What it does
- Runs, thrown away: a container gets files, runs one command, gives back its exit code, its output and the files asked for, and is removed whatever happened. Past its time it's killed.
- Sessions, kept: a container kept for an owner under a key (an agent's chat, say), where commands run and files go in and out between calls, until it's closed, idle too long, or past its lifetime.
- Prepared images, cached: a request may name preparation steps; the first time they run they're saved as an image, and later requests with the same base, steps, files and owner start from it.
- A warm pool, kept running: containers started ahead of need, so a run doesn't wait for one; each serves one run and is replaced, so nothing one run left reaches the next.
- The operator's rules: images are names the settings map to pinned references, never something a request or an upload chooses; limits have defaults and maxima; the sweep removes what's past its time, even another server's.
Why and how: docs/adr/0001. Coming from ABP's module template? Where ABP's layers are in this repository.
Packages
| Package | What it holds |
|---|---|
AbpSandbox.Contracts |
ISandbox, requests and results, and the provider seam (ISandboxProvider). Nothing but .NET. |
AbpSandbox |
The ABP module: the policy, runs, sessions, prepared images and the sweep. |
AbpSandbox.Docker |
The Docker provider, through the Engine API (Unix socket, Windows named pipe or TCP). |
AbpSandbox.Remote |
The base for cloud providers: a runner beside the work in each task, jobs through object storage (ADR 0002). |
AbpSandbox.Fargate |
The AWS Fargate provider: ECS tasks, jobs through S3. deploy/aws makes the closed network it needs. |
AbpSandbox.Agents |
Tools for AbpAgent: sandbox_run, sandbox_exec, sandbox_put, sandbox_get, opt-in and asking first. Depends only on AbpAgent.Contracts. |
An Azure (Container Instances) provider fits the same base, and Kubernetes comes later. Docker's containers share the server's kernel: use it for development and a host's own checks; code from strangers belongs on Fargate, whose tasks are each their own small virtual machine.
Use it
[DependsOn(typeof(AbpSandboxDockerModule))]
public class MyModule : AbpModule { }
Nothing runs until the settings name a provider (docker, fargate); a host may load several and pick by site.
ISandbox.CheckAsync says whether the sandbox can run now, and why not.
"AbpSandbox": {
"Provider": "docker",
"Images": { "alpine": "alpine:3.20@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc" },
"MaxTime": "00:05:00"
}
SandboxResult result = await sandbox.RunAsync(new SandboxRequest
{
Owner = "review:" + versionId,
Image = "alpine",
Command = ["sh", "-c", "unzip -q package.zip -d out && ls -R out"],
Files = [new("package.zip", bytes)],
});
Build and test
dotnet build and dotnet test. The Docker provider's tests run against a real engine when ABP_SANDBOX_DOCKER=1
(and ABP_SANDBOX_DOCKER_ENDPOINT for one that isn't the platform's own).
Releasing
The version is VersionPrefix and VersionSuffix in Directory.Build.props, and CHANGELOG.md needs an entry for
it. Pushing the tag v<version>, such as v0.1.0, runs the checks. GitHub Actions then pushes the packages to
nuget.org through Trusted Publishing, with no
stored key, and makes a GitHub release. Set it up once:
- On nuget.org, signed in as the account that will own the packages: Trusted Publishing, add a policy with
owner
tekthar, repositoryabp-sandbox, workflow fileci.ymland environmentrelease. - On GitHub, in the repository's Settings: an environment
release, and the Actions variableNUGET_USER, the nuget.org profile name of the account in step 1. - Release:
git tag v<version> && git push origin v<version>.
License
Apache License 2.0: see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AbpSandbox (>= 0.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.