Skip to content

Commit

Permalink
use built base image for mise
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup committed Feb 13, 2025
1 parent 697d096 commit 4475f7d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
3 changes: 2 additions & 1 deletion core/generate/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ func (c *GenerateContext) ApplyConfig(config *config.Config) error {
aptStep.Packages = config.AptPackages

// The apt step should run first
miseStep.DependsOn = append(miseStep.DependsOn, aptStep.DisplayName)
// miseStep.DependsOn = append(miseStep.DependsOn, aptStep.DisplayName)
miseStep.SupportingAptPackages = append(miseStep.SupportingAptPackages, config.AptPackages...)
}

// Step config
Expand Down
32 changes: 17 additions & 15 deletions core/generate/mise_step_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

const (
MisePackageStepName = "packages:mise"
BuilderBaseImage = "ghcr.io/railwayapp/railpack-builder-base:latest"
)

type MiseStepBuilder struct {
Expand All @@ -22,8 +23,8 @@ type MiseStepBuilder struct {
MisePackages []*resolver.PackageRef
SupportingMiseFiles []string
Assets map[string]string
DependsOn []string
Outputs *[]string
// DependsOn []string
Outputs *[]string

app *a.App
env *a.Environment
Expand All @@ -36,10 +37,10 @@ func (c *GenerateContext) newMiseStepBuilder() *MiseStepBuilder {
MisePackages: []*resolver.PackageRef{},
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"},
app: c.App,
env: c.Env,
// DependsOn: []string{},
Outputs: &[]string{"/mise/shims", "/mise/installs", "/usr/local/bin/mise", "/etc/mise/config.toml", "/root/.local/state/mise"},
app: c.App,
env: c.Env,
}

c.Steps = append(c.Steps, step)
Expand Down Expand Up @@ -78,9 +79,11 @@ func (b *MiseStepBuilder) Build(options *BuildStepOptions) (*plan.Step, error) {
return step, nil
}

step.DependsOn = b.DependsOn
// step.DependsOn = b.DependsOn

miseCache := options.Caches.AddCache("mise", "/mise/cache")
// miseCache := options.Caches.AddCache("mise", "/mise/cache")

step.StartingImage = BuilderBaseImage

// Install mise
step.AddCommands([]plan.Command{
Expand All @@ -89,12 +92,11 @@ func (b *MiseStepBuilder) Build(options *BuildStepOptions) (*plan.Step, error) {
plan.NewVariableCommand("MISE_CONFIG_DIR", "/mise"),
plan.NewVariableCommand("MISE_CACHE_DIR", "/mise/cache"),
plan.NewPathCommand("/mise/shims"),
options.NewAptInstallCommand([]string{"curl", "ca-certificates", "git"}),
plan.NewExecCommand("sh -c 'curl -fsSL https://mise.run | sh'",
plan.ExecOptions{
CustomName: "install mise",
Caches: []string{miseCache},
}),
// options.NewAptInstallCommand([]string{"curl", "ca-certificates", "git"}),
// plan.NewExecCommand("sh -c 'curl -fsSL https://mise.run | sh'",
// plan.ExecOptions{
// CustomName: "install mise",
// }),
})

// Add user mise config files if they exist
Expand Down Expand Up @@ -144,7 +146,7 @@ func (b *MiseStepBuilder) Build(options *BuildStepOptions) (*plan.Step, error) {
}),
plan.NewExecCommand("sh -c 'mise trust -a && mise install'", plan.ExecOptions{
CustomName: "install mise packages: " + strings.Join(pkgNames, ", "),
Caches: []string{miseCache},
// Caches: []string{miseCache},
}),
})
}
Expand Down
2 changes: 1 addition & 1 deletion core/providers/php/php.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (p *PhpProvider) Plan(ctx *generate.GenerateContext) error {
if err != nil {
return err
}
nodePackages.DependsOn = []string{imageStep.DisplayName}
// nodePackages.DependsOn = []string{imageStep.DisplayName}

nodeInstall, err := nodeProvider.Install(ctx, nodePackages, packageJson)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions images/debian/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ RUN apt-get update && apt-get install -y \
liblzma-dev

# Install mise
# TODO: I don't think we need these envs here. Or we can remove from the mise_step
ENV MISE_INSTALL_PATH=/usr/local/bin/mise \
MISE_DATA_DIR=/mise \
MISE_CONFIG_DIR=/mise \
MISE_CACHE_DIR=/mise/cache \
MISE_VERBOSE=1 \
PATH=/mise/shims:$PATH

# TODO: Install mise from source to get a smaller binary

RUN curl -fsSL https://mise.run | sh

0 comments on commit 4475f7d

Please sign in to comment.