swift-server/swift-devcontainer-template

Updating for the new development containers specification?

pvzig opened this issue · 8 comments

pvzig commented

Is there interest in updating this to follow with the new dev containers format(s)?

I’ve built out a feature (which you can see here: https://github.com/pvzig/swift-dev-container) and a Swift dev container image (forked here: https://github.com/pvzig/images/tree/main/src/swift). This work largely follows the patterns used by Rust and Go for their respective dev container features and images.

Example of using a feature

{
    "image": "mcr.microsoft.com/vscode/devcontainers/base:jammy",
    "features": {
        "ghcr.io/pvzig/swift-dev-container/swift:0": {}
    }
}

Or with the image:

{
    "image": "ghcr.io/pvzig/images/swift:5.6-amazonlinux2",
    "remoteUser": "vscode"
}

Both repos are configured with Github actions for pushing images to the Github Package Registry.

We are yet to publish the original swift-dev-container. Apple would prefer we don't use GH actions and to publish elsewhere than ghcr.io. Creating a feature and then using it our image would be a good path to follow. I assume you can't have both feature and image in the same repo. I haven't looked into this in much detail.

thanks @pvzig unfortunately with cannot use GHA on this repository. we can set up other CI solutions, e.g. if we have a bash script to publish the images etc

pvzig commented

Got it. Looks like both devcontainer features and images support any OCI Registry so there's no reason we couldn't use Docker or whatever the preferred registry is and the CLI to publish via a script.

If we're rolling our own publishing I don't think there is any reason they couldn't both be in the same repo but I might be wrong. Features specifically expect to be in the /src/swift directory but you specify a --workspace-folder when building an image with the CLI.

So we have a published template now (attached to this repo). Basically a copy of what was there before.

The first thing I want to do is remove all the shell scripts and replace those with features. I have a version almost ready here https://github.com/swift-server/swift-devcontainer-template/blob/features/src/swift/.devcontainer/devcontainer.json.

Regarding prebuilt images I'm not sure how Apple feel about managing another set of container images for swift. It looks like you have basically replicated the scripts in https://github.com/apple/swift-docker.

pvzig commented

Yeah, I'm not sure that there's a ton of value in implementing a devcontainer specific image. I just did some testing and they don't seem to start up any faster compared to the published docker images. The neat thing (imo) is the ability to generate all the variants with the mainfest.json and the tooling but that seems to be taken care of by the folks managing apple/swift-docker.

The template using the dev container features is now live. Do you want to keep this issue open or shall we close for the moment. We might look to support a devcontainer feature later on, but I'd want to make sure we aren't repeating work already done when setting up the feature.

pvzig commented

We can go ahead and close this issue out. While acknowledging that it's another script to maintain, I think it'd be great to have a Swift feature in the future!

Yes I would like to implement a swift feature, but at the same time want to make sure we aren't replicating code from elsewhere.