diff --git a/src/go.mod b/src/go.mod index 21267dbd8..299fcb8ff 100644 --- a/src/go.mod +++ b/src/go.mod @@ -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 ( @@ -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 ( diff --git a/src/pkg/cli/compose/fixup.go b/src/pkg/cli/compose/fixup.go index 8d9dd8f9f..a90bb201d 100644 --- a/src/pkg/cli/compose/fixup.go +++ b/src/pkg/cli/compose/fixup.go @@ -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 } diff --git a/src/pkg/cli/compose/fixup_test.go b/src/pkg/cli/compose/fixup_test.go index 052a6a0b2..efcc392a6 100644 --- a/src/pkg/cli/compose/fixup_test.go +++ b/src/pkg/cli/compose/fixup_test.go @@ -1,7 +1,6 @@ package compose import ( - "encoding/json" "strings" "testing" @@ -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" ) func TestFixup(t *testing.T) { @@ -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) } diff --git a/src/testdata/Fancy-Proj_Dir/compose.yaml.fixup b/src/testdata/Fancy-Proj_Dir/compose.yaml.fixup index 9e26dfeeb..0967ef424 100644 --- a/src/testdata/Fancy-Proj_Dir/compose.yaml.fixup +++ b/src/testdata/Fancy-Proj_Dir/compose.yaml.fixup @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/src/testdata/alttestproj/compose.yaml.fixup b/src/testdata/alttestproj/compose.yaml.fixup index f2186d249..6610807c1 100644 --- a/src/testdata/alttestproj/compose.yaml.fixup +++ b/src/testdata/alttestproj/compose.yaml.fixup @@ -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" - } -} \ No newline at end of file +dfnx: + build: + context: . + dockerfile: Dockerfile + deploy: + resources: + limits: + memory: "268435456" + networks: + default: null + restart: unless-stopped diff --git a/src/testdata/ambiguous-strings/compose.yaml.fixup b/src/testdata/ambiguous-strings/compose.yaml.fixup index c8ec19a83..28d50e53e 100644 --- a/src/testdata/ambiguous-strings/compose.yaml.fixup +++ b/src/testdata/ambiguous-strings/compose.yaml.fixup @@ -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 - } - } -} \ No newline at end of file +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 diff --git a/src/testdata/base-image/compose.yaml.fixup b/src/testdata/base-image/compose.yaml.fixup index 7c57b51d7..d5fd88676 100644 --- a/src/testdata/base-image/compose.yaml.fixup +++ b/src/testdata/base-image/compose.yaml.fixup @@ -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 - } - } -} \ No newline at end of file +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 diff --git a/src/testdata/build-image/compose.yaml.fixup b/src/testdata/build-image/compose.yaml.fixup index 7a1dd6617..a99c75e34 100644 --- a/src/testdata/build-image/compose.yaml.fixup +++ b/src/testdata/build-image/compose.yaml.fixup @@ -1,10 +1,4 @@ -{ - "app": { - "command": null, - "entrypoint": null, - "image": "myapp:latest", - "networks": { - "default": null - } - } -} \ No newline at end of file +app: + image: myapp:latest + networks: + default: null diff --git a/src/testdata/build/compose.yaml.fixup b/src/testdata/build/compose.yaml.fixup index 3aef658cc..97b646688 100644 --- a/src/testdata/build/compose.yaml.fixup +++ b/src/testdata/build/compose.yaml.fixup @@ -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 - } - } -} \ No newline at end of file +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 diff --git a/src/testdata/bun-in-compose/compose.yaml.fixup b/src/testdata/bun-in-compose/compose.yaml.fixup index ae038f586..7449dca59 100644 --- a/src/testdata/bun-in-compose/compose.yaml.fixup +++ b/src/testdata/bun-in-compose/compose.yaml.fixup @@ -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 - } - } -} \ No newline at end of file +bun: + build: + context: ./app + dockerfile: Dockerfile + networks: + default: null + restart: unless-stopped +server: + image: oven/bun:latest + networks: + default: null diff --git a/src/testdata/bun-in-dockerfile/compose.yaml.fixup b/src/testdata/bun-in-dockerfile/compose.yaml.fixup index 44523e39e..4b8f64645 100644 --- a/src/testdata/bun-in-dockerfile/compose.yaml.fixup +++ b/src/testdata/bun-in-dockerfile/compose.yaml.fixup @@ -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 - } - } -} \ No newline at end of file +bun: + build: + context: ./app + dockerfile: Dockerfile + networks: + default: null + restart: unless-stopped +server: + image: alpine:latest + networks: + default: null diff --git a/src/testdata/compose-go-warn/compose.yaml.fixup b/src/testdata/compose-go-warn/compose.yaml.fixup index 3e83740cf..8fcc982ff 100644 --- a/src/testdata/compose-go-warn/compose.yaml.fixup +++ b/src/testdata/compose-go-warn/compose.yaml.fixup @@ -1,18 +1,9 @@ -{ - "echo": { - "command": null, - "entrypoint": null, - "image": "ealen/echo-server", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 80, - "protocol": "tcp", - "app_protocol": "http" - } - ] - } -} \ No newline at end of file +echo: + image: ealen/echo-server + networks: + default: null + ports: + - mode: ingress + target: 80 + protocol: tcp + app_protocol: http diff --git a/src/testdata/configdetection/compose.yaml.fixup b/src/testdata/configdetection/compose.yaml.fixup index cbb7598aa..7033ce2ea 100644 --- a/src/testdata/configdetection/compose.yaml.fixup +++ b/src/testdata/configdetection/compose.yaml.fixup @@ -1,18 +1,11 @@ -{ - "configdetection": { - "command": null, - "entrypoint": null, - "environment": { - "API_KEY": "50m34p1k3y", - "AWS_CLIENT_ID": "AROA1234567890ABCDEF", - "GH_PAT": "ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890", - "HIGH_ENTROPY_STRING": "VEfk5vO0Q53VkK_uicor", - "MY_URL": "https://user:p455w0rd@example.com", - "NOT_SENSITIVE": "notsensitive" - }, - "image": "alpine", - "networks": { - "default": null - } - } -} \ No newline at end of file +configdetection: + environment: + API_KEY: 50m34p1k3y + AWS_CLIENT_ID: AROA1234567890ABCDEF + GH_PAT: ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890 + HIGH_ENTROPY_STRING: VEfk5vO0Q53VkK_uicor + MY_URL: https://user:p455w0rd@example.com + NOT_SENSITIVE: notsensitive + image: alpine + networks: + default: null diff --git a/src/testdata/configoverride/compose.yaml.fixup b/src/testdata/configoverride/compose.yaml.fixup index d0ff00364..ef6fd7e11 100644 --- a/src/testdata/configoverride/compose.yaml.fixup +++ b/src/testdata/configoverride/compose.yaml.fixup @@ -1,13 +1,6 @@ -{ - "service1": { - "command": null, - "entrypoint": null, - "environment": { - "VAR1": null - }, - "image": "alpine", - "networks": { - "default": null - } - } -} \ No newline at end of file +service1: + environment: + VAR1: null + image: alpine + networks: + default: null diff --git a/src/testdata/debugproj/compose.yaml.fixup b/src/testdata/debugproj/compose.yaml.fixup index 1e8051211..2e76dab07 100644 --- a/src/testdata/debugproj/compose.yaml.fixup +++ b/src/testdata/debugproj/compose.yaml.fixup @@ -1,24 +1,12 @@ -{ - "failing": { - "build": { - "context": "./app", - "dockerfile": "Dockerfile" - }, - "command": null, - "entrypoint": null, - "networks": { - "default": null - } - }, - "ok": { - "build": { - "context": ".", - "dockerfile": "Dockerfile" - }, - "command": null, - "entrypoint": null, - "networks": { - "default": null - } - } -} \ No newline at end of file +failing: + build: + context: ./app + dockerfile: Dockerfile + networks: + default: null +ok: + build: + context: . + dockerfile: Dockerfile + networks: + default: null diff --git a/src/testdata/dependson/compose.yaml.fixup b/src/testdata/dependson/compose.yaml.fixup index ec9d9b4d0..4442afa97 100644 --- a/src/testdata/dependson/compose.yaml.fixup +++ b/src/testdata/dependson/compose.yaml.fixup @@ -1,48 +1,27 @@ -{ - "service1": { - "command": null, - "depends_on": { - "service2": { - "condition": "service_started", - "required": true - }, - "service3": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "image": "alpine", - "networks": { - "default": null - } - }, - "service2": { - "command": null, - "depends_on": { - "service3": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "image": "alpine", - "networks": { - "default": null - } - }, - "service3": { - "command": null, - "depends_on": { - "service3": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "image": "alpine", - "networks": { - "default": null - } - } -} \ No newline at end of file +service1: + depends_on: + service2: + condition: service_started + required: true + service3: + condition: service_started + required: true + image: alpine + networks: + default: null +service2: + depends_on: + service3: + condition: service_started + required: true + image: alpine + networks: + default: null +service3: + depends_on: + service3: + condition: service_started + required: true + image: alpine + networks: + default: null diff --git a/src/testdata/dockerfile-validation-errors/compose.yaml.fixup b/src/testdata/dockerfile-validation-errors/compose.yaml.fixup index bec623d3f..2a219445e 100644 --- a/src/testdata/dockerfile-validation-errors/compose.yaml.fixup +++ b/src/testdata/dockerfile-validation-errors/compose.yaml.fixup @@ -1,21 +1,11 @@ -{ - "invalid-dockerfile": { - "build": { - "context": ".", - "dockerfile": "Dockerfile.invalid" - }, - "command": null, - "entrypoint": null, - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 8080, - "protocol": "tcp", - "app_protocol": "http" - } - ] - } -} \ No newline at end of file +invalid-dockerfile: + build: + context: . + dockerfile: Dockerfile.invalid + networks: + default: null + ports: + - mode: ingress + target: 8080 + protocol: tcp + app_protocol: http diff --git a/src/testdata/empty/compose.yaml.fixup b/src/testdata/empty/compose.yaml.fixup index 9e26dfeeb..0967ef424 100644 --- a/src/testdata/empty/compose.yaml.fixup +++ b/src/testdata/empty/compose.yaml.fixup @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/src/testdata/emptyenv/compose.yaml.fixup b/src/testdata/emptyenv/compose.yaml.fixup index 1b4bf9201..2746b6a83 100644 --- a/src/testdata/emptyenv/compose.yaml.fixup +++ b/src/testdata/emptyenv/compose.yaml.fixup @@ -1,20 +1,11 @@ -{ - "emptyenv": { - "build": { - "context": ".", - "dockerfile": "Dockerfile", - "args": { - "ARG2": "" - } - }, - "command": null, - "entrypoint": null, - "environment": { - "ENV1": null, - "ENV2": "" - }, - "networks": { - "default": null - } - } -} \ No newline at end of file +emptyenv: + build: + context: . + dockerfile: Dockerfile + args: + ARG2: "" + environment: + ENV1: null + ENV2: "" + networks: + default: null diff --git a/src/testdata/extends/compose.yaml.fixup b/src/testdata/extends/compose.yaml.fixup index 463e5b1c1..6bfc09028 100644 --- a/src/testdata/extends/compose.yaml.fixup +++ b/src/testdata/extends/compose.yaml.fixup @@ -1,109 +1,68 @@ -{ - "array-override": { - "command": null, - "entrypoint": null, - "environment": { - "EMPTY_VALUE": "bar", - "NEW_VALUE": "bar", - "NO_VALUE": "bar", - "WITH_VALUE": "bar" - }, - "image": "bogus", - "networks": { - "default": null - } - }, - "array-reset": { - "command": null, - "entrypoint": null, - "image": "bogus", - "networks": { - "default": null - } - }, - "array-set": { - "command": null, - "entrypoint": null, - "environment": { - "BASE_ONLY": "foo", - "EMPTY_VALUE": "bar", - "NEW_VALUE": "bar", - "NO_VALUE": "bar", - "WITH_VALUE": "bar" - }, - "image": "bogus", - "networks": { - "default": null - } - }, - "array-unset": { - "command": null, - "entrypoint": null, - "environment": { - "BASE_ONLY": "foo", - "EMPTY_VALUE": null, - "NEW_VALUE": null, - "NO_VALUE": null, - "WITH_VALUE": null - }, - "image": "bogus", - "networks": { - "default": null - } - }, - "map-override": { - "command": null, - "entrypoint": null, - "environment": { - "EMPTY_VALUE": "bar", - "NEW_VALUE": "bar", - "NO_VALUE": "bar", - "WITH_VALUE": "bar" - }, - "image": "bogus", - "networks": { - "default": null - } - }, - "map-reset": { - "command": null, - "entrypoint": null, - "environment": { - "BASE_ONLY": "foo" - }, - "image": "bogus", - "networks": { - "default": null - } - }, - "map-set": { - "command": null, - "entrypoint": null, - "environment": { - "BASE_ONLY": "foo", - "EMPTY_VALUE": "bar", - "NEW_VALUE": "bar", - "NO_VALUE": "bar", - "WITH_VALUE": "bar" - }, - "image": "bogus", - "networks": { - "default": null - } - }, - "map-unset": { - "command": null, - "entrypoint": null, - "environment": { - "BASE_ONLY": "foo", - "EMPTY_VALUE": null, - "NEW_VALUE": null, - "NO_VALUE": null, - "WITH_VALUE": null - }, - "image": "bogus", - "networks": { - "default": null - } - } -} \ No newline at end of file +array-override: + environment: + EMPTY_VALUE: bar + NEW_VALUE: bar + NO_VALUE: bar + WITH_VALUE: bar + image: bogus + networks: + default: null +array-reset: + image: bogus + networks: + default: null +array-set: + environment: + BASE_ONLY: foo + EMPTY_VALUE: bar + NEW_VALUE: bar + NO_VALUE: bar + WITH_VALUE: bar + image: bogus + networks: + default: null +array-unset: + environment: + BASE_ONLY: foo + EMPTY_VALUE: null + NEW_VALUE: null + NO_VALUE: null + WITH_VALUE: null + image: bogus + networks: + default: null +map-override: + environment: + EMPTY_VALUE: bar + NEW_VALUE: bar + NO_VALUE: bar + WITH_VALUE: bar + image: bogus + networks: + default: null +map-reset: + environment: + BASE_ONLY: foo + image: bogus + networks: + default: null +map-set: + environment: + BASE_ONLY: foo + EMPTY_VALUE: bar + NEW_VALUE: bar + NO_VALUE: bar + WITH_VALUE: bar + image: bogus + networks: + default: null +map-unset: + environment: + BASE_ONLY: foo + EMPTY_VALUE: null + NEW_VALUE: null + NO_VALUE: null + WITH_VALUE: null + image: bogus + networks: + default: null diff --git a/src/testdata/fixupenv/compose.yaml.fixup b/src/testdata/fixupenv/compose.yaml.fixup index f5de386c1..232be2a81 100644 --- a/src/testdata/fixupenv/compose.yaml.fixup +++ b/src/testdata/fixupenv/compose.yaml.fixup @@ -1,103 +1,57 @@ -{ - "Mistral": { - "command": null, - "entrypoint": null, - "image": "mistral:latest", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 8000, - "protocol": "tcp" - } - ] - }, - "fixup-args": { - "build": { - "context": ".", - "dockerfile": "Dockerfile", - "args": { - "API_URL": "http://mock-mistral:8000" - } - }, - "command": null, - "entrypoint": null, - "networks": { - "default": null - } - }, - "ingress-service": { - "command": null, - "entrypoint": null, - "image": "somedb:latest", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 5432, - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "refer-self-build-arg": { - "build": { - "context": ".", - "dockerfile": "Dockerfile", - "args": { - "CONFIG4": "refer-self-env.fixupenv.tenant2.defang.app" - } - }, - "command": null, - "entrypoint": null, - "networks": { - "default": null - } - }, - "refer-self-env": { - "command": null, - "entrypoint": null, - "environment": { - "CONFIG3": "refer-self-env.fixupenv.tenant2.defang.app" - }, - "image": "service:latest", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 5678, - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "ui": { - "command": null, - "entrypoint": null, - "environment": { - "API_URL": "http://mock-mistral:8000", - "SENSITIVE_DATA": null - }, - "image": "ui:latest", - "networks": { - "default": null - } - }, - "use-ingress-service": { - "command": null, - "entrypoint": null, - "environment": { - "UI_URL": "ingress-service.fixupenv.tenant2.defang.app:5432" - }, - "image": "service:latest", - "networks": { - "default": null - } - } -} \ No newline at end of file +Mistral: + image: mistral:latest + networks: + default: null + ports: + - mode: host + target: 8000 + protocol: tcp +fixup-args: + build: + context: . + dockerfile: Dockerfile + args: + API_URL: http://mock-mistral:8000 + networks: + default: null +ingress-service: + image: somedb:latest + networks: + default: null + ports: + - mode: ingress + target: 5432 + protocol: tcp + app_protocol: http +refer-self-build-arg: + build: + context: . + dockerfile: Dockerfile + args: + CONFIG4: refer-self-env.fixupenv.tenant2.defang.app + networks: + default: null +refer-self-env: + environment: + CONFIG3: refer-self-env.fixupenv.tenant2.defang.app + image: service:latest + networks: + default: null + ports: + - mode: ingress + target: 5678 + protocol: tcp + app_protocol: http +ui: + environment: + API_URL: http://mock-mistral:8000 + SENSITIVE_DATA: null + image: ui:latest + networks: + default: null +use-ingress-service: + environment: + UI_URL: ingress-service.fixupenv.tenant2.defang.app:5432 + image: service:latest + networks: + default: null diff --git a/src/testdata/gpu/compose.yaml.fixup b/src/testdata/gpu/compose.yaml.fixup index e4cdfb7ec..bd571d1fe 100644 --- a/src/testdata/gpu/compose.yaml.fixup +++ b/src/testdata/gpu/compose.yaml.fixup @@ -1,25 +1,11 @@ -{ - "mistral": { - "command": null, - "deploy": { - "replicas": 1, - "resources": { - "reservations": { - "devices": [ - { - "capabilities": [ - "gpu" - ], - "count": -1 - } - ] - } - }, - "placement": {} - }, - "entrypoint": null, - "networks": { - "default": null - } - } -} \ No newline at end of file +mistral: + deploy: + replicas: 1 + resources: + reservations: + devices: + - capabilities: + - gpu + count: -1 + networks: + default: null diff --git a/src/testdata/healthcheck/compose.yaml.fixup b/src/testdata/healthcheck/compose.yaml.fixup index 42dfd5737..34ef42647 100644 --- a/src/testdata/healthcheck/compose.yaml.fixup +++ b/src/testdata/healthcheck/compose.yaml.fixup @@ -1,150 +1,94 @@ -{ - "cmd-shell": { - "command": null, - "entrypoint": null, - "healthcheck": { - "test": [ - "CMD-SHELL", - "echo hello", - "second line" - ] - }, - "image": "alpine", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 5000, - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "curl": { - "command": null, - "entrypoint": null, - "healthcheck": { - "test": [ - "CMD", - "curl", - "-f", - "localhost" - ] - }, - "image": "curl", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 80, - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "flask1": { - "command": null, - "entrypoint": null, - "healthcheck": { - "test": [ - "CMD", - "python", - "-c", - "import sys, urllib.request;urllib.request.urlopen(sys.argv[1]).read()", - "http://localhost/" - ], - "timeout": "1s" - }, - "image": "flask", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 5000, - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "flask2": { - "command": null, - "entrypoint": null, - "healthcheck": { - "test": [ - "CMD", - "python", - "-c", - "import urllib.request;urllib.request.urlopen('http://127.0.0.1/path').read()" - ], - "interval": "10s" - }, - "image": "flask", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 5000, - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "none": { - "command": null, - "entrypoint": null, - "healthcheck": { - "test": [ - "NONE", - "ignored" - ], - "timeout": "1s", - "interval": "1m0s", - "retries": 3 - }, - "image": "alpine", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 5000, - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "wget": { - "command": null, - "entrypoint": null, - "healthcheck": { - "test": [ - "CMD", - "wget", - "-q", - "--spider", - "localhost:80" - ] - }, - "image": "alpine", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 80, - "protocol": "tcp", - "app_protocol": "http" - } - ] - } -} \ No newline at end of file +cmd-shell: + healthcheck: + test: + - CMD-SHELL + - echo hello + - second line + image: alpine + networks: + default: null + ports: + - mode: ingress + target: 5000 + protocol: tcp + app_protocol: http +curl: + healthcheck: + test: + - CMD + - curl + - -f + - localhost + image: curl + networks: + default: null + ports: + - mode: ingress + target: 80 + protocol: tcp + app_protocol: http +flask1: + healthcheck: + test: + - CMD + - python + - -c + - import sys, urllib.request;urllib.request.urlopen(sys.argv[1]).read() + - http://localhost/ + timeout: 1s + image: flask + networks: + default: null + ports: + - mode: ingress + target: 5000 + protocol: tcp + app_protocol: http +flask2: + healthcheck: + test: + - CMD + - python + - -c + - import urllib.request;urllib.request.urlopen('http://127.0.0.1/path').read() + interval: 10s + image: flask + networks: + default: null + ports: + - mode: ingress + target: 5000 + protocol: tcp + app_protocol: http +none: + healthcheck: + test: + - NONE + - ignored + timeout: 1s + interval: 1m0s + retries: 3 + image: alpine + networks: + default: null + ports: + - mode: ingress + target: 5000 + protocol: tcp + app_protocol: http +wget: + healthcheck: + test: + - CMD + - wget + - -q + - --spider + - localhost:80 + image: alpine + networks: + default: null + ports: + - mode: ingress + target: 80 + protocol: tcp + app_protocol: http diff --git a/src/testdata/heroku/compose.yaml.fixup b/src/testdata/heroku/compose.yaml.fixup index 14425bd1e..63fef888a 100644 --- a/src/testdata/heroku/compose.yaml.fixup +++ b/src/testdata/heroku/compose.yaml.fixup @@ -1,57 +1,32 @@ -{ - "app": { - "build": { - "context": ".", - "dockerfile": "*Railpack" - }, - "command": null, - "depends_on": { - "postgres": { - "condition": "service_started", - "required": true - }, - "redis": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "environment": { - "DATABASE_URL": "postgres://postgres:postgres@mock-postgres:5432/app", - "REDIS_URL": "redis://mock-redis:5739" - }, - "networks": { - "default": null - } - }, - "postgres": { - "command": null, - "entrypoint": null, - "image": "postgres:15-alpine", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 5432, - "protocol": "tcp" - } - ] - }, - "redis": { - "command": null, - "entrypoint": null, - "image": "redis:7-alpine", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 6379, - "protocol": "tcp" - } - ] - } -} \ No newline at end of file +app: + build: + context: . + dockerfile: '*Railpack' + depends_on: + postgres: + condition: service_started + required: true + redis: + condition: service_started + required: true + environment: + DATABASE_URL: postgres://postgres:postgres@mock-postgres:5432/app + REDIS_URL: redis://mock-redis:5739 + networks: + default: null +postgres: + image: postgres:15-alpine + networks: + default: null + ports: + - mode: host + target: 5432 + protocol: tcp +redis: + image: redis:7-alpine + networks: + default: null + ports: + - mode: host + target: 6379 + protocol: tcp diff --git a/src/testdata/interpolate/compose.yaml.fixup b/src/testdata/interpolate/compose.yaml.fixup index 6af7c87b0..62ce67c70 100644 --- a/src/testdata/interpolate/compose.yaml.fixup +++ b/src/testdata/interpolate/compose.yaml.fixup @@ -1,21 +1,14 @@ -{ - "interpolate": { - "command": null, - "entrypoint": null, - "environment": { - "BRACED": "interpolate", - "DB": "postgres://user:${POSTGRES_PASSWORD}@db:5432/db", - "NAME": "interpolate", - "NODE_ENV": "${NODE_ENV}", - "NOP": "abc$def", - "NOP_BRACED": "abc${def}", - "PORT": "8080", - "VAR1": "${VAR1}", - "interpolate": "value" - }, - "image": "alpine", - "networks": { - "default": null - } - } -} \ No newline at end of file +interpolate: + environment: + BRACED: interpolate + DB: postgres://user:${POSTGRES_PASSWORD}@db:5432/db + NAME: interpolate + NODE_ENV: ${NODE_ENV} + NOP: abc$def + NOP_BRACED: abc${def} + PORT: "8080" + VAR1: ${VAR1} + interpolate: value + image: alpine + networks: + default: null diff --git a/src/testdata/llm/compose.yaml.fixup b/src/testdata/llm/compose.yaml.fixup index 0978b0653..277f796ad 100644 --- a/src/testdata/llm/compose.yaml.fixup +++ b/src/testdata/llm/compose.yaml.fixup @@ -1,57 +1,34 @@ -{ - "alt-repo": { - "command": null, - "entrypoint": null, - "image": "altrepo.com/litellm:latest", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 4000, - "protocol": "tcp" - } - ] - }, - "gateway-with-ports": { - "command": null, - "entrypoint": null, - "image": "litellm/litellm:latest", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 5678, - "published": "5678", - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "gateway-without-ports": { - "command": null, - "entrypoint": null, - "image": "litellm/litellm:latest", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 4000, - "protocol": "tcp" - } - ] - }, - "llm": { - "command": null, - "entrypoint": null, - "image": "llm:latest", - "networks": { - "default": null - } - } -} \ No newline at end of file +alt-repo: + image: altrepo.com/litellm:latest + networks: + default: null + ports: + - mode: host + target: 4000 + protocol: tcp + x-defang-llm: true +gateway-with-ports: + image: litellm/litellm:latest + networks: + default: null + ports: + - mode: ingress + target: 5678 + published: "5678" + protocol: tcp + app_protocol: http + x-defang-llm: true +gateway-without-ports: + image: litellm/litellm:latest + networks: + default: null + ports: + - mode: host + target: 4000 + protocol: tcp + x-defang-llm: true +llm: + image: llm:latest + networks: + default: null + x-defang-llm: true diff --git a/src/testdata/longname/compose.yaml.fixup b/src/testdata/longname/compose.yaml.fixup index 563ba7cee..e82ddca85 100644 --- a/src/testdata/longname/compose.yaml.fixup +++ b/src/testdata/longname/compose.yaml.fixup @@ -1,10 +1,4 @@ -{ - "aVeryLongServiceNameThatIsDefinitelyTooLongThatWillCauseAnError": { - "command": null, - "entrypoint": null, - "image": "alpine", - "networks": { - "default": null - } - } -} \ No newline at end of file +aVeryLongServiceNameThatIsDefinitelyTooLongThatWillCauseAnError: + image: alpine + networks: + default: null diff --git a/src/testdata/models/compose.yaml.fixup b/src/testdata/models/compose.yaml.fixup index 3a33dd7a9..7d3773234 100644 --- a/src/testdata/models/compose.yaml.fixup +++ b/src/testdata/models/compose.yaml.fixup @@ -1,142 +1,93 @@ -{ - "ai_model": { - "command": [ - "--drop_params", - "--model", - "ai/model", - "--alias", - "ai/model" - ], - "entrypoint": null, - "environment": { - "LITELLM_MASTER_KEY": "networkisalreadyprivate" - }, - "image": "litellm/litellm:v1.82.3-stable.patch.3", - "networks": { - "model_provider_private": null - }, - "ports": [ - { - "mode": "host", - "target": 4000, - "protocol": "tcp" - } - ] - }, - "modellist": { - "command": null, - "depends_on": { - "ai_model": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "environment": { - "AI_MODEL_MODEL": "ai/model", - "AI_MODEL_URL": "http://mock-ai-model:4000/v1/" - }, - "image": "app", - "models": { - "ai_model": null - }, - "networks": { - "default": null, - "model_provider_private": null - } - }, - "modelmap": { - "command": null, - "depends_on": { - "ai_model": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "environment": { - "AI_MODEL_MODEL": "ai/model", - "AI_MODEL_URL": "http://mock-ai-model:4000/v1/" - }, - "image": "app", - "models": { - "ai_model": null - }, - "networks": { - "default": null, - "model_provider_private": null - } - }, - "my_model": { - "command": [ - "--drop_params", - "--model", - "ai/model", - "--alias", - "ai/model" - ], - "entrypoint": null, - "environment": { - "LITELLM_MASTER_KEY": "networkisalreadyprivate" - }, - "image": "litellm/litellm:v1.82.3-stable.patch.3", - "networks": { - "model_provider_private": null - }, - "ports": [ - { - "mode": "host", - "target": 4000, - "protocol": "tcp" - } - ] - }, - "withendpoint": { - "command": null, - "depends_on": { - "my_model": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "environment": { - "MODEL_URL": "http://mock-my-model:4000/v1/", - "MY_MODEL_MODEL": "ai/model" - }, - "image": "app", - "models": { - "my_model": { - "endpoint_var": "MODEL_URL" - } - }, - "networks": { - "default": null, - "model_provider_private": null - } - }, - "withmodelvar": { - "command": null, - "depends_on": { - "ai_model": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "environment": { - "AI_MODEL_URL": "http://mock-ai-model:4000/v1/", - "MY_MODEL_NAME": "ai/model" - }, - "image": "app", - "models": { - "ai_model": { - "model_var": "MY_MODEL_NAME" - } - }, - "networks": { - "default": null, - "model_provider_private": null - } - } -} \ No newline at end of file +ai_model: + command: + - --drop_params + - --model + - ai/model + - --alias + - ai/model + environment: + LITELLM_MASTER_KEY: networkisalreadyprivate + image: litellm/litellm:v1.82.3-stable.patch.3 + networks: + model_provider_private: null + ports: + - mode: host + target: 4000 + protocol: tcp + x-defang-llm: true +modellist: + depends_on: + ai_model: + condition: service_started + required: true + environment: + AI_MODEL_MODEL: ai/model + AI_MODEL_URL: http://mock-ai-model:4000/v1/ + image: app + models: + ai_model: null + networks: + default: null + model_provider_private: null + x-defang-llm: true +modelmap: + depends_on: + ai_model: + condition: service_started + required: true + environment: + AI_MODEL_MODEL: ai/model + AI_MODEL_URL: http://mock-ai-model:4000/v1/ + image: app + models: + ai_model: null + networks: + default: null + model_provider_private: null +my_model: + command: + - --drop_params + - --model + - ai/model + - --alias + - ai/model + environment: + LITELLM_MASTER_KEY: networkisalreadyprivate + image: litellm/litellm:v1.82.3-stable.patch.3 + networks: + model_provider_private: null + ports: + - mode: host + target: 4000 + protocol: tcp + x-defang-llm: true +withendpoint: + depends_on: + my_model: + condition: service_started + required: true + environment: + MODEL_URL: http://mock-my-model:4000/v1/ + MY_MODEL_MODEL: ai/model + image: app + models: + my_model: + endpoint_var: MODEL_URL + networks: + default: null + model_provider_private: null +withmodelvar: + depends_on: + ai_model: + condition: service_started + required: true + environment: + AI_MODEL_URL: http://mock-ai-model:4000/v1/ + MY_MODEL_NAME: ai/model + image: app + models: + ai_model: + model_var: MY_MODEL_NAME + networks: + default: null + model_provider_private: null diff --git a/src/testdata/mongo/compose.yaml.fixup b/src/testdata/mongo/compose.yaml.fixup index 2467e6614..b4bc973b5 100644 --- a/src/testdata/mongo/compose.yaml.fixup +++ b/src/testdata/mongo/compose.yaml.fixup @@ -1,250 +1,163 @@ -{ - "mongo": { - "command": null, - "entrypoint": null, - "environment": { - "MONGO_INITDB_ROOT_PASSWORD": "example!", - "MONGO_INITDB_ROOT_USERNAME": "root" - }, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 27017, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-express": { - "command": null, - "depends_on": { - "mongo": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "environment": { - "ME_CONFIG_BASICAUTH": "false", - "ME_CONFIG_MONGODB_ADMINPASSWORD": "example!", - "ME_CONFIG_MONGODB_ADMINUSERNAME": "root", - "ME_CONFIG_MONGODB_URL": "mongodb://root:example!@mock-mongo:27017/" - }, - "image": "mongo-express", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 8081, - "published": "8081", - "protocol": "tcp", - "app_protocol": "http" - } - ], - "restart": "always" - }, - "mongo-port1234": { - "command": [ - "--port", - "1234" - ], - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 1234, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-port1235": { - "command": [ - "--port=1235" - ], - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 1235, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-port1236": { - "command": [ - "--port", - "1236", - "--shardsvr" - ], - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 1236, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-port1237": { - "command": [ - "--port=1237", - "--configsvr" - ], - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 1237, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-port1238": { - "command": [ - "--shardsvr", - "--port", - "1238" - ], - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 1238, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-port1239": { - "command": [ - "--configsvr", - "--port=1239" - ], - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 1239, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-port27018": { - "command": [ - "--shardsvr" - ], - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 27018, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-port27019": { - "command": [ - "--configsvr" - ], - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 27019, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-unmanaged": { - "command": null, - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 27017, - "protocol": "tcp" - } - ], - "restart": "always" - }, - "mongo-wrong-image": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 27017, - "protocol": "tcp" - } - ] - }, - "short-ports": { - "command": null, - "entrypoint": null, - "image": "mongo", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 27017, - "published": "27017", - "protocol": "tcp" - } - ] - } -} \ No newline at end of file +mongo: + environment: + MONGO_INITDB_ROOT_PASSWORD: example! + MONGO_INITDB_ROOT_USERNAME: root + image: mongo + networks: + default: null + ports: + - mode: host + target: 27017 + protocol: tcp + restart: always + x-defang-mongodb: + allow-downtime: true +mongo-express: + depends_on: + mongo: + condition: service_started + required: true + environment: + ME_CONFIG_BASICAUTH: "false" + ME_CONFIG_MONGODB_ADMINPASSWORD: example! + ME_CONFIG_MONGODB_ADMINUSERNAME: root + ME_CONFIG_MONGODB_URL: mongodb://root:example!@mock-mongo:27017/ + image: mongo-express + networks: + default: null + ports: + - mode: ingress + target: 8081 + published: "8081" + protocol: tcp + app_protocol: http + restart: always +mongo-port1234: + command: + - --port + - "1234" + image: mongo + networks: + default: null + ports: + - mode: host + target: 1234 + protocol: tcp + restart: always + x-defang-mongodb: true +mongo-port1235: + command: + - --port=1235 + image: mongo + networks: + default: null + ports: + - mode: host + target: 1235 + protocol: tcp + restart: always + x-defang-mongodb: true +mongo-port1236: + command: + - --port + - "1236" + - --shardsvr + image: mongo + networks: + default: null + ports: + - mode: host + target: 1236 + protocol: tcp + restart: always +mongo-port1237: + command: + - --port=1237 + - --configsvr + image: mongo + networks: + default: null + ports: + - mode: host + target: 1237 + protocol: tcp + restart: always + x-defang-mongodb: true +mongo-port1238: + command: + - --shardsvr + - --port + - "1238" + image: mongo + networks: + default: null + ports: + - mode: host + target: 1238 + protocol: tcp + restart: always + x-defang-mongodb: true +mongo-port1239: + command: + - --configsvr + - --port=1239 + image: mongo + networks: + default: null + ports: + - mode: host + target: 1239 + protocol: tcp + restart: always + x-defang-mongodb: true +mongo-port27018: + command: + - --shardsvr + image: mongo + networks: + default: null + ports: + - mode: host + target: 27018 + protocol: tcp + restart: always + x-defang-mongodb: true +mongo-port27019: + command: + - --configsvr + image: mongo + networks: + default: null + ports: + - mode: host + target: 27019 + protocol: tcp + restart: always + x-defang-mongodb: true +mongo-unmanaged: + image: mongo + networks: + default: null + ports: + - mode: host + target: 27017 + protocol: tcp + restart: always +mongo-wrong-image: + image: example + networks: + default: null + ports: + - mode: host + target: 27017 + protocol: tcp + x-defang-mongodb: true +short-ports: + image: mongo + networks: + default: null + ports: + - mode: host + target: 27017 + published: "27017" + protocol: tcp diff --git a/src/testdata/networks/compose.yaml.fixup b/src/testdata/networks/compose.yaml.fixup index f36fb501c..6b69ffd9e 100644 --- a/src/testdata/networks/compose.yaml.fixup +++ b/src/testdata/networks/compose.yaml.fixup @@ -1,59 +1,29 @@ -{ - "service-default": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "default": null - } - }, - "service-internal": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "internal": null - } - }, - "service-invalid": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "invalid-network-name": {} - } - }, - "service-multi": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "default": null, - "internal": null - } - }, - "service-private": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "private": null - } - }, - "service-public": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "public": {} - } - }, - "service-public-list": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "public": null - } - } -} \ No newline at end of file +service-default: + image: example + networks: + default: null +service-internal: + image: example + networks: + internal: null +service-invalid: + image: example + networks: + invalid-network-name: {} +service-multi: + image: example + networks: + default: null + internal: null +service-private: + image: example + networks: + private: null +service-public: + image: example + networks: + public: {} +service-public-list: + image: example + networks: + public: null diff --git a/src/testdata/noprojname/compose.yaml.fixup b/src/testdata/noprojname/compose.yaml.fixup index 9e26dfeeb..0967ef424 100644 --- a/src/testdata/noprojname/compose.yaml.fixup +++ b/src/testdata/noprojname/compose.yaml.fixup @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/src/testdata/platforms/compose.yaml.fixup b/src/testdata/platforms/compose.yaml.fixup index ce89c569c..46251fa69 100644 --- a/src/testdata/platforms/compose.yaml.fixup +++ b/src/testdata/platforms/compose.yaml.fixup @@ -1,11 +1,5 @@ -{ - "intel2": { - "command": null, - "entrypoint": null, - "image": "busybox", - "networks": { - "default": null - }, - "platform": "LINUX/X86_64" - } -} \ No newline at end of file +intel2: + image: busybox + networks: + default: null + platform: LINUX/X86_64 diff --git a/src/testdata/ports/compose.yaml.fixup b/src/testdata/ports/compose.yaml.fixup index 6a887a2b1..37f13a5af 100644 --- a/src/testdata/ports/compose.yaml.fixup +++ b/src/testdata/ports/compose.yaml.fixup @@ -1,115 +1,64 @@ -{ - "grpc": { - "command": null, - "entrypoint": null, - "image": "bogus", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 9000, - "protocol": "tcp", - "app_protocol": "grpc" - } - ] - }, - "long": { - "command": null, - "entrypoint": null, - "image": "bogus", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 82, - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "long-published": { - "command": null, - "entrypoint": null, - "image": "bogus", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 83, - "published": "8083", - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "short": { - "command": null, - "entrypoint": null, - "image": "bogus", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 80, - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "short-published": { - "command": null, - "entrypoint": null, - "image": "bogus", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 81, - "published": "8081", - "protocol": "tcp", - "app_protocol": "http" - } - ] - }, - "short-udp": { - "command": null, - "entrypoint": null, - "image": "bogus", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 84, - "protocol": "udp" - } - ] - }, - "short-udp-published": { - "command": null, - "entrypoint": null, - "image": "bogus", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 85, - "published": "8085", - "protocol": "udp" - } - ] - } -} \ No newline at end of file +grpc: + image: bogus + networks: + default: null + ports: + - mode: ingress + target: 9000 + protocol: tcp + app_protocol: grpc +long: + image: bogus + networks: + default: null + ports: + - mode: ingress + target: 82 + protocol: tcp + app_protocol: http +long-published: + image: bogus + networks: + default: null + ports: + - mode: ingress + target: 83 + published: "8083" + protocol: tcp + app_protocol: http +short: + image: bogus + networks: + default: null + ports: + - mode: ingress + target: 80 + protocol: tcp + app_protocol: http +short-published: + image: bogus + networks: + default: null + ports: + - mode: ingress + target: 81 + published: "8081" + protocol: tcp + app_protocol: http +short-udp: + image: bogus + networks: + default: null + ports: + - mode: host + target: 84 + protocol: udp +short-udp-published: + image: bogus + networks: + default: null + ports: + - mode: host + target: 85 + published: "8085" + protocol: udp diff --git a/src/testdata/postgres/compose.yaml.fixup b/src/testdata/postgres/compose.yaml.fixup index 1bd536444..1bbcb4485 100644 --- a/src/testdata/postgres/compose.yaml.fixup +++ b/src/testdata/postgres/compose.yaml.fixup @@ -1,96 +1,57 @@ -{ - "no-ext": { - "command": null, - "entrypoint": null, - "image": "postgres", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 5432, - "protocol": "tcp" - } - ] - }, - "no-ports": { - "command": null, - "entrypoint": null, - "image": "postgres", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 5432, - "protocol": "tcp" - } - ] - }, - "no-ports-override": { - "command": null, - "entrypoint": null, - "environment": { - "PGPORT": "5433" - }, - "image": "postgres", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 5433, - "protocol": "tcp" - } - ] - }, - "short-ports": { - "command": null, - "entrypoint": null, - "image": "postgres", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 5432, - "published": "5432", - "protocol": "tcp" - } - ] - }, - "with-ext": { - "command": null, - "entrypoint": null, - "image": "postgres", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 5432, - "protocol": "tcp" - } - ] - }, - "wrong-image": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 5432, - "protocol": "tcp" - } - ] - } -} \ No newline at end of file +no-ext: + image: postgres + networks: + default: null + ports: + - mode: host + target: 5432 + protocol: tcp +no-ports: + image: postgres + networks: + default: null + ports: + - mode: host + target: 5432 + protocol: tcp + x-defang-postgres: null +no-ports-override: + environment: + PGPORT: "5433" + image: postgres + networks: + default: null + ports: + - mode: host + target: 5433 + protocol: tcp + x-defang-postgres: null +short-ports: + image: postgres + networks: + default: null + ports: + - mode: host + target: 5432 + published: "5432" + protocol: tcp + x-defang-postgres: null +with-ext: + image: postgres + networks: + default: null + ports: + - mode: host + target: 5432 + protocol: tcp + x-defang-postgres: + allow-downtime: true +wrong-image: + image: example + networks: + default: null + ports: + - mode: host + target: 5432 + protocol: tcp + x-defang-postgres: null diff --git a/src/testdata/profiles/compose.yaml.fixup b/src/testdata/profiles/compose.yaml.fixup index bdae8fb87..a9311b3cd 100644 --- a/src/testdata/profiles/compose.yaml.fixup +++ b/src/testdata/profiles/compose.yaml.fixup @@ -1,21 +1,10 @@ -{ - "always": { - "command": null, - "entrypoint": null, - "image": "alpine", - "networks": { - "default": null - } - }, - "defangonly": { - "profiles": [ - "defang" - ], - "command": null, - "entrypoint": null, - "image": "alpine", - "networks": { - "default": null - } - } -} \ No newline at end of file +always: + image: alpine + networks: + default: null +defangonly: + profiles: + - defang + image: alpine + networks: + default: null diff --git a/src/testdata/provider/compose.yaml.fixup b/src/testdata/provider/compose.yaml.fixup index 63cdc7081..8cfed67d5 100644 --- a/src/testdata/provider/compose.yaml.fixup +++ b/src/testdata/provider/compose.yaml.fixup @@ -1,47 +1,30 @@ -{ - "ai_runner": { - "command": [ - "--drop_params", - "--model", - "ai/smollm2", - "--alias", - "ai/smollm2" - ], - "entrypoint": null, - "environment": { - "DEBUG": "true", - "LITELLM_MASTER_KEY": "networkisalreadyprivate" - }, - "image": "litellm/litellm:v1.82.3-stable.patch.3", - "networks": { - "model_provider_private": null - }, - "ports": [ - { - "mode": "host", - "target": 4000, - "protocol": "tcp" - } - ] - }, - "chat": { - "command": null, - "depends_on": { - "ai_runner": { - "condition": "service_started", - "required": true - } - }, - "entrypoint": null, - "environment": { - "AI_RUNNER_MODEL": "ai/smollm2", - "AI_RUNNER_URL": "http://mock-ai-runner:4000/v1/", - "OPENAI_API_KEY": "networkisalreadyprivate" - }, - "image": "my-chat-app", - "networks": { - "default": null, - "model_provider_private": null - } - } -} \ No newline at end of file +ai_runner: + command: + - --drop_params + - --model + - ai/smollm2 + - --alias + - ai/smollm2 + environment: + DEBUG: "true" + LITELLM_MASTER_KEY: networkisalreadyprivate + image: litellm/litellm:v1.82.3-stable.patch.3 + networks: + model_provider_private: null + ports: + - mode: host + target: 4000 + protocol: tcp +chat: + depends_on: + ai_runner: + condition: service_started + required: true + environment: + AI_RUNNER_MODEL: ai/smollm2 + AI_RUNNER_URL: http://mock-ai-runner:4000/v1/ + OPENAI_API_KEY: networkisalreadyprivate + image: my-chat-app + networks: + default: null + model_provider_private: null diff --git a/src/testdata/railpack/compose.yaml.fixup b/src/testdata/railpack/compose.yaml.fixup index 7a9061d98..31f4e40f8 100644 --- a/src/testdata/railpack/compose.yaml.fixup +++ b/src/testdata/railpack/compose.yaml.fixup @@ -1,41 +1,24 @@ -{ - "railpack-long": { - "build": { - "context": ".", - "dockerfile": "*Railpack" - }, - "command": [ - "exec node index.js" - ], - "entrypoint": null, - "networks": { - "default": null - } - }, - "railpack-short": { - "build": { - "context": ".", - "dockerfile": "*Railpack" - }, - "command": [ - "npm start" - ], - "entrypoint": null, - "networks": { - "default": null - } - }, - "railpackwithdockerfile": { - "build": { - "context": ".", - "dockerfile": "*Railpack" - }, - "command": [ - "something \"with space\" \"${PORT}\"" - ], - "entrypoint": null, - "networks": { - "default": null - } - } -} \ No newline at end of file +railpack-long: + build: + context: . + dockerfile: '*Railpack' + command: + - exec node index.js + networks: + default: null +railpack-short: + build: + context: . + dockerfile: '*Railpack' + command: + - npm start + networks: + default: null +railpackwithdockerfile: + build: + context: . + dockerfile: '*Railpack' + command: + - something "with space" "${PORT}" + networks: + default: null diff --git a/src/testdata/redis/compose.yaml.fixup b/src/testdata/redis/compose.yaml.fixup index 2978fb916..943af4027 100644 --- a/src/testdata/redis/compose.yaml.fixup +++ b/src/testdata/redis/compose.yaml.fixup @@ -1,111 +1,67 @@ -{ - "no-ext": { - "command": null, - "entrypoint": null, - "image": "redis", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 6379, - "protocol": "tcp" - } - ] - }, - "no-ports": { - "command": null, - "entrypoint": null, - "image": "redis", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 6379, - "protocol": "tcp" - } - ] - }, - "no-ports-override": { - "command": [ - "--port", - "6380" - ], - "entrypoint": null, - "image": "redis", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 6380, - "protocol": "tcp" - } - ] - }, - "short-ports": { - "command": null, - "entrypoint": null, - "image": "redis", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 6379, - "published": "6379", - "protocol": "tcp" - } - ] - }, - "valkey-service": { - "command": null, - "entrypoint": null, - "image": "valkey/valkey:latest", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 6379, - "protocol": "tcp" - } - ] - }, - "with-ext": { - "command": null, - "entrypoint": null, - "image": "redis", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 6379, - "protocol": "tcp" - } - ] - }, - "wrong-image": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 6379, - "protocol": "tcp" - } - ] - } -} \ No newline at end of file +no-ext: + image: redis + networks: + default: null + ports: + - mode: host + target: 6379 + protocol: tcp +no-ports: + image: redis + networks: + default: null + ports: + - mode: host + target: 6379 + protocol: tcp + x-defang-redis: null +no-ports-override: + command: + - --port + - "6380" + image: redis + networks: + default: null + ports: + - mode: host + target: 6380 + protocol: tcp + x-defang-redis: null +short-ports: + image: redis + networks: + default: null + ports: + - mode: host + target: 6379 + published: "6379" + protocol: tcp + x-defang-redis: null +valkey-service: + image: valkey/valkey:latest + networks: + default: null + ports: + - mode: host + target: 6379 + protocol: tcp + x-defang-redis: true +with-ext: + image: redis + networks: + default: null + ports: + - mode: host + target: 6379 + protocol: tcp + x-defang-redis: + allow-downtime: true +wrong-image: + image: example + networks: + default: null + ports: + - mode: host + target: 6379 + protocol: tcp + x-defang-redis: null diff --git a/src/testdata/replicas/compose.yaml.fixup b/src/testdata/replicas/compose.yaml.fixup index 7c15a7d22..2be6562c6 100644 --- a/src/testdata/replicas/compose.yaml.fixup +++ b/src/testdata/replicas/compose.yaml.fixup @@ -1,63 +1,33 @@ -{ - "autoscaled": { - "command": null, - "entrypoint": null, - "image": "nginx:latest", - "networks": { - "default": null - } - }, - "default": { - "command": null, - "entrypoint": null, - "image": "nginx:latest", - "networks": { - "default": null - } - }, - "deploy": { - "command": null, - "deploy": { - "resources": { - "reservations": { - "cpus": 0.25, - "memory": "268435456" - } - }, - "placement": {} - }, - "entrypoint": null, - "image": "nginx:latest", - "networks": { - "default": null - } - }, - "managed": { - "command": null, - "entrypoint": null, - "image": "redis:latest", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "host", - "target": 6379, - "protocol": "tcp" - } - ] - }, - "replicated": { - "command": null, - "deploy": { - "replicas": 3, - "resources": {}, - "placement": {} - }, - "entrypoint": null, - "image": "nginx:latest", - "networks": { - "default": null - } - } -} \ No newline at end of file +autoscaled: + image: nginx:latest + networks: + default: null + x-defang-autoscaling: true +default: + image: nginx:latest + networks: + default: null +deploy: + deploy: + resources: + reservations: + cpus: 0.25 + memory: "268435456" + image: nginx:latest + networks: + default: null +managed: + image: redis:latest + networks: + default: null + ports: + - mode: host + target: 6379 + protocol: tcp + x-defang-redis: true +replicated: + deploy: + replicas: 3 + image: nginx:latest + networks: + default: null diff --git a/src/testdata/sanity/compose.yaml.fixup b/src/testdata/sanity/compose.yaml.fixup index 1ea822bc9..19bbeb3d4 100644 --- a/src/testdata/sanity/compose.yaml.fixup +++ b/src/testdata/sanity/compose.yaml.fixup @@ -1,30 +1,16 @@ -{ - "nginx": { - "command": null, - "deploy": { - "resources": { - "reservations": { - "memory": "268435456" - } - }, - "placement": {} - }, - "entrypoint": null, - "environment": { - "dummy": null - }, - "image": "nginx", - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 80, - "protocol": "tcp", - "app_protocol": "http" - } - ], - "restart": "unless-stopped" - } -} \ No newline at end of file +nginx: + deploy: + resources: + reservations: + memory: "268435456" + environment: + dummy: null + image: nginx + networks: + default: null + ports: + - mode: ingress + target: 80 + protocol: tcp + app_protocol: http + restart: unless-stopped diff --git a/src/testdata/secretname/compose.yaml.fixup b/src/testdata/secretname/compose.yaml.fixup index b90e03701..72d4a4cc7 100644 --- a/src/testdata/secretname/compose.yaml.fixup +++ b/src/testdata/secretname/compose.yaml.fixup @@ -1,17 +1,9 @@ -{ - "app": { - "build": { - "context": ".", - "dockerfile": "Dockerfile" - }, - "command": null, - "entrypoint": null, - "environment": { - "dummy": null - }, - "networks": { - "default": null - }, - "restart": "unless-stopped" - } -} \ No newline at end of file +app: + build: + context: . + dockerfile: Dockerfile + environment: + dummy: null + networks: + default: null + restart: unless-stopped diff --git a/src/testdata/static-files/compose.yaml.fixup b/src/testdata/static-files/compose.yaml.fixup index 7d2b7d783..90ef5dca2 100644 --- a/src/testdata/static-files/compose.yaml.fixup +++ b/src/testdata/static-files/compose.yaml.fixup @@ -1,18 +1,13 @@ -{ - "x": { - "command": null, - "entrypoint": null, - "image": "blah", - "networks": { - "default": null - } - }, - "y": { - "command": null, - "entrypoint": null, - "image": "blah", - "networks": { - "default": null - } - } -} \ No newline at end of file +x: + image: blah + networks: + default: null + x-defang-static-files: ./folder +"y": + image: blah + networks: + default: null + x-defang-static-files: + folder: ./folder + redirects: true - www.example.com + x-unsupported: asdf diff --git a/src/testdata/testproj/compose.yaml.fixup b/src/testdata/testproj/compose.yaml.fixup index b303012b1..2a65e3b5b 100644 --- a/src/testdata/testproj/compose.yaml.fixup +++ b/src/testdata/testproj/compose.yaml.fixup @@ -1,64 +1,41 @@ -{ - "dfnx": { - "build": { - "context": ".", - "dockerfile": "Dockerfile", - "args": { - "DNS": "mock-dfnx" - }, - "target": "testproj" - }, - "command": null, - "deploy": { - "resources": { - "limits": { - "cpus": 2, - "memory": "536870912" - }, - "reservations": { - "cpus": 0.25, - "memory": "268435456" - } - }, - "placement": {} - }, - "entrypoint": null, - "environment": { - "DOTENV": "enabled", - "DOT_ENV_INTERPOLATION": "enabled", - "FOO": "bar", - "dummy": null - }, - "healthcheck": { - "test": [ - "CMD", - "curl", - "-f", - "http://localhost/" - ] - }, - "networks": { - "default": null - }, - "ports": [ - { - "mode": "ingress", - "target": 80, - "protocol": "tcp", - "app_protocol": "http" - }, - { - "mode": "ingress", - "target": 1234, - "protocol": "tcp", - "app_protocol": "http" - }, - { - "mode": "host", - "target": 4567, - "protocol": "udp" - } - ], - "restart": "unless-stopped" - } -} \ No newline at end of file +dfnx: + build: + context: . + dockerfile: Dockerfile + args: + DNS: mock-dfnx + target: testproj + deploy: + resources: + limits: + cpus: 2 + memory: "536870912" + reservations: + cpus: 0.25 + memory: "268435456" + environment: + DOT_ENV_INTERPOLATION: enabled + DOTENV: enabled + FOO: bar + dummy: null + healthcheck: + test: + - CMD + - curl + - -f + - http://localhost/ + networks: + default: null + ports: + - mode: ingress + target: 80 + protocol: tcp + app_protocol: http + - mode: ingress + target: 1234 + protocol: tcp + app_protocol: http + - mode: host + target: 4567 + protocol: udp + restart: unless-stopped diff --git a/src/testdata/toomany/compose.yaml.fixup b/src/testdata/toomany/compose.yaml.fixup index 286e7f777..f97ec1802 100644 --- a/src/testdata/toomany/compose.yaml.fixup +++ b/src/testdata/toomany/compose.yaml.fixup @@ -1,10 +1,4 @@ -{ - "service1": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "default": null - } - } -} \ No newline at end of file +service1: + image: example + networks: + default: null diff --git a/src/testdata/toomany/docker-compose.yml.fixup b/src/testdata/toomany/docker-compose.yml.fixup index 286e7f777..f97ec1802 100644 --- a/src/testdata/toomany/docker-compose.yml.fixup +++ b/src/testdata/toomany/docker-compose.yml.fixup @@ -1,10 +1,4 @@ -{ - "service1": { - "command": null, - "entrypoint": null, - "image": "example", - "networks": { - "default": null - } - } -} \ No newline at end of file +service1: + image: example + networks: + default: null