Skip to content

Commit

Permalink
remove mise binary from final image
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup committed Jan 31, 2025
1 parent d2168e0 commit 9636ccc
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions core/generate/mise_step_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (c *GenerateContext) newMiseStepBuilder() *MiseStepBuilder {
SupportingAptPackages: []string{},
Assets: map[string]string{},
DependsOn: []string{},
Outputs: &[]string{"/mise/shims", "/mise/installs", "/usr/local/bin/mise", "/etc/mise/config.toml", "/root/.local/state/mise"},
Outputs: &[]string{"/mise/shims", "/mise/installs"},
app: c.App,
env: c.Env,
}
Expand Down Expand Up @@ -88,8 +88,7 @@ func (b *MiseStepBuilder) Build(options *BuildStepOptions) (*plan.Step, error) {
plan.NewVariableCommand("MISE_CONFIG_DIR", "/mise"),
plan.NewVariableCommand("MISE_INSTALL_PATH", "/usr/local/bin/mise"),
plan.NewVariableCommand("MISE_CACHE_DIR", "/mise/cache"),
plan.NewPathCommand("/mise/shims"),
options.NewAptInstallCommand([]string{"curl", "ca-certificates"}),
options.NewAptInstallCommand([]string{"curl", "ca-certificates", "git"}),
plan.NewExecCommand("sh -c 'curl -fsSL https://mise.run | sh'",
plan.ExecOptions{
CustomName: "install mise",
Expand Down Expand Up @@ -146,6 +145,21 @@ func (b *MiseStepBuilder) Build(options *BuildStepOptions) (*plan.Step, error) {
})
}

// Packages installed have binaries available at /mise/installs/{package}/{version}/bin
// We need to add these to the PATH
for _, pkg := range b.MisePackages {
resolved, ok := options.ResolvedPackages[pkg.Name]
if !ok || resolved.ResolvedVersion == nil {
continue
}

version := *resolved.ResolvedVersion

step.AddCommands([]plan.Command{
plan.NewPathCommand("/mise/installs/" + pkg.Name + "/" + version + "/bin"),
})
}

step.Assets = b.Assets
step.Outputs = b.Outputs
step.UseSecrets = &[]bool{false}[0]
Expand Down

0 comments on commit 9636ccc

Please sign in to comment.