Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217
google.golang.org/grpc v1.79.3
google.golang.org/protobuf v1.36.11
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand Down Expand Up @@ -161,7 +162,6 @@ require (
google.golang.org/genai v1.30.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
Expand Down
4 changes: 4 additions & 0 deletions src/pkg/cli/compose/fixup.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func FixupServices(ctx context.Context, provider client.Provider, project *compo
for name, model := range project.Models {
model.Name = name // ensure the model has a name
svccfg := fixupModel(model, project, accountInfo)
if svccfg.Extensions == nil {
svccfg.Extensions = make(map[string]interface{})
}
svccfg.Extensions["x-defang-llm"] = true
project.Services[svccfg.Name] = *svccfg
}

Expand Down
5 changes: 2 additions & 3 deletions src/pkg/cli/compose/fixup_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package compose

import (
"encoding/json"
"strings"
"testing"

Expand All @@ -10,6 +9,7 @@ import (
composeTypes "github.com/compose-spec/compose-go/v2/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
Comment thread
lionello marked this conversation as resolved.
)

func TestFixup(t *testing.T) {
Expand All @@ -33,8 +33,7 @@ func TestFixup(t *testing.T) {
services[svc.Name] = svc
}

// Convert the protobuf services to pretty JSON for comparison (YAML would include all the zero values)
actual, err := json.MarshalIndent(services, "", " ")
actual, err := yaml.Marshal(services)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion src/testdata/Fancy-Proj_Dir/compose.yaml.fixup
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
33 changes: 11 additions & 22 deletions src/testdata/alttestproj/compose.yaml.fixup
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
{
"dfnx": {
"build": {
"context": ".",
"dockerfile": "Dockerfile"
},
"command": null,
"deploy": {
"resources": {
"limits": {
"memory": "268435456"
}
},
"placement": {}
},
"entrypoint": null,
"networks": {
"default": null
},
"restart": "unless-stopped"
}
}
dfnx:
build:
context: .
dockerfile: Dockerfile
deploy:
resources:
limits:
memory: "268435456"
networks:
default: null
restart: unless-stopped
72 changes: 28 additions & 44 deletions src/testdata/ambiguous-strings/compose.yaml.fixup
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
{
"a": {
"build": {
"context": ".",
"dockerfile": "*Railpack",
"args": {
"GITSHA": "65e1234",
"INT": "1234",
"VERSION": "65e1234"
}
},
"command": null,
"entrypoint": null,
"environment": {
"GITSHA": "65e1234",
"INT": "1234",
"VERSION": "65e1234"
},
"networks": {
"default": null
}
},
"b": {
"build": {
"context": ".",
"dockerfile": "*Railpack",
"args": {
"GITSHA": "65e1234",
"INT": "1234",
"VERSION": "65e1234"
}
},
"command": null,
"entrypoint": null,
"environment": {
"GITSHA": "65e1234",
"INT": "1234",
"VERSION": "65e1234"
},
"networks": {
"default": null
}
}
}
a:
build:
context: .
dockerfile: '*Railpack'
args:
GITSHA: 65e1234
INT: "1234"
VERSION: 65e1234
environment:
GITSHA: 65e1234
INT: "1234"
VERSION: 65e1234
networks:
default: null
b:
build:
context: .
dockerfile: '*Railpack'
args:
GITSHA: 65e1234
INT: "1234"
VERSION: 65e1234
environment:
GITSHA: 65e1234
INT: "1234"
VERSION: 65e1234
networks:
default: null
53 changes: 18 additions & 35 deletions src/testdata/base-image/compose.yaml.fixup
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
{
"mutiple-images": {
"build": {
"context": "./multiple-images",
"dockerfile": "Dockerfile"
},
"command": null,
"entrypoint": null,
"networks": {
"default": null
}
},
"no-dockerfile": {
"build": {
"context": ".",
"dockerfile": "*Railpack"
},
"command": null,
"entrypoint": null,
"networks": {
"default": null
}
},
"one-image": {
"build": {
"context": "./one_image",
"dockerfile": "Dockerfile"
},
"command": null,
"entrypoint": null,
"networks": {
"default": null
}
}
}
mutiple-images:
build:
context: ./multiple-images
dockerfile: Dockerfile
networks:
default: null
no-dockerfile:
build:
context: .
dockerfile: '*Railpack'
networks:
default: null
one-image:
build:
context: ./one_image
dockerfile: Dockerfile
networks:
default: null
14 changes: 4 additions & 10 deletions src/testdata/build-image/compose.yaml.fixup
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
"app": {
"command": null,
"entrypoint": null,
"image": "myapp:latest",
"networks": {
"default": null
}
}
}
app:
image: myapp:latest
networks:
default: null
71 changes: 26 additions & 45 deletions src/testdata/build/compose.yaml.fixup
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
{
"build1": {
"build": {
"context": ".",
"dockerfile": "Dockerfile",
"args": {
"BASE_IMAGE": "nginx"
},
"target": "test",
"shm_size": "2147483648"
},
"command": null,
"entrypoint": null,
"networks": {
"default": null
}
},
"build2": {
"build": {
"context": ".",
"dockerfile": "Dockerfile",
"args": {
"BASE_IMAGE": "alpine"
},
"target": "test",
"shm_size": "2147483648"
},
"command": null,
"entrypoint": null,
"networks": {
"default": null
}
},
"normalized": {
"build": {
"context": ".",
"dockerfile": "Dockerfile"
},
"command": null,
"entrypoint": null,
"networks": {
"default": null
}
}
}
build1:
build:
context: .
dockerfile: Dockerfile
args:
BASE_IMAGE: nginx
target: test
shm_size: "2147483648"
networks:
default: null
build2:
build:
context: .
dockerfile: Dockerfile
args:
BASE_IMAGE: alpine
target: test
shm_size: "2147483648"
networks:
default: null
normalized:
build:
context: .
dockerfile: Dockerfile
networks:
default: null
33 changes: 11 additions & 22 deletions src/testdata/bun-in-compose/compose.yaml.fixup
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
{
"bun": {
"build": {
"context": "./app",
"dockerfile": "Dockerfile"
},
"command": null,
"entrypoint": null,
"networks": {
"default": null
},
"restart": "unless-stopped"
},
"server": {
"command": null,
"entrypoint": null,
"image": "oven/bun:latest",
"networks": {
"default": null
}
}
}
bun:
build:
context: ./app
dockerfile: Dockerfile
networks:
default: null
restart: unless-stopped
server:
image: oven/bun:latest
networks:
default: null
33 changes: 11 additions & 22 deletions src/testdata/bun-in-dockerfile/compose.yaml.fixup
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
{
"bun": {
"build": {
"context": "./app",
"dockerfile": "Dockerfile"
},
"command": null,
"entrypoint": null,
"networks": {
"default": null
},
"restart": "unless-stopped"
},
"server": {
"command": null,
"entrypoint": null,
"image": "alpine:latest",
"networks": {
"default": null
}
}
}
bun:
build:
context: ./app
dockerfile: Dockerfile
networks:
default: null
restart: unless-stopped
server:
image: alpine:latest
networks:
default: null
Loading
Loading