From 17f83f746ab749860290b159bffea2365a3e3608 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Tue, 9 Dec 2025 22:59:04 -0600 Subject: [PATCH 1/3] feat(environment): add createEnvFile option to environment settings - Introduced a new boolean field `createEnvFile` in the environment schema to control the generation of an .env file during the build process. - Updated the form in the dashboard to include a toggle for `createEnvFile`, allowing users to enable or disable this feature. - Modified the Docker command generation logic to respect the `createEnvFile` flag, ensuring that the environment file is only created when appropriate. - Updated the database schema to include the `createEnvFile` column in the application table with a default value of true. --- .../application/environment/show.tsx | 35 +- apps/dokploy/drizzle/0131_volatile_beast.sql | 1 + apps/dokploy/drizzle/meta/0131_snapshot.json | 6928 +++++++++++++++++ apps/dokploy/drizzle/meta/_journal.json | 7 + .../dokploy/server/api/routers/application.ts | 1 + packages/server/src/db/schema/application.ts | 3 + .../server/src/utils/builders/docker-file.ts | 19 +- 7 files changed, 6991 insertions(+), 3 deletions(-) create mode 100644 apps/dokploy/drizzle/0131_volatile_beast.sql create mode 100644 apps/dokploy/drizzle/meta/0131_snapshot.json diff --git a/apps/dokploy/components/dashboard/application/environment/show.tsx b/apps/dokploy/components/dashboard/application/environment/show.tsx index 48e978880..071d7bc90 100644 --- a/apps/dokploy/components/dashboard/application/environment/show.tsx +++ b/apps/dokploy/components/dashboard/application/environment/show.tsx @@ -5,14 +5,16 @@ 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 +41,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { env: "", buildArgs: "", buildSecrets: "", + createEnvFile: true, }, resolver: zodResolver(addEnvironmentSchema), }); @@ -47,10 +50,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 +63,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { env: data.env || "", buildArgs: data.buildArgs || "", buildSecrets: data.buildSecrets || "", + createEnvFile: data.createEnvFile ?? true, }); } }, [data, form]); @@ -67,6 +73,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { env: formData.env, buildArgs: formData.buildArgs, buildSecrets: formData.buildSecrets, + createEnvFile: formData.createEnvFile, applicationId, }) .then(async () => { @@ -83,6 +90,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => { env: data?.env || "", buildArgs: data?.buildArgs || "", buildSecrets: data?.buildSecrets || "", + createEnvFile: data?.createEnvFile ?? true, }); }; @@ -167,6 +175,29 @@ 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 && (