Skip to content

Commit 8fcde00

Browse files
committed
builder: update railpack to 0.17.1 with new providers
1 parent deb74ab commit 8fcde00

7 files changed

Lines changed: 640 additions & 811 deletions

File tree

ent/migrate/schema.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ent/serviceconfig/serviceconfig.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 159 additions & 147 deletions
Large diffs are not rendered by default.

go.sum

Lines changed: 372 additions & 552 deletions
Large diffs are not rendered by default.

internal/sourceanalyzer/enum/framework.go

Lines changed: 78 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -8,84 +8,75 @@ import (
88
"github.com/railwayapp/railpack/core/generate"
99
)
1010

11-
// Detect framework based on provider and plan
1211
func DetectFramework(provider Provider, ctx *generate.GenerateContext) Framework {
1312
switch provider {
14-
// Node frameworks
1513
case Node:
1614
framework, ok := ctx.Metadata.Properties["nodeRuntime"]
17-
if ok {
18-
switch framework {
19-
case "next":
20-
return Next
21-
case "astro":
22-
return Astro
23-
case "vite":
24-
return Vite
25-
case "cra":
26-
return CRA
27-
case "angular":
28-
return Angular
29-
case "remix":
30-
return Remix
31-
case "bun":
32-
return BunFW
33-
case "express":
34-
return Express
35-
}
15+
if !ok {
16+
return UnknownFramework
17+
}
18+
switch framework {
19+
case "next":
20+
return Next
21+
case "nuxt":
22+
return Nuxt
23+
case "astro":
24+
return Astro
25+
case "vite":
26+
return Vite
27+
case "cra":
28+
return CRA
29+
case "angular":
30+
return Angular
31+
case "remix":
32+
return Remix
33+
case "tanstack-start":
34+
return TanstackStart
35+
case "react-router":
36+
return ReactRouter
37+
case "bun":
38+
return BunFW
39+
case "static":
40+
return StaticFW
3641
}
37-
// Python frameworks
3842
case Python:
3943
framework, ok := ctx.Metadata.Properties["pythonRuntime"]
40-
if ok {
41-
switch framework {
42-
case "python":
43-
return PythonFramework
44-
case "django":
45-
return Django
46-
case "flask":
47-
return Flask
48-
case "fastapi":
49-
return FastAPI
50-
case "fasthtml":
51-
return FastHTML
52-
}
44+
if !ok {
45+
return UnknownFramework
46+
}
47+
switch framework {
48+
case "django":
49+
return Django
50+
case "flask":
51+
return Flask
52+
case "fastapi":
53+
return FastAPI
54+
case "fasthtml":
55+
return FastHTML
5356
}
54-
// Go frameworks
5557
case Go:
56-
gin, ok := ctx.Metadata.Properties["goGin"]
57-
if ok && gin == "true" {
58+
if ctx.Metadata.Properties["goGin"] == "true" {
5859
return Gin
5960
}
60-
// Java frameworks
6161
case Java:
62-
javaFramework, ok := ctx.Metadata.Properties["javaFramework"]
63-
if ok {
64-
switch javaFramework {
65-
case "spring-boot":
66-
return SpringBoot
67-
}
62+
if ctx.Metadata.Properties["javaFramework"] == "spring-boot" {
63+
return SpringBoot
6864
}
69-
// PHP frameworks
7065
case PHP:
71-
for _, log := range ctx.Logger.Logs {
72-
if strings.Contains(strings.ToLower(log.Msg), "laravel") {
73-
return Laravel
74-
}
66+
if ctx.Metadata.Properties["phpLaravel"] == "true" {
67+
return Laravel
7568
}
76-
// Ruby frameworks
7769
case Ruby:
78-
railsFramework, ok := ctx.Metadata.Properties["rubyRails"]
79-
if ok && railsFramework == "true" {
70+
if ctx.Metadata.Properties["rubyRails"] == "true" {
8071
return Rails
8172
}
82-
// Rust frameworks
8373
case Rust:
84-
if ctx.Deploy != nil {
85-
for _, variable := range ctx.Deploy.Variables {
86-
if strings.EqualFold(variable, "rocket_address") {
87-
return Rocket
88-
}
74+
if ctx.Deploy == nil {
75+
return UnknownFramework
76+
}
77+
for _, variable := range ctx.Deploy.Variables {
78+
if strings.EqualFold(variable, "rocket_address") {
79+
return Rocket
8980
}
9081
}
9182
}
@@ -97,43 +88,38 @@ func DetectFramework(provider Provider, ctx *generate.GenerateContext) Framework
9788
type Framework string
9889

9990
const (
100-
// * node frameworks
101-
Next Framework = "next"
102-
Astro Framework = "astro"
103-
Vite Framework = "vite"
104-
CRA Framework = "cra"
105-
Angular Framework = "angular"
106-
Remix Framework = "remix"
107-
BunFW Framework = "bun"
108-
Express Framework = "express"
109-
Sveltekit Framework = "sveltekit"
110-
Svelte Framework = "svelte"
111-
Solid Framework = "solid"
112-
Hono Framework = "hono"
113-
TanstackStart Framework = "tanstack-start"
114-
// * python frameworks
115-
PythonFramework Framework = "python" // Sometimes detected as a framework
116-
Django Framework = "django"
117-
Flask Framework = "flask"
118-
FastAPI Framework = "fastapi"
119-
FastHTML Framework = "fasthtml"
120-
// * GO frameworks
121-
Gin Framework = "gin"
122-
// * Java frameworks
123-
SpringBoot Framework = "spring-boot"
124-
// * PHP frameworks
125-
Laravel Framework = "laravel"
126-
// * Ruby frameworks
127-
Rails Framework = "rails"
128-
// * Rust frameworks
129-
Rocket Framework = "rocket"
130-
// * not detected
91+
Next Framework = "next"
92+
Nuxt Framework = "nuxt"
93+
Astro Framework = "astro"
94+
Vite Framework = "vite"
95+
CRA Framework = "cra"
96+
Angular Framework = "angular"
97+
Remix Framework = "remix"
98+
TanstackStart Framework = "tanstack-start"
99+
ReactRouter Framework = "react-router"
100+
BunFW Framework = "bun"
101+
StaticFW Framework = "static"
102+
Sveltekit Framework = "sveltekit"
103+
Svelte Framework = "svelte"
104+
Solid Framework = "solid"
105+
Hono Framework = "hono"
106+
Express Framework = "express"
107+
Django Framework = "django"
108+
Flask Framework = "flask"
109+
FastAPI Framework = "fastapi"
110+
FastHTML Framework = "fasthtml"
111+
Gin Framework = "gin"
112+
SpringBoot Framework = "spring-boot"
113+
Laravel Framework = "laravel"
114+
Rails Framework = "rails"
115+
Rocket Framework = "rocket"
131116
UnknownFramework Framework = "unknown"
132117
)
133118

134119
var allFrameworks = []Framework{
135-
Next, Astro, Vite, CRA, Angular, Remix, BunFW, Express, Sveltekit, Svelte, Solid, Hono, TanstackStart,
136-
PythonFramework, Django, Flask, FastAPI, FastHTML,
120+
Next, Nuxt, Astro, Vite, CRA, Angular, Remix, TanstackStart, ReactRouter, BunFW, StaticFW,
121+
Sveltekit, Svelte, Solid, Hono, Express,
122+
Django, Flask, FastAPI, FastHTML,
137123
Gin,
138124
SpringBoot,
139125
Laravel,

internal/sourceanalyzer/enum/provider.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ import (
88

99
// Parses detected providers into Provider
1010
func ParseProvider(detectedProviders []string) Provider {
11-
provider := ""
12-
// Always use the first one?
13-
if len(detectedProviders) > 0 {
14-
provider = detectedProviders[0]
11+
if len(detectedProviders) == 0 {
12+
return UnknownProvider
1513
}
1614

17-
switch provider {
15+
switch detectedProviders[0] {
1816
case "node":
1917
return Node
2018
case "deno":
@@ -33,10 +31,18 @@ func ParseProvider(detectedProviders []string) Provider {
3331
return Ruby
3432
case "rust":
3533
return Rust
36-
case "elixir":
34+
case "elixir", "Elixir":
3735
return Elixir
3836
case "staticfile":
3937
return Staticfile
38+
case "dotnet", "Dotnet":
39+
return Dotnet
40+
case "cpp":
41+
return Cpp
42+
case "gleam":
43+
return Gleam
44+
case "shell":
45+
return Shell
4046
default:
4147
return UnknownProvider
4248
}
@@ -57,10 +63,14 @@ const (
5763
Rust Provider = "rust"
5864
Elixir Provider = "elixir"
5965
Staticfile Provider = "staticfile"
66+
Dotnet Provider = "dotnet"
67+
Cpp Provider = "cpp"
68+
Gleam Provider = "gleam"
69+
Shell Provider = "shell"
6070
UnknownProvider Provider = "unknown"
6171
)
6272

63-
var allProviders = []Provider{Node, Deno, Bun, Go, Java, PHP, Python, Ruby, Rust, Elixir, Staticfile, UnknownProvider}
73+
var allProviders = []Provider{Node, Deno, Bun, Go, Java, PHP, Python, Ruby, Rust, Elixir, Staticfile, Dotnet, Cpp, Gleam, Shell, UnknownProvider}
6474

6575
// Values provides list valid values for Enum.
6676
func (Provider) Values() (kinds []string) {

pkg/builder/internal/buildkit/buildkit.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
"time"
99

10+
"github.com/containerd/platforms"
1011
"github.com/docker/cli/cli/config/configfile"
1112
"github.com/docker/cli/cli/config/types"
1213
"github.com/moby/buildkit/client"
@@ -15,6 +16,7 @@ import (
1516
"github.com/moby/buildkit/session/auth/authprovider"
1617
"github.com/moby/buildkit/session/secrets/secretsprovider"
1718
"github.com/moby/buildkit/util/appcontext"
19+
specs "github.com/opencontainers/image-spec/specs-go/v1"
1820
rpBuildkit "github.com/railwayapp/railpack/buildkit"
1921
"github.com/railwayapp/railpack/core/plan"
2022
"github.com/tonistiigi/fsutil"
@@ -25,7 +27,7 @@ import (
2527
type BuildWithBuildkitClientOptions struct {
2628
ImageName string
2729
RailpackBuildPlan *plan.BuildPlan
28-
Platform rpBuildkit.BuildPlatform
30+
Platform specs.Platform
2931
SecretsHash string
3032
Secrets map[string]string
3133
CacheKey string
@@ -80,8 +82,8 @@ func BuildWithBuildkitClient(cfg *config.Config, appDir string, opts BuildWithBu
8082
}
8183

8284
buildPlatform := opts.Platform
83-
if (buildPlatform == rpBuildkit.BuildPlatform{}) {
84-
buildPlatform = rpBuildkit.DetermineBuildPlatformFromHost()
85+
if buildPlatform.OS == "" {
86+
buildPlatform, _ = rpBuildkit.ParsePlatformWithDefaults("")
8587
}
8688

8789
// Setup channel for progress monitoring
@@ -114,7 +116,7 @@ func BuildWithBuildkitClient(cfg *config.Config, appDir string, opts BuildWithBu
114116
return fmt.Errorf("error creating context FS: %w", err)
115117
}
116118

117-
log.Infof("Building image for %s with BuildKit %s", buildPlatform.String(), info.BuildkitVersion.Version)
119+
log.Infof("Building image for %s with BuildKit %s", platforms.Format(buildPlatform), info.BuildkitVersion.Version)
118120
log.Infof("Using context path: %s", contextPath)
119121

120122
secretsMap := make(map[string][]byte)
@@ -149,7 +151,7 @@ func BuildWithBuildkitClient(cfg *config.Config, appDir string, opts BuildWithBu
149151

150152
// Create the auth provider configuration
151153
authProviderCfg := authprovider.DockerAuthProviderConfig{
152-
ConfigFile: configFile,
154+
AuthConfigProvider: authprovider.LoadAuthConfig(configFile),
153155
}
154156

155157
sessionAttachables = append(sessionAttachables, authprovider.NewDockerAuthProvider(authProviderCfg))
@@ -205,13 +207,12 @@ func BuildWithBuildkitClient(cfg *config.Config, appDir string, opts BuildWithBu
205207
"filename": dockerfileBasename,
206208
}
207209
} else if opts.RailpackBuildPlan != nil {
208-
// Using RailPack BuildPlan
209210
buildPlatform := opts.Platform
210-
if (buildPlatform == rpBuildkit.BuildPlatform{}) {
211-
buildPlatform = rpBuildkit.DetermineBuildPlatformFromHost()
211+
if buildPlatform.OS == "" {
212+
buildPlatform, _ = rpBuildkit.ParsePlatformWithDefaults("")
212213
}
213214

214-
log.Infof("Building image for %s with BuildKit %s", buildPlatform.String(), info.BuildkitVersion.Version)
215+
log.Infof("Building image for %s with BuildKit %s", platforms.Format(buildPlatform), info.BuildkitVersion.Version)
215216

216217
llbState, image, err := rpBuildkit.ConvertPlanToLLB(opts.RailpackBuildPlan, rpBuildkit.ConvertPlanOptions{
217218
BuildPlatform: buildPlatform,

0 commit comments

Comments
 (0)