diff --git a/apps/dokploy/__test__/drop/drop.test.ts b/apps/dokploy/__test__/drop/drop.test.ts index cabc77d87..901e59c42 100644 --- a/apps/dokploy/__test__/drop/drop.test.ts +++ b/apps/dokploy/__test__/drop/drop.test.ts @@ -28,6 +28,7 @@ const baseApp: ApplicationNested = { railpackVersion: "0.2.2", applicationId: "", previewLabels: [], + createEnvFile: true, herokuVersion: "", giteaBranch: "", buildServerId: "", diff --git a/apps/dokploy/__test__/traefik/traefik.test.ts b/apps/dokploy/__test__/traefik/traefik.test.ts index 279e74fa5..01ecb9e8e 100644 --- a/apps/dokploy/__test__/traefik/traefik.test.ts +++ b/apps/dokploy/__test__/traefik/traefik.test.ts @@ -7,6 +7,7 @@ const baseApp: ApplicationNested = { rollbackActive: false, applicationId: "", previewLabels: [], + createEnvFile: true, herokuVersion: "", giteaRepository: "", giteaOwner: "", diff --git a/apps/dokploy/components/dashboard/application/environment/show.tsx b/apps/dokploy/components/dashboard/application/environment/show.tsx index 48e978880..5de03c367 100644 --- a/apps/dokploy/components/dashboard/application/environment/show.tsx +++ b/apps/dokploy/components/dashboard/application/environment/show.tsx @@ -5,14 +5,23 @@ import { toast } from "sonner"; import { z } from "zod"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; -import { Form } from "@/components/ui/form"; +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, +} from "@/components/ui/form"; import { Secrets } from "@/components/ui/secrets"; +import { Switch } from "@/components/ui/switch"; import { api } from "@/utils/api"; const addEnvironmentSchema = z.object({ env: z.string(), buildArgs: z.string(), buildSecrets: z.string(), + createEnvFile: z.boolean(), }); type EnvironmentSchema = z.infer; @@ -39,6 +48,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { env: "", buildArgs: "", buildSecrets: "", + createEnvFile: true, }, resolver: zodResolver(addEnvironmentSchema), }); @@ -47,10 +57,12 @@ export const ShowEnvironment = ({ applicationId }: Props) => { const currentEnv = form.watch("env"); const currentBuildArgs = form.watch("buildArgs"); const currentBuildSecrets = form.watch("buildSecrets"); + const currentCreateEnvFile = form.watch("createEnvFile"); const hasChanges = currentEnv !== (data?.env || "") || currentBuildArgs !== (data?.buildArgs || "") || - currentBuildSecrets !== (data?.buildSecrets || ""); + currentBuildSecrets !== (data?.buildSecrets || "") || + currentCreateEnvFile !== (data?.createEnvFile ?? true); useEffect(() => { if (data) { @@ -58,6 +70,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { env: data.env || "", buildArgs: data.buildArgs || "", buildSecrets: data.buildSecrets || "", + createEnvFile: data.createEnvFile ?? true, }); } }, [data, form]); @@ -67,6 +80,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { env: formData.env, buildArgs: formData.buildArgs, buildSecrets: formData.buildSecrets, + createEnvFile: formData.createEnvFile, applicationId, }) .then(async () => { @@ -83,6 +97,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { env: data?.env || "", buildArgs: data?.buildArgs || "", buildSecrets: data?.buildSecrets || "", + createEnvFile: data?.createEnvFile ?? true, }); }; @@ -167,6 +182,30 @@ export const ShowEnvironment = ({ applicationId }: Props) => { placeholder="NPM_TOKEN=xyz" /> )} + {data?.buildType === "dockerfile" && ( + ( + +
+ Create Environment File + + When enabled, an .env file will be created during the + build process. Disable this if you don't want to generate + an environment file. + +
+ + + +
+ )} + /> + )}
{hasChanges && (