Skip to content

Commit

Permalink
support Wolfi-based dev containers
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Hall <jason@chainguard.dev>
  • Loading branch information
imjasonh authored and pascalbreuninger committed Jun 29, 2024
1 parent 9f518af commit 7231a6d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pkg/ide/openvscode/openvscode.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (o *OpenVSCodeServer) Install() error {
// check what release we need to download
url := o.getReleaseUrl()

vscode.InstallAlpineRequirements(o.log)
vscode.InstallAPKRequirements(o.log)

// download tar
resp, err := devpodhttp.GetHTTPClient().Get(url)
Expand Down
31 changes: 0 additions & 31 deletions pkg/ide/vscode/alpine.go

This file was deleted.

45 changes: 45 additions & 0 deletions pkg/ide/vscode/apk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package vscode

import (
"bytes"
"os"
"os/exec"
"strings"

"github.com/loft-sh/devpod/pkg/command"
"github.com/loft-sh/log"
)

// InstallAPKRequirements installs the requirements using apk.
//
// This is used by Alpine- and Wolfi-based images.
func InstallAPKRequirements(logger log.Logger) {
if !command.Exists("apk") {
return
}

dependencies := []string{"build-base"}
if all, err := os.ReadFile("/etc/os-release"); err != nil {
logger.Errorf("Error reading /etc/os-release: %v", err)
return
} else if !bytes.Contains(all, []byte("ID=alpine")) {
// Alpine needs gcompat for compatibility with musl.
// Wolfi-based distros don't need this, and Wolfi doesn't have it.
dependencies = append(dependencies, "gcompat")
}
logger.Debugf("Install apk requirements...")
if !command.Exists("git") {
dependencies = append(dependencies, "git")
}
if !command.Exists("bash") {
dependencies = append(dependencies, "bash")
}
if !command.Exists("curl") {
dependencies = append(dependencies, "curl")
}

out, err := exec.Command("sh", "-c", "apk update && apk add "+strings.Join(dependencies, " ")).CombinedOutput()
if err != nil {
logger.Errorf("Error updating apk dependencies: %v", command.WrapCommandError(out, err))
}
}
2 changes: 1 addition & 1 deletion pkg/ide/vscode/vscode.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (o *VsCodeServer) Install() error {
return nil
}

InstallAlpineRequirements(o.log)
InstallAPKRequirements(o.log)

// add settings
if o.settings == "" {
Expand Down

0 comments on commit 7231a6d

Please sign in to comment.