Open jcbhmr opened 1 year ago
Hi @jcbhmr, thanks for reaching out.
Jarrod's repo contains a Flutter and Android feature. Since it's my first time playing with these features, I've used it as a starting point and converted it into Dart SDK.
That script of mine is mostly a copy of a script in the official Dart docker container image. Unfortunately, since the Dart team does not have an official pointer to what's "latest" version of the Dart SDK, the versions, URLs and package checksums are hardcoded in the script.
I could potentially improve the script to pull these from devcontainer.json, but in this form, this feature's configuration would always have to be manually updated to catch up with the release rollout of Dart SDK, which is kind of meh experience IMO.
Let me know your thoughts.
I think it might be possible to use something like this? https://github.com/devcontainers/features/blob/main/src/github-cli/install.sh#L80 find_version_from_git_tags
or something to get the latest version from https://github.com/dart-lang/sdk/tags ?? maybe not idk.
i tried using apt to install it as described in the docs and didn't get very far 😅 #2
@t-kozak There's also @eitsupi's https://github.com/devcontainers-community/features/blob/8522fe1bf77b027373dbf10b332010599afc0633/src/dart/install.sh Dart feature that worked, but I don't know if it fits your (exemplifying the typical Dart user 😅 you're the Dart-expert here 🤣) use case.
It downloads the Dart zip archive, but it doesn't do the magic checksum that the current feature does. idk if this is a requirement 🤷♀️
anyways, just thought now that there's discussion on improvement, itd be good to bring the another Dart installation magician into the conversation.
Oh, and thanks for participating in this discussion about something you probably wrote once and forgot about 🤣
IMO, I think that using the apt
is the way to go (not zip). However!... Hot take... I probably wouldn't follow the instructions at either dart's site or dart repo wiki. Instead...
Because the dart files are held on a Google storage drive, I would probably
An example, for 3.1.2
current stable...
curl -O https://storage.googleapis.com/dart-archive/channels/stable/release/3.1.2/linux_packages/dart_3.1.2-1_amd64.deb
sudo apt install -y -f ./dart_3.1.2-1_amd64.deb
(be careful of thr -1
that follows version in deb filenames, example 3.1.2-1
)
Everything above is my main comment. Here bellow are just some extra thoughts...
A. I wouldn't recommend copying the dart-docker
repo because it is....
Dockerfile
B. I would recommend querying the Dart archive on googleapis...
If you only want to know the version number of the latest (stable) version... https://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION (just replace stable with dev or beta in above url to see those instead)
You can investigate the https://storage.googleapis.com/storage/v1/b/dart-archive/
to see what's in there. Make sure you set your delmiter and ask for json in response. So for instance, to ask for folders (prefix
) in stable...
So this link https://storage.googleapis.com/storage/v1/b/dart-archive/o?delimiter=/&alt=json&prefix=channels/stable/release/ (again, replace stable with dev or beta if desired) returns the following...
{
"kind": "storage#objects",
"prefixes": [
"channels/stable/release/1.11.0/",
"channels/stable/release/1.11.1/",
// truncated ...
"channels/stable/release/3.0.6/",
"channels/stable/release/3.0.7/",
"channels/stable/release/3.1.0/",
"channels/stable/release/3.1.1/",
"channels/stable/release/3.1.2/",
]
}
Which list's all folders (prefix
), made up of versions. (stable, in above example). Those version numbers may be all you need, or you can traverse into the folders by appending to the prefix in the url. So for instance, if you wanted to know about version 2.9.3 specifically...
https://storage.googleapis.com/storage/v1/b/dart-archive/o?delimiter=/&alt=json&prefix=channels/stable/release/2.9.3/
and you see it has 3 folders api-docs
, linux_packages
, sdk
Side note: if you do want to use zip (instead of deb) so that you can target more than just amd65 platform, the zips and sha hashes are in sdk
(as opposed to debs in linux_packages).
C. In your repo it uses latest
as the proposal, would stable
be better? As stable
more closely follows the dart versioning. But i haven't pulled around with deaf containers in a while, latest
may be the common convention
D. I see that you are including versions within the proposals, (currently 3.0.7
in your devcontainer-feature.json) which is very nice of you but I wouldn't stress yourself out about itinitially. For now, just provide 'latest' or 'stable'/'beta', as that's what most people are going to use. Down the road if you want... the simplest way to keep that version up to date is to set up a github action, fired via nightly a cron job, to check an if
condition to run based on either the current version file, or if the version file's (stable/beta/dev) have been updated since a time condition...
Example: Sep 14th...
curl --time-cond '14 Sep 2023' https://storage.googleapis.com/dart-archive/channels/{stable,dev,beta}/release/latest/VERSION
"1 days ago" (aka yesterday)
curl --time-cond "$(date -d 1 days ago" +"%d %b %Y")" https://storage.googleapis.com/dart-archive/channels/{stabble,dev,beta}/release/latest/VERSION
^above command returns only the ones updated after provided date. You can confirm this by inspect the last-modified
date of (stable) VERSION...
curl -s -I https://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION | grep -i Last-Modified
which currently returns... "last-modified: Wed, 13 Sep 2023 15:12:48 GMT"
If you check for any updates since yesterday, using the curl -v
flag and anything comes back you know there's been an update. To get all versions for all channels...
(needs jq
command)...
curl -s "https://storage.googleapis.com/storage/v1/b/dart-archive/o?delimiter=/&alt=json&prefix=channels/{stable,beta,dev}/release/" | jq '.prefixes[] | split("/")[-2]' | grep -E '[3-9]+\.[0-9]+\.[0-9]+'
^ filters only for dart version 3+
Ya know.... After looking at it again, I may have changed my mind. Maybe the dart-docker and zip is the right approach. It would support M1 macs.🤔
Yea, after looking at it some more. I like the way you were doing it best. https://github.com/jarrodcolburn/features-dart-sdk/blob/patch-1/install.sh Look at my PR. I try to rewrite file it so hashes aren't hardcoded and should work with any dart version.
I'm not on a computer that's setup to test this at the moment. Please git it a try.
Hello @jarrodcolburn and @t-kozak! 👋
I notice that you'd created a Dart SDK feature for devcontainers but it wasn't on the https://containers.dev/features list. I figured you might be interested in this repo.