Skip to content

Commit 5da5f0a

Browse files
committed
Added overrides for github downloads
1 parent 75d1580 commit 5da5f0a

File tree

13 files changed

+195
-13
lines changed

13 files changed

+195
-13
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ If your remote points directly to `https://dl.google.com/go`, you need to set:
6565

6666
See [override-all.env](./override-all.env) for a file with all possible override variables.
6767

68+
#### Special overrides
69+
70+
There are a few sources which are used in multiple installations. For those sources, there is an override that globaly overrides all installations from this sources. Here is the list of those sources and their keys.
71+
72+
```
73+
GITHUB_DOWNLOAD_URL_BASE=...
74+
```
75+
6876
### Extend an existing feature
6977

7078
TBD

build/build.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ func packageFeature(featureName string) error {
153153
}
154154

155155
func testFeature(featureName string) error {
156+
// For debugging
157+
keepImage := false
156158
// Prepare the temporary folder for the devcontainer spec
157159
testPath := ".scenario-test"
158160
os.RemoveAll(testPath)
@@ -246,7 +248,9 @@ func testFeature(featureName string) error {
246248
}); err != nil {
247249
return err
248250
}
249-
defer execr.Run(false, "docker", "image", "rm", imageName)
251+
if !keepImage {
252+
defer execr.Run(false, "docker", "image", "rm", imageName)
253+
}
250254

251255
// Run the check in the container
252256
checkError := execr.Run(true, "docker", "run", "-t", "--rm", "-v", "/var/run/docker.sock:/var/run/docker.sock", imageName, "sh", "-c", "/tmp/check.sh")

features/src/docker-out/NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Debian, Ubuntu, Alpine
88

99
Needs access to the following URL for downloading and resolving:
1010
* https://download.docker.com
11+
* https://github.com

features/src/docker-out/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ A feature which installs the Docker client and re-uses the host socket.
1515
"buildxVersionResolve": false,
1616
"downloadUrlBase": "",
1717
"downloadUrlPath": "",
18-
"versionsUrl": ""
18+
"versionsUrl": "",
19+
"composeDownloadUrlBase": "",
20+
"composeDownloadUrlPath": "",
21+
"buildxDownloadUrlBase": "",
22+
"buildxDownloadUrlPath": ""
1923
}
2024
}
2125
```
@@ -33,6 +37,10 @@ A feature which installs the Docker client and re-uses the host socket.
3337
| downloadUrlBase | The download URL to use for Docker binaries. | string | <empty> | |
3438
| downloadUrlPath | The download URL path to use for Docker binaries. | string | <empty> | |
3539
| versionsUrl | The URL to use for checking available versions. | string | <empty> | |
40+
| composeDownloadUrlBase | The download URL to use for Docker Compose binaries. | string | <empty> | |
41+
| composeDownloadUrlPath | The download URL path to use for Docker Compose binaries. | string | <empty> | |
42+
| buildxDownloadUrlBase | The download URL to use for Docker Buildx binaries. | string | <empty> | |
43+
| buildxDownloadUrlPath | The download URL path to use for Docker Buildx binaries. | string | <empty> | |
3644

3745
## Customizations
3846

@@ -50,3 +58,4 @@ Debian, Ubuntu, Alpine
5058

5159
Needs access to the following URL for downloading and resolving:
5260
* https://download.docker.com
61+
* https://github.com

features/src/docker-out/devcontainer-feature.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,26 @@
6565
"type": "string",
6666
"default": "",
6767
"description": "The URL to use for checking available versions."
68+
},
69+
"composeDownloadUrlBase": {
70+
"type": "string",
71+
"default": "",
72+
"description": "The download URL to use for Docker Compose binaries."
73+
},
74+
"composeDownloadUrlPath": {
75+
"type": "string",
76+
"default": "",
77+
"description": "The download URL path to use for Docker Compose binaries."
78+
},
79+
"buildxDownloadUrlBase": {
80+
"type": "string",
81+
"default": "",
82+
"description": "The download URL to use for Docker Buildx binaries."
83+
},
84+
"buildxDownloadUrlPath": {
85+
"type": "string",
86+
"default": "",
87+
"description": "The download URL path to use for Docker Buildx binaries."
6888
}
6989
},
7090
"customizations": {

features/src/docker-out/install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ esac
1414
-downloadUrlBase="${DOWNLOADURLBASE:-""}" \
1515
-downloadUrlPath="${DOWNLOADURLPATH:-""}" \
1616
-versionsUrl="${VERSIONSURL:-""}" \
17+
-composeDownloadUrlBase="${COMPOSEDOWNLOADURLBASE:-""}" \
18+
-composeDownloadUrlPath="${COMPOSEDOWNLOADURLPATH:-""}" \
19+
-buildxDownloadUrlBase="${BUILDXDOWNLOADURLBASE:-""}" \
20+
-buildxDownloadUrlPath="${BUILDXDOWNLOADURLPATH:-""}"

features/src/docker-out/installer.go

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
//////////
1818

1919
var dockerCliVersionRegexp *regexp.Regexp = regexp.MustCompile(`(?m)^(\d+)\.(\d+)\.(\d+)$`)
20-
var dockerComposeVersionRegexp *regexp.Regexp = regexp.MustCompile(`(?m)^v(\d+)\.(\d+)\.(\d+)$`)
21-
var dockerBuildxVersionRegexp *regexp.Regexp = regexp.MustCompile(`(?m)^v(\d+)\.(\d+)\.(\d+)$`)
20+
var dockerComposeVersionRegexp *regexp.Regexp = regexp.MustCompile(`(?m)^v(?P<raw>(\d+)\.(\d+)\.(\d+))$`)
21+
var dockerBuildxVersionRegexp *regexp.Regexp = regexp.MustCompile(`(?m)^v(?P<raw>(\d+)\.(\d+)\.(\d+))$`)
2222

2323
//////////
2424
// Main
@@ -42,6 +42,10 @@ func runMain() error {
4242
downloadUrlBase := flag.String("downloadUrlBase", "", "")
4343
downloadUrlPath := flag.String("downloadUrlPath", "", "")
4444
versionsUrl := flag.String("versionsUrl", "", "")
45+
composeDownloadUrlBase := flag.String("composeDownloadUrlBase", "", "")
46+
composeDownloadUrlPath := flag.String("composeDownloadUrlPath", "", "")
47+
buildxDownloadUrlBase := flag.String("buildxDownloadUrlBase", "", "")
48+
buildxDownloadUrlPath := flag.String("buildxDownloadUrlPath", "", "")
4549
flag.Parse()
4650

4751
// Load settings from an external file
@@ -52,6 +56,8 @@ func runMain() error {
5256
installer.HandleOverride(downloadUrlBase, "https://download.docker.com", "docker-out-download-url-base")
5357
installer.HandleOverride(downloadUrlPath, "/linux/static/stable", "docker-out-download-url-path")
5458
installer.HandleOverride(versionsUrl, "https://download.docker.com/linux/static/stable", "docker-out-versions-url")
59+
installer.HandleGitHubOverride(composeDownloadUrlBase, composeDownloadUrlPath, "docker/compose", "docker-out-compose-download-url")
60+
installer.HandleGitHubOverride(buildxDownloadUrlBase, buildxDownloadUrlPath, "docker/buildx", "docker-out-buildx-download-url")
5561

5662
// Create and process the feature
5763
feature := installer.NewFeature("Docker-Out", false,
@@ -62,10 +68,14 @@ func runMain() error {
6268
VersionsUrl: *versionsUrl,
6369
},
6470
&dockerComposeComponent{
65-
ComponentBase: installer.NewComponentBase("Docker Compose", *composeVersion, *composeVersionResolve),
71+
ComponentBase: installer.NewComponentBase("Docker Compose", *composeVersion, *composeVersionResolve),
72+
DownloadUrlBase: *composeDownloadUrlBase,
73+
DownloadUrlPath: *composeDownloadUrlPath,
6674
},
6775
&dockerBuildxComponent{
68-
ComponentBase: installer.NewComponentBase("Docker buildx", *buildxVersion, *buildxVersionResolve),
76+
ComponentBase: installer.NewComponentBase("Docker buildx", *buildxVersion, *buildxVersionResolve),
77+
DownloadUrlBase: *buildxDownloadUrlBase,
78+
DownloadUrlPath: *buildxDownloadUrlPath,
6979
},
7080
)
7181
return feature.Process()
@@ -152,6 +162,8 @@ func (c *dockerCliComponent) getArchitecturePathPart() (string, error) {
152162

153163
type dockerComposeComponent struct {
154164
*installer.ComponentBase
165+
DownloadUrlBase string
166+
DownloadUrlPath string
155167
}
156168

157169
func (c *dockerComposeComponent) GetAllVersions() ([]*gover.Version, error) {
@@ -181,7 +193,12 @@ func (c *dockerComposeComponent) InstallVersion(version *gover.Version) error {
181193
if err != nil {
182194
return err
183195
}
184-
downloadUrl := fmt.Sprintf("https://github.com/docker/compose/releases/download/%s/docker-compose-linux-%s", version.Raw, archPart)
196+
// https://github.com/docker/compose/releases/download/v2.39.2/docker-compose-linux-x86_64
197+
versionPart := fmt.Sprintf("v%s", version.Raw)
198+
downloadUrl, err := installer.Tools.Http.BuildUrl(c.DownloadUrlBase, c.DownloadUrlPath, versionPart, fmt.Sprintf("docker-compose-linux-%s", archPart))
199+
if err != nil {
200+
return err
201+
}
185202
if err := installer.Tools.Download.ToFile(downloadUrl, "/usr/local/lib/docker/cli-plugins/docker-compose", "Docker Compose"); err != nil {
186203
return err
187204
}
@@ -196,6 +213,8 @@ func (c *dockerComposeComponent) InstallVersion(version *gover.Version) error {
196213

197214
type dockerBuildxComponent struct {
198215
*installer.ComponentBase
216+
DownloadUrlBase string
217+
DownloadUrlPath string
199218
}
200219

201220
func (c *dockerBuildxComponent) GetAllVersions() ([]*gover.Version, error) {
@@ -225,7 +244,12 @@ func (c *dockerBuildxComponent) InstallVersion(version *gover.Version) error {
225244
if err != nil {
226245
return err
227246
}
228-
downloadUrl := fmt.Sprintf("https://github.com/docker/buildx/releases/download/%s/buildx-%s.linux-%s", version.Raw, version.Raw, archPart)
247+
// https://github.com/docker/buildx/releases/download/v0.26.1/buildx-v0.26.1.linux-amd64
248+
versionPart := fmt.Sprintf("v%s", version.Raw)
249+
downloadUrl, err := installer.Tools.Http.BuildUrl(c.DownloadUrlBase, c.DownloadUrlPath, versionPart, fmt.Sprintf("buildx-%s.linux-%s", versionPart, archPart))
250+
if err != nil {
251+
return err
252+
}
229253
if err := installer.Tools.Download.ToFile(downloadUrl, "/usr/local/lib/docker/cli-plugins/docker-buildx", "Docker buildx"); err != nil {
230254
return err
231255
}

features/src/go/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ esac
1010
-downloadUrlBase="${DOWNLOADURLBASE:-""}" \
1111
-downloadUrlPath="${DOWNLOADURLPATH:-""}" \
1212
-latestUrl="${LATESTURL:-""}" \
13-
-versionsUrl="${VERSIONSURL:-""}" \
13+
-versionsUrl="${VERSIONSURL:-""}"

features/src/zig/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ esac
99
-versionResolve="${VERSIONRESOLVE:-"false"}" \
1010
-downloadUrlBase="${DOWNLOADURLBASE:-""}" \
1111
-downloadUrlPath="${DOWNLOADURLPATH:-""}" \
12-
-versionsUrl="${VERSIONSURL:-""}" \
12+
-versionsUrl="${VERSIONSURL:-""}"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
4+
[[ -f "$(dirname "$0")/../functions.sh" ]] && source "$(dirname "$0")/../functions.sh"
5+
[[ -f "$(dirname "$0")/functions.sh" ]] && source "$(dirname "$0")/functions.sh"
6+
7+
check_version "$(docker version -f '{{.Client.Version}}')" "28.3.3"
8+
check_version "$(docker compose version)" "Docker Compose version v2.39.1"
9+
check_version "$(docker buildx version)" "github.com/docker/buildx v0.21.2 1360a9e8d25a2c3d03c2776d53ae62e6ff0a843d"

0 commit comments

Comments
 (0)