Skip to content

Commit a7c1be3

Browse files
CopilotAniruddh25Copilotanushakolan
authored
Add default dab-config.json to Docker image (#3168)
## Why make this change? The Docker image shipped with no default configuration file, requiring users to supply one before the container would start — a poor out-of-the-box experience for first-time users. ## What is this change? - **`dab-config.json`** (new, repo root) — Default configuration baked into the image: - `mssql` database type; connection string resolved at runtime via `@env('DAB_CONNSTRING')` (no secrets committed) - REST (`/api`), GraphQL (`/graphql`), and MCP (`/mcp`) endpoints enabled - `autoentities.default` template with `dml-tools` enabled and explicit `anonymous: ["create", "read", "update", "delete"]` permissions - Authentication provider set to `"Simulator"` (valid dev-mode provider per schema) - Host mode: `development` - `$schema` points to `releases/latest/download/dab.draft.schema.json` (always current, never stale) - **`Dockerfile`** — Copies the default config into the runtime image: ```dockerfile # Add default dab-config.json to /App in the image COPY dab-config.json /App/dab-config.json ``` - **`.gitignore`** — Added `!/dab-config.json` exception; the existing `dab-config*.json` rule was silently excluding this file from version control. ## How was this tested? - [ ] Integration Tests - [ ] Unit Tests Container startup was manually verified: built an image using the compiled service binary and the default `dab-config.json`, then ran it with `DAB_CONNSTRING` set. Logs confirmed successful startup: ``` Loading config file from /App/dab-config.json. Now listening on: http://[::]:5000 Application started. ``` JSON schema validation was also confirmed to pass against `schemas/dab.draft.schema.json`. ## Sample Request(s) Run the container with just a connection string — no config mount required: ```bash docker run -e DAB_CONNSTRING="<your-connection-string>" -p 5000:5000 <image> ``` Override the default config by mounting your own: ```bash docker run -e DAB_CONNSTRING="..." -v ./my-dab-config.json:/App/dab-config.json -p 5000:5000 <image> ``` <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Supplement Docker image with default configuration file (dab-config.json)</issue_title> > <issue_description>## Problem > > The current Docker image does not include a default configuration file, making it less user-friendly for those getting started. > > ## Proposal > > - Add a default configuration file named `dab-config.json` to the Docker image. > - The file should be available in a standard location within the image, such as `/App/dab-config.json` (see the Dockerfile below). > - The file should contain the following settings: > > ```json > { > "$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.7.86-rc/dab.draft.schema.json", > "data-source": { > "database-type": "mssql", > "connection-string": "@env('DAB_CONNSTRING')", > "options": { > "set-session-context": false > } > }, > "runtime": { > "rest": { > "enabled": true, > "path": "/api", > "request-body-strict": false > }, > "graphql": { > "enabled": true, > "path": "/graphql", > "allow-introspection": true > }, > "mcp": { > "enabled": true, > "path": "/mcp" > }, > "host": { > "cors": { > "origins": [], > "allow-credentials": false > }, > "authentication": { > "provider": "Unauthenticated" > }, > "mode": "development" > } > }, > "entities": {}, > "autoentities": { > "default": { > "template": { > "mcp": { "dml-tool": true }, > "rest": { "enabled": true}, > "graphql": { "enabled": true }, > "health": { "enabled": true }, > "cache": { > "enabled": false > } > }, > "permissions": [ > { > "role": "anonymous", > "actions": [ > "*" > ] > } > ] > } > } > } > ``` > > ## Benefit > > Including this configuration file will provide immediate guidance for users, improve out-of-the-box experience, and make Docker-based experimentation much easier. > > ## Relevant code locations > > **Dockerfile** > The Docker image is defined by [`Dockerfile`](https://github.com/Azure/data-api-builder/blob/main/Dockerfile): > > ```dockerfile > FROM mcr.microsoft.com/dotnet/sdk:8.0-cbl-mariner2.0. AS build > > WORKDIR /src > COPY [".", "./"] > RUN dotnet build "./src/Service/Azure.DataApiBuilder.Service.csproj" -c Docker -o /out -r linux-x64 > > FROM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS runtime > COPY --from=build /out /App > WORKDIR /App > ENV ASPNETCORE_URLS=http://+:5000 > ENTRYPOINT ["dotnet", "Azure.DataApiBuilder.Service.dll"] > ``` > > To add the default config, include a line such as: > > ```dockerfile > # Add default dab-config.json to /App in the image > COPY dab-config.json /App/dab-config.json > ``` > > **References in deployment scripts and samples** > > - [`samples/aspire/apphost.cs`](https://github.com/Azure/data-api-builder/blob/main/samples/aspire/apphost.cs#L30-L48) binds `dab-config.json` into the container at `/App/dab-config.json`. > - [`samples/azure/bicep/dab-on-aca.bicep`](https://github.com/Azure/data-api-builder/blob/main/samples/azure/bicep/dab-on-aca.bicep) and > [`samples/azure/azure-container-apps-deploy.sh`](https://github.com/Azure/data-api-builder/blob/main/samples/azure/azure-container-apps-deploy.sh) > reference mounting and passing `dab-config.json`. > - Documentation and deployment code often expect this file to be named `dab-config.json` and placed at `/App/dab-config.json` or a similar standard path. > > > Please ensure the Docker image has this default config at `/App/dab-config.json`, and consider documenting override patterns for cloud and local deployments.</issue_description> > > <agent_instructions>refer to .github/copilot-instructions.md</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #3160 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Aniruddh25 <[email protected]> Co-authored-by: Aniruddh Munde <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Anusha Kolan <[email protected]>
1 parent 1dd0882 commit a7c1be3

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dab-config*.json
1515
*.dab-config.json
1616
!dab-config.*reference.json
1717
!dab-config.*.example.json
18+
!/dab-config.json
1819

1920
*.cd
2021

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ RUN dotnet build "./src/Service/Azure.DataApiBuilder.Service.csproj" -c Docker -
1010
FROM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS runtime
1111

1212
COPY --from=build /out /App
13+
# Add default dab-config.json to /App in the image
14+
COPY dab-config.json /App/dab-config.json
1315
WORKDIR /App
1416
ENV ASPNETCORE_URLS=http://+:5000
1517
ENTRYPOINT ["dotnet", "Azure.DataApiBuilder.Service.dll"]

dab-config.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json",
3+
"data-source": {
4+
"database-type": "mssql",
5+
"connection-string": "@env('DAB_CONNSTRING')",
6+
"options": {
7+
"set-session-context": false
8+
}
9+
},
10+
"runtime": {
11+
"rest": {
12+
"enabled": true,
13+
"path": "/api",
14+
"request-body-strict": false
15+
},
16+
"graphql": {
17+
"enabled": true,
18+
"path": "/graphql",
19+
"allow-introspection": true
20+
},
21+
"mcp": {
22+
"enabled": true,
23+
"path": "/mcp"
24+
},
25+
"host": {
26+
"cors": {
27+
"origins": [],
28+
"allow-credentials": false
29+
},
30+
"authentication": {
31+
"provider": "Simulator"
32+
},
33+
"mode": "development"
34+
}
35+
},
36+
"entities": {},
37+
"autoentities": {
38+
"default": {
39+
"template": {
40+
"mcp": { "dml-tools": true },
41+
"rest": { "enabled": true },
42+
"graphql": { "enabled": true },
43+
"health": { "enabled": true },
44+
"cache": {
45+
"enabled": false
46+
}
47+
},
48+
"permissions": [
49+
{
50+
"role": "anonymous",
51+
"actions": [
52+
"create", "read", "update", "delete"
53+
]
54+
}
55+
]
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)