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
10 changes: 7 additions & 3 deletions docs/deploystack/deploystack-config-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ You can override these values using the `config.yml` (only on your main branch)

| Property | Type | Description | Constraints |
|----------|------|-------------|-------------|
| `name` | String | Override the repository name for DeployStack display | Maximum 40 characters |
| `description` | String | Override the repository description for DeployStack display | Maximum 500 characters |
| `logo` | String | URL to your application logo | [Application Logo Configuration](/docs/deploystack/application-logo-configuration.md) |
| `mappings` | Array | Defines relationships between services for connection configuration | Required |
| `mappings[].fromService` | String | Service that needs to connect to another service | Required |
| `mappings[].toService` | String | Service being connected to | Required |
| `mappings[].environmentVariables` | Array of Strings | Environment variable names that reference the target service | Required |
| `mappings[].property` | String | Type of connection property to reference (e.g., 'connectionString', 'hostport') | Optional, defaults to 'hostport' |

The override process follows this order:

Expand Down Expand Up @@ -148,10 +150,12 @@ deployment:
environmentVariables:
- "DATABASE_HOST"
- "DATABASE_URL"
property: "connectionString"
- fromService: "frontend"
toService: "api"
environmentVariables:
- "API_URL"
property: "hostport"
```

This configuration tells DeployStack how to properly configure communication between:
Expand Down
10 changes: 9 additions & 1 deletion docs/docker-to-iac/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ type ServiceConnectionsConfig = {
fromService: string; // Service that needs to connect
toService: string; // Service to connect to
environmentVariables: string[]; // Environment variables that reference the service
property?: string; // Connection property type (connectionString, hostport, etc.)
}>
};
```
Expand All @@ -443,7 +444,14 @@ serviceConnections: {
{
fromService: 'frontend',
toService: 'api',
environmentVariables: ['API_URL']
environmentVariables: ['API_URL'],
property: 'hostport'
},
{
fromService: 'app',
toService: 'db',
environmentVariables: ['DATABASE_URL'],
property: 'connectionString'
}
]
}
Expand Down
46 changes: 41 additions & 5 deletions docs/docker-to-iac/service-connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ menuTitle: Service Connections

# Service Connections

The `docker-to-iac` module now supports configuring service-to-service communication when translating Docker Compose files to cloud provider IaC templates. This feature is essential for multi-container applications where services need to communicate with each other (e.g., web applications connecting to databases).
The `docker-to-iac` module supports configuring service-to-service communication when translating Docker Compose files to cloud provider IaC templates. This feature is essential for multi-container applications where services need to communicate with each other (e.g., web applications connecting to databases).

## The Challenge

Expand Down Expand Up @@ -63,7 +63,8 @@ const result = translate(dockerComposeContent, {
environmentVariables: [ // List of env vars that reference the service
'DATABASE_HOST',
'API_URL'
]
],
property: 'connectionString' // The type of connection (connectionString, hostport, etc.)
}
]
}
Expand All @@ -77,6 +78,7 @@ For each service connection mapping:
- `fromService`: The service that needs to connect to another service
- `toService`: The service being connected to
- `environmentVariables`: Array of environment variable names that reference the target service
- `property`: The type of connection property to reference (e.g., 'connectionString', 'hostport', etc.)

## Provider-Specific Implementations

Expand All @@ -99,7 +101,7 @@ services:
fromService:
name: db
type: pserv
property: hostport
property: hostport # This property is derived from the 'property' parameter in your mapping
```

This approach leverages Render's built-in service discovery capabilities for reliable inter-service communication.
Expand All @@ -122,7 +124,7 @@ services:

## Complete Example

Here's a complete example showing Node.js microservices communicating with each other:
Here's a complete example showing Node.js microservices communicating with each other, and a more detailed database connection example:

```javascript
const dockerComposeContent = `
Expand All @@ -148,13 +150,47 @@ const serviceConnections = {
{
fromService: 'frontend',
toService: 'api',
environmentVariables: ['API_URL']
environmentVariables: ['API_URL'],
property: 'hostport'
}
]
};

// For DigitalOcean - Service name stays as "api" in http://api:3000
// For Render - Will use fromService syntax instead of string replacement

// Database Connection Example
const databaseComposeContent = `
services:
app:
image: node:18-alpine
environment:
- DATABASE_URL=postgresql://postgres:secret@postgres:5432/mydb
ports:
- "3000:3000"

postgres:
image: postgres:latest
environment:
- POSTGRES_DB: mydb
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: secret
`;

const dbServiceConnections = {
mappings: [
{
fromService: 'app',
toService: 'postgres',
environmentVariables: ['DATABASE_URL'],
property: 'connectionString' // Use connectionString for full database URL
}
]
};

// Result will include proper connection format for each provider
// DigitalOcean: DATABASE_URL=${postgres.DATABASE_URL}
// Render: fromDatabase: { name: "postgres", property: "connectionString" }
```

## Response Format
Expand Down