Commit Graph
107 Commits
Author SHA1 Message Date
Dmitry Kovba 5da0125228 Redirect to the documentation from the homepage (#159)
This PR fixes the homepage at https://apple.github.io/containerization/
2025-06-23 10:19:16 -07:00
Satyam Singh 22f2efd8d1 fix: correct release condition in GitHub Actions and globalize enviro… (#127)
# Refactor GitHub Actions Workflow: Containerization Build
## 🛠 Summary
This PR introduces several important improvements and cleanups to the
build-containerization-template GitHub Actions workflow for better
maintainability, correctness, and readability.

### 🔧 Changes Made
#### 1.  Fix invalid conditional syntax
- **!= is not supported in expressions** with **if**: in GitHub Actions.

- Only logical operators like !, &&, || are valid.

#### 2.  Globalized environment variables
- Moved CURRENT_SDK and DEVELOPER_DIR to the job-level env: block to:

- Avoid redundancy across steps

- Make the workflow more maintainable

### 3.  Replaced `secrets.GITHUB_TOKEN` with `github.token`
- Prefer github.token for GitHub-provided auth token to improve clarity
and scoping.

@katiewasnothere
2025-06-23 09:26:50 -07:00
Dmitry Kovba a339606068 Fix the Swiftly bin path (#158)
This PR resolves the following error for new users:

```
% make cross-prep
Installing Swiftly...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 8549k  100 8549k    0     0  14.7M      0 --:--:-- --:--:-- --:--:-- 14.8M
installer: Package name is 
installer: Installing at base path /Users/Dmitry
installer: The install was successful.
Welcome to swiftly, the Swift toolchain manager for Linux and macOS!

Please read the following information carefully before proceeding with the installation. If you
wish to customize the steps performed during the installation process, refer to 'swiftly init -h'
for configuration options.

Swiftly installs files into the following locations:

/Users/Dmitry/.swiftly - Directory for configuration files
/Users/Dmitry/.swiftly/bin - Links to the binaries of the active toolchain
/Users/Dmitry/Library/Developer/Toolchains - Directory hosting installed toolchains

These locations can be changed by setting the environment variables
SWIFTLY_HOME_DIR, SWIFTLY_BIN_DIR, and SWIFTLY_TOOLCHAINS_DIR before running 'swiftly init' again.

For your convenience, swiftly will also attempt to modify your shell's profile file to make
installed items available in your environment upon login. This can be suppressed with the
'--no-modify-profile' option.

Proceed? (Y/n): 

Installing swiftly in /Users/Dmitry/.swiftly/bin/swiftly...
Error: The file “swiftly” couldn’t be opened because there is no such file.
make[1]: *** [swiftly] Error 1
make: *** [cross-prep] Error 2
```
2025-06-20 20:02:23 -07:00
Aditya Ramani 016c80fac0 Better parsing for www-authenticate headers (#155)
There was a bug where the `www-authenticate` header in the HTTP response
from a registry would not be parsed accurately.

Specifically, if the header value had more than one `<space>` character,
the entire header would be ignored. This PR fixes this bug and adds unit
test to detect this in the future.


Fixes https://github.com/apple/container/issues/240
And most likely fixes https://github.com/apple/container/issues/237

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-20 15:51:47 -07:00
Cornelius Roemer cad00de874 Fix typo in README (#54) 2025-06-18 17:31:58 -07:00
Danny Canter 2a96a0d447 Containerization: Always set TERM (#146)
Make sure we always set TERM for containers that ask for a tty. Right
now this handling was spread around in a bunch of spots, but I'd wager
setting it for the client on the host via LinuxContainer/Process is more
sane and already what we do for a lot of the other fields.
2025-06-18 17:00:00 -07:00
Danny Canter 1992cfe779 Containerization: Reduce allocations for image subsystems (#152)
Continue the allocations journey for anything that is in the codepaths
for pulling images. This time there's a couple spots in archive and ext4
we can get rid of some copies.
2025-06-18 16:11:46 -07:00
Nandha Reddy 35a821f041 fix: vminitd incorrectly overwrites custom HOME environment variable (#136)
## Summary

The vminitd service was using `process.env.contains("HOME")` which
checks for exact string match rather than environment variables starting
with "HOME=".

Since environment variables are stored as `"KEY=value"` strings, the
condition was always false, causing vminitd to always override custom
HOME values even when explicitly provided by the client.

## Changes

- Updates the logic in `vminitd/Sources/vminitd/Server+GRPC.swift` to
use `contains(where: { $0.hasPrefix("HOME=") })` to properly detect
existing HOME environment variables
- Adds regression test `testProcessCustomHomeEnvvar()` to verify that
custom HOME environment variables are preserved when provided by the
client

## Testing

The fix has been tested with the new integration test that:
  - Sets a custom HOME environment variable (`HOME=/tmp/custom/home`)
- Runs a shell command that outputs the HOME variable on the container
runtime
- Verifies the custom HOME value is preserved and not overwritten with
the default

## Environment

  - macOS: 26.0 (25A5279m)
  - Hardware: M4 Pro
  - Xcode: 26 beta
  - Swift: 6.2-dev

Fixes #135
2025-06-17 21:51:11 -07:00
Joseph Heck 445450dcce limits buildAndTest to Apple repository (#150)
Constrains the buildAndTest job to only run on the
`apple/containerization` repository due to Runner constraints.

Simplest solution - fixes #132
2025-06-17 14:20:20 -07:00
Alexey Makhov 689af841d6 Sort keys in image index to keep the digest consistent (#149)
The digest is calculated based on written json data, but JSONEncoder
doesn't preserve order bby default, so the digest is not consistent.

Signed-off-by: Alexey <makhov.alex@gmail.com>
2025-06-17 12:23:25 -07:00
Alexey Makhov 4a196b6dc2 Adds some context to fetchToken errors (#129)
Fixes https://github.com/apple/container/issues/182 and
https://github.com/apple/container/issues/183

Signed-off-by: Alexey <makhov.alex@gmail.com>
2025-06-17 08:26:46 -07:00
Riya Amemiya 4a482a00c0 Fix typos in README and LinuxContainer.swift comments (#144)
## Changes 

### README.md

- Fixed grammatical error: "when a process is ran" → "when a process is
run"
- Fixed plural form: "for instruction on" → "for instructions on"

### kernel/README.md

- Fixed numbering sequence: "4. Run `make`" → "3. Run `make`" in build
instructions

### Sources/Containerization/LinuxContainer.swift

- Fixed grammatical error in comment: "The container has ran" → "The
container has run"
2025-06-17 02:40:05 -07:00
Danny Canter 328221e44c ContainerizationOCI: Cut down on allocations (#141)
We were doing intermediate step copies to Data objects both for push and
pull. We only need the data for the lifetime of the singular writes to
update the state of the checksums and to write to disk somewhere, so we
can use a view into the buffer from the http client to satisfy this.
2025-06-16 22:18:36 -07:00
Danny Canter 5a360242d3 Fix make release goal (#140)
We were using a := assignment for BUILD_BIN_DIR which evaluates any
variables immediately. Our make release logic sets the envvar and then
invokes `all` but at that point the value of BUILD_BIN_DIR has already
been determined.
2025-06-16 17:40:25 -07:00
Dmitry Kovba b14395515c Fix warnings in make docs (#139)
This PR also has additional small improvements.
2025-06-16 17:22:22 -07:00
Josh Soref c00ede68c1 fix comment misspellings (#131)
This PR corrects misspellings identified by the [check-spelling
action](https://github.com/marketplace/actions/check-spelling)

The misspellings have been reported at
https://github.com/jsoref/containerization/actions/runs/15662940240/attempts/1#summary-44123291170
The action reports that the changes in this PR would make it happy:
https://github.com/jsoref/containerization/actions/runs/15662940315/attempts/1#summary-44123291367

---------

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2025-06-16 16:06:37 -04:00
Aditya Ramani f4177e7d67 More informative errors from RegistryClient (#134)
Also creates an `ErrorResponse` type to model the errors typically
returned by a container registry.

Reference: https://distribution.github.io/distribution/spec/api/#errors

Example error message:
```
Error: HTTP request to https://ghcr.io/token?client_id=containerization-registry-client&service=ghcr.io&scope=repository:user/image:pull failed with response: 403 Forbidden. Reason: {"errors":[{"message":"requested access to the resource is denied","code":"DENIED"}]}
```

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-16 11:07:32 -07:00
Danny Canter 77c54434b8 LinuxProcess: Always return CZError (#111)
We should return our own error type always for our methods. This wraps
all of the public methods on the process to return a more full featured
error than the rpcerrors we get today.
2025-06-16 13:40:36 -04:00
Dmitry Kovba a65deb517a Add instructions for installing Xcode (#125)
Now, we require installing Xcode 26 beta. This PRs adds an important
step of setting the active developer directory. Fixes
https://github.com/apple/containerization/issues/119.
2025-06-16 09:23:34 -07:00
Danny Canter 3cf8eeebf4 SandboxContext: Remove AttachProcessRequest/Response (#121)
These were not used in any rpcs and were a leftover idea.
2025-06-13 21:56:54 -07:00
Danny Canter 8923495949 Vminitd: Remove unneeded mkdir (#123)
The rootfs should be mounted by this point in oci alteration code.
2025-06-13 21:56:25 -07:00
Dmitry Kovba a3cb1f0103 Update to Swift 6.2 and Swift 6.2-snapshot in vminitd (#94)
This PR resolves https://github.com/apple/containerization/issues/58 and
https://github.com/apple/containerization/issues/119. Requires updating
Swift and Static Linux SDK on GitHub runners. Please also see
https://github.com/apple/container/pull/195.
2025-06-13 17:46:30 -07:00
Kathryn Baldauf 4751d073bb Improve release tag regex (#122)
Matches changes made in https://github.com/apple/container/pull/187 by
@Thedarkmatter10

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-13 14:45:16 -07:00
Seyed Mojtaba Hosseini Zeidabadi 763141633c build: extend the swift-syntax version range (#97)
Building Swift-Syntax can be time-consuming, but this issue has been
resolved in the latest version by using a prebuilt binary. This
improvement enhances CI build times and the overall quality of the
package.

I’ve kept the version at 600 for compatibility reasons, but it might be
possible to start from 601 as well.
Please let me know.
Thanks
2025-06-13 11:20:50 -07:00
Kathryn Baldauf 4300595d03 Add fallback year or hawkeye formatting if no git attributes (#120)
Matches https://github.com/apple/container/pull/180

This adds a default year to use when a file does not yet have git
attributes (aka for a newly created file).

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-13 09:55:37 -07:00
Dmitry Kovba 256daaf481 Update issue templates (#114)
Please see commits for the list of changes.
2025-06-13 09:10:43 -07:00
Aditya Ramani a4a0cdfae1 Add a way to detect if a process' io has completed (#110)
This change adds a new private method `waitIoComplete` on the
`LinuxProcess` type.

This method is called internally when the user calls `wait` for a
process - and it tries to give the IO streams some time to clear their
buffers.

Internally, this method sets up an `AsyncStream` down which an item is
sent when the vsock connection for either stdout/stderr is terminated.
We get this termination signal when the readability handler for the
associated fd fires with a no available data.

Inside the guest - once we are done relaying the IO from the process
into the socket connection, we close the socket fd which triggers the
above.

All this logic is wrapped around a timeout of 3 seconds, just to ensure
the method does not block forever.

---------

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-13 11:23:41 -04:00
Danny Canter a56fdb7046 LinuxContainer: Remove extraneous extensions (#117)
Not sure why we had this type in 12 different sections 😅.
2025-06-13 10:14:19 -04:00
Danny Canter 90dfc9d90e EXT4: Adjustments to file names and visibilities (#112)
- FileTimestamps constructor that actually let you provide values was
not public, so it wasn't possible to pass in values other than nil. This
change makes the other constructor and the underlying fields public.
- Rename EXT4+Format to EXT4+Formatter
- Rename EXT4+Export to EXT4Reader+Export
- Make the superblock publicly accessible in the reader like the docs
for the product states.
2025-06-12 23:32:45 -07:00
Kathryn Baldauf 6d9e4b9c4d Add issue template for containerization (#102)
Matches templates made in container here
https://github.com/apple/container/pull/152.

Points questions to the container Discussions.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-12 15:18:06 -04:00
Danny Canter 28199a7d9e Add Swift Package Index docs publishing (#107) 2025-06-12 15:16:34 -04:00
Danny Canter 4f3622a4e5 cctl: Use AsyncSignalHandler for sigwinch (#105)
We already have a type that does what the setupSigwinchHandler method
was doing.
2025-06-12 10:38:34 -04:00
Danny Canter 0f18608f0e gitignore: Remove editor specific git ignore rules (#106)
These truthfully should be up to users to maintain, as trying to add
everyones editor of choice config directories here isn't ideal.

This additionally adds a section in contributing on the new stance.
2025-06-12 10:37:59 -04:00
Danny Canter b39f132510 Vminitd: Always parse /etc/passwd (#104)
Fixes #103 (and should fix
https://github.com/apple/container/issues/108)

Today we only parse if the username field of the runtime spec is set,
but this misses if someone just supplied the integer uid and gid fields
only.
2025-06-12 10:19:31 -04:00
Kathryn Baldauf 7c063dfbe4 Remove most uses of env variables for image registries (#100)
When we were testing the repo, we added authentication to most of the
registry tests so that we could access private images. Now that the
images are public, this PR removes the use of REGISTRY_TOKEN and
REGISTRY_USERNAME in tests that no longer require authenticating.

Note: REGISTRY_TOKEN, REGISTRY_USERNAME, and REGISTRY_HOST are still
required in the CI to push images and for a few registry tests. So the
env variables are not completely removed. The variables are only used in
the test tool cctl and in our swift tests.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-12 10:16:43 -04:00
Michael Crosby 5d2d7a1bc3 update license header removing new line (#99)
Fixes #63

Signed-off-by: crosbymichael <michael_crosby@apple.com>
2025-06-12 09:57:35 -04:00
Danny Canter 4b05e5f231 CONTRIBUTING: Add blurb about requiring signed commits (#98)
We require signed commits as of yesterday, and it'd be nice to have this
in writing somewhere to avoid contributors getting blindsided when
github has a scary x on the merge button.
2025-06-11 13:24:59 -07:00
Seyed Mojtaba Hosseini Zeidabadi 6bb3d1ad1f Fix: extended in throughout the code (#92)
- Corrected the typo in the method name (`Extened` → `Extended`)
 - Updated all references to reflect the corrected spelling
- Introduced a `@available(*, deprecated)` alias for the original method
to maintain backward compatibility, as it was part of the public API
2025-06-11 12:49:23 -07:00
Seyed Mojtaba Hosseini Zeidabadi 27db60af22 fix: structure in createOCILayoutStructure (#93)
Both the callee and caller names have been corrected.
2025-06-11 14:51:15 -04:00
Dmitry Kovba f245ae63b3 Improve @SendableProperty (#91)
This PR ensures that we enter a lock inside the `@SendableProperty`
implementation as soon as we access a computed property. Additionally,
it mirrors the access level of the original property. Both changes are
required for [improved
accuracy](https://github.com/apple/container/pull/144) of progress
updates in container. Additionally, it should resolve
https://github.com/apple/containerization/issues/60 that occurs on
certain configurations.

Please tag as 0.1.1 after merging.
2025-06-11 14:13:21 -04:00
Alexander 0cb8d29462 Updated gitignore: .idea (#90)
Added .idea to .gitignore file
2025-06-11 10:50:32 -07:00
ronbo 1ee7d10cca Add swiftly link (#95)
add link to swiftly toolchain manager
2025-06-11 10:32:40 -07:00
Danny Canter 943723315b LinuxContainer: Ensure we close guest agent connections (#87)
Use scoped access to the agent connection to ensure the vsock fds are
close(2)'d.

### Note
In a follow up I'd like to change `LinuxProcess` to dialing the agent
connection inside of `.start()`. I don't like needing to pass it an
agent connection. It has a reference to a vm so it can easily dial
inside itself if it needs to.
2025-06-11 11:44:06 -04:00
Danny Canter 7320f8360e VZVirtualMachineInstance: Adjust silent success behavior of nested virt (#88)
Fixes #85

The virtualization bool on LinuxContainer mostly just forwards to
VZVirtualMachineInstance which today would silently take your boolean
and do nothing if the underlying platform doesn't have support for it.
This is (to me) arguably worse than erroring, as it gives the client a
false security that the setting is on, and they should have virt
capabilities in the container/guest now.

This change makes it so that we throw a ContainerizationError for this
case, with a code of .unsupported so it's checkable by a user if they
want more information on the "why".
2025-06-11 11:39:39 -04:00
Dmitry Kovba bc1032e218 Require having Xcode 26 beta (#84)
This PR requires installing Xcode 26 beta until we resolve
https://github.com/apple/containerization/issues/66.
2025-06-11 10:43:52 -04:00
Dmitry Kovba 61379dcf65 Update availability checks to macOS 26 (#80)
This PR updates availability checks for macOS 16 to macOS 26.
2025-06-11 10:42:25 -04:00
Noritaka Kobayashi 69827b55d2 refactor: remove extraneous "break" (#76)
remove extraneous "break"
2025-06-10 21:36:42 -07:00
Spencer King 6d18db68ff docs: Avoid using Latin abbreviations in documentation (#81)
Remove Latin abbreviations from the documentation in accordance with the
[Apple Style Guide](https://help.apple.com/applestyleguide/). This
change does not impact any abbreviations used in code comments since
those are not covered by the style guide.
2025-06-10 21:36:18 -07:00
Iceman 5258424e36 Fetch without chunking in parallel (#75)
## Issue

When pulling images, the download speed appears to be slower compared to
Docker.
I found that parallel chunk generation was being performed during the
layer download process.
While individual chunks allow parallel download operations, the overall
process remains sequential between chunks.
This results less performance when chunks contain both small and large
layers mixed together.

## Changes

Discontinued chunk-based segmentation to enable more efficient parallel
downloads.

## Results(in my local env)

| image | layers | old | new |
| ---|---|---|---|
| node:latest | 12 | 1m15s | 1m10s |
| ghcr.io/norio-nomura/swift_discord_bot:main | 54 |  2m45s | 2m30s |

<details>
<summary>raw terminal log</summary>

```
❯ rm -rf ~/Library/Application\ Support/com.apple.containerization && time bin/cctl_old images pull docker.io/library/node:latest
image pulled
bin/cctl_old images pull docker.io/library/node:latest  42.37s user 6.60s system 64% cpu 1:15.94 total

❯ rm -rf ~/Library/Application\ Support/com.apple.containerization && time bin/cctl_new images pull docker.io/library/node:latest
image pulled
bin/cctl_new images pull docker.io/library/node:latest  42.27s user 6.72s system 69% cpu 1:10.58 total

❯ rm -rf ~/Library/Application\ Support/com.apple.containerization && time bin/cctl_old images pull docker.io/library/node:latest
image pulled
bin/cctl_old images pull docker.io/library/node:latest  45.65s user 7.36s system 70% cpu 1:15.64 total

❯ rm -rf ~/Library/Application\ Support/com.apple.containerization && time bin/cctl_new images pull docker.io/library/node:latest
image pulled
bin/cctl_new images pull docker.io/library/node:latest  39.76s user 6.32s system 65% cpu 1:10.50 total

❯ rm -rf ~/Library/Application\ Support/com.apple.containerization && time bin/cctl_old images pull docker.io/library/node:latest
image pulled
bin/cctl_old images pull docker.io/library/node:latest  42.47s user 6.75s system 65% cpu 1:14.72 total

❯ rm -rf ~/Library/Application\ Support/com.apple.containerization && time bin/cctl_new images pull docker.io/library/node:latest
image pulled
bin/cctl_new images pull docker.io/library/node:latest  42.28s user 6.65s system 69% cpu 1:09.93 total

❯ rm -rf ~/Library/Application\ Support/com.apple.containerization && time bin/cctl_new images pull ghcr.io/norio-nomura/swift_discord_bot:main
image pulled
bin/cctl_new images pull ghcr.io/norio-nomura/swift_discord_bot:main  103.83s user 18.71s system 81% cpu 2:30.02 total

❯ rm -rf ~/Library/Application\ Support/com.apple.containerization && time bin/cctl_old images pull ghcr.io/norio-nomura/swift_discord_bot:main
image pulled
bin/cctl_old images pull ghcr.io/norio-nomura/swift_discord_bot:main  120.79s user 20.70s system 85% cpu 2:45.26 total
```
</details>


<details>
<summary>patch for download only</summary>

```diff
diff --git a/Sources/cctl/ImageCommand.swift b/Sources/cctl/ImageCommand.swift
index 84c5218..4aa4bb8 100644
--- a/Sources/cctl/ImageCommand.swift
+++ b/Sources/cctl/ImageCommand.swift
@@ -127,6 +127,7 @@ extension Application {
                 }
 
                 print("image pulled")
+                return
 
                 let tempDir = FileManager.default.uniqueTemporaryDirectory(create: true)
                 if let platform {
```
</details>
2025-06-10 21:26:36 -07:00
Dmitry Kovba 4ad3c996f0 Update the names of Xcode, macOS, and Apple silicon (#83)
This PR updates the names of Xcode and macOS to the official names used
in https://developer.apple.com/download/applications/. Also, it fixes
the capitalization in "Apple silicon".
2025-06-10 18:03:25 -07:00