Skip to content

Commit 79f6d2d

Browse files
committed
feat: add service filter for uploads
1 parent a0b3467 commit 79f6d2d

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

cli/src/commands/deploy-phases.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ export async function uploadFiles(ctx: DeployContext): Promise<UploadRollbackPla
8585

8686
if (!uploads || uploads.length === 0) return plan;
8787

88+
const serviceFilter = ctx.options.services
89+
? new Set(ctx.options.services.split(',').map((s: string) => s.trim()))
90+
: null;
91+
8892
for (const upload of uploads) {
93+
if (serviceFilter && upload.service) {
94+
const uploadServices = Array.isArray(upload.service) ? upload.service : [upload.service];
95+
if (!uploadServices.some(s => serviceFilter.has(s))) continue;
96+
}
8997
const srcAbs = resolve(ctx.projectRoot, upload.src);
9098

9199
if (!existsSync(srcAbs)) {

cli/src/schemas/config.schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ export const UploadItemSchema = z.object({
302302
dest: z.string()
303303
.refine(v => v.startsWith('/'), { message: 'dest must be an absolute path (starting with /)' })
304304
.describe('Absolute destination path on the remote server'),
305+
service: z.union([z.string(), z.array(z.string())]).optional()
306+
.describe('Service(s) this upload belongs to. When --services is used, only uploads matching a targeted service are transferred.'),
305307
});
306308

307309
/**

cli/src/utils/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export interface NotificationsConfig {
138138
export interface UploadItem {
139139
src: string;
140140
dest: string;
141+
service?: string | string[];
141142
}
142143

143144
export interface DockflowConfig {

docs/app/configuration/upload/page.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ services:
2929
|-------|------|-------------|---------|
3030
| `src` | `string` | Local path relative to the project root (file or directory) | Yes |
3131
| `dest` | `string` | Absolute destination path on the remote server | Yes |
32+
| `service` | `string \| string[]` | Service(s) this upload belongs to. When deploying with `--services`, only uploads matching a targeted service are transferred. Uploads without this field are always transferred. | No |
3233

3334
`dest` must start with `/`. If `src` is a directory, `dest` is used as the destination directory and the relative structure is preserved.
3435

@@ -80,6 +81,24 @@ upload:
8081
File permissions are not preserved (files are created with the server's default umask). If a service requires specific permissions (e.g., `640` for `mosquitto_passwd`), add a `post-deploy` hook that runs `chmod`.
8182
</Callout>
8283

84+
## Scoping uploads to a service
85+
86+
When using `--services` to deploy a single service, uploads without a `service` field still run. Use the `service` field to restrict an upload to specific services:
87+
88+
```yaml
89+
upload:
90+
- src: .dockflow/docker/mosquitto/
91+
dest: /opt/dockflow/mqtt/
92+
service: mqtt # only transferred when deploying the mqtt service
93+
94+
- src: .dockflow/docker/prometheus.yml
95+
dest: /opt/dockflow/monitoring/prometheus.yml
96+
service: [prometheus, grafana] # transferred when either service is targeted
97+
98+
- src: .dockflow/shared.conf
99+
dest: /opt/dockflow/shared.conf # no service field → always transferred
100+
```
101+
83102
## Full example
84103

85104
```yaml
@@ -89,8 +108,10 @@ project_name: my-app
89108
upload:
90109
- src: .dockflow/docker/mosquitto/
91110
dest: /opt/dockflow/mqtt/
111+
service: mqtt
92112
- src: .dockflow/docker/prometheus.yml
93113
dest: /opt/dockflow/monitoring/prometheus.yml
114+
service: prometheus
94115
```
95116

96117
```yaml

0 commit comments

Comments
 (0)