Skip to content

Commit 58980b4

Browse files
committed
feat(web): Add command field in docker compose
1 parent b97f26c commit 58980b4

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

web/src/pages/docker-compose/docker-compose.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ const DockerCompose: FC = () => {
170170
if (item.environment && item.environment[0]) {
171171
item.environment = null;
172172
}
173+
if (item.command?.length === 0) {
174+
item.command = null;
175+
}
173176
return item;
174177
});
175178

@@ -282,6 +285,13 @@ const DockerCompose: FC = () => {
282285
placeholder="container_name"
283286
/>
284287
</div>
288+
<div className="mb-4 flex flex-col">
289+
<FormInput
290+
id="command"
291+
name={`services.${index}.command`}
292+
label="Command"
293+
/>
294+
</div>
285295
<ServiceBuildFields serviceIndex={index} />
286296
<ServicePortsFields serviceIndex={index} />
287297
<ServiceVolumesFields serviceIndex={index} />

web/src/pages/docker-compose/docker-compose.type.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,16 @@ export interface DockerComposeValidationError {
5757
}
5858

5959
const KV_Schema = zod.array(
60-
zod.object({
61-
key: zod
62-
.string()
63-
.min(1, { message: 'Key must be at least 1 character long' }),
64-
value: zod
65-
.string()
66-
.min(1, { message: 'Value must be at least 1 character long' }),
67-
}).nullable(),
60+
zod
61+
.object({
62+
key: zod
63+
.string()
64+
.min(1, { message: 'Key must be at least 1 character long' }),
65+
value: zod
66+
.string()
67+
.min(1, { message: 'Value must be at least 1 character long' }),
68+
})
69+
.nullable(),
6870
);
6971

7072
export const BuildSchema = zod.object({
@@ -81,7 +83,7 @@ export const ServiceSchema = zod.object({
8183
environment: KV_Schema,
8284
container_name: zod.string(),
8385
ports: zod.array(zod.string()).nullable(),
84-
command: zod.string().optional(),
86+
command: zod.string().optional().nullable(),
8587
volumes: zod.array(zod.string()).nullable(),
8688
networks: zod.array(zod.string()).nullable(),
8789
depends_on: zod.array(zod.string()).nullable(),
@@ -122,12 +124,11 @@ export const DockerComposeSchema = zod.object({
122124

123125
export type TDockerCompose = zod.infer<typeof DockerComposeSchema>;
124126

125-
126127
type AppNetwork = {
127128
network_name: string;
128129
driver: {
129130
label: string;
130-
value: "bridge" | "host" | "none" | "overlay";
131+
value: 'bridge' | 'host' | 'none' | 'overlay';
131132
};
132133
};
133134

@@ -137,4 +138,4 @@ type NetworkConfig = {
137138
external?: boolean;
138139
};
139140

140-
export type CombinedNetworkType = AppNetwork | NetworkConfig;
141+
export type CombinedNetworkType = AppNetwork | NetworkConfig;

0 commit comments

Comments
 (0)