@@ -5,14 +5,23 @@ import { toast } from "sonner";
55import { z } from "zod" ;
66import { Button } from "@/components/ui/button" ;
77import { Card } from "@/components/ui/card" ;
8- import { Form } from "@/components/ui/form" ;
8+ import {
9+ Form ,
10+ FormControl ,
11+ FormDescription ,
12+ FormField ,
13+ FormItem ,
14+ FormLabel ,
15+ } from "@/components/ui/form" ;
916import { Secrets } from "@/components/ui/secrets" ;
17+ import { Switch } from "@/components/ui/switch" ;
1018import { api } from "@/utils/api" ;
1119
1220const addEnvironmentSchema = z . object ( {
1321 env : z . string ( ) ,
1422 buildArgs : z . string ( ) ,
1523 buildSecrets : z . string ( ) ,
24+ createEnvFile : z . boolean ( ) ,
1625} ) ;
1726
1827type EnvironmentSchema = z . infer < typeof addEnvironmentSchema > ;
@@ -39,6 +48,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
3948 env : "" ,
4049 buildArgs : "" ,
4150 buildSecrets : "" ,
51+ createEnvFile : true ,
4252 } ,
4353 resolver : zodResolver ( addEnvironmentSchema ) ,
4454 } ) ;
@@ -47,17 +57,20 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
4757 const currentEnv = form . watch ( "env" ) ;
4858 const currentBuildArgs = form . watch ( "buildArgs" ) ;
4959 const currentBuildSecrets = form . watch ( "buildSecrets" ) ;
60+ const currentCreateEnvFile = form . watch ( "createEnvFile" ) ;
5061 const hasChanges =
5162 currentEnv !== ( data ?. env || "" ) ||
5263 currentBuildArgs !== ( data ?. buildArgs || "" ) ||
53- currentBuildSecrets !== ( data ?. buildSecrets || "" ) ;
64+ currentBuildSecrets !== ( data ?. buildSecrets || "" ) ||
65+ currentCreateEnvFile !== ( data ?. createEnvFile ?? true ) ;
5466
5567 useEffect ( ( ) => {
5668 if ( data ) {
5769 form . reset ( {
5870 env : data . env || "" ,
5971 buildArgs : data . buildArgs || "" ,
6072 buildSecrets : data . buildSecrets || "" ,
73+ createEnvFile : data . createEnvFile ?? true ,
6174 } ) ;
6275 }
6376 } , [ data , form ] ) ;
@@ -67,6 +80,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
6780 env : formData . env ,
6881 buildArgs : formData . buildArgs ,
6982 buildSecrets : formData . buildSecrets ,
83+ createEnvFile : formData . createEnvFile ,
7084 applicationId,
7185 } )
7286 . then ( async ( ) => {
@@ -83,6 +97,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
8397 env : data ?. env || "" ,
8498 buildArgs : data ?. buildArgs || "" ,
8599 buildSecrets : data ?. buildSecrets || "" ,
100+ createEnvFile : data ?. createEnvFile ?? true ,
86101 } ) ;
87102 } ;
88103
@@ -167,6 +182,30 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
167182 placeholder = "NPM_TOKEN=xyz"
168183 />
169184 ) }
185+ { data ?. buildType === "dockerfile" && (
186+ < FormField
187+ control = { form . control }
188+ name = "createEnvFile"
189+ render = { ( { field } ) => (
190+ < FormItem className = "flex flex-row items-center justify-between p-3 border rounded-lg shadow-sm" >
191+ < div className = "space-y-0.5" >
192+ < FormLabel > Create Environment File</ FormLabel >
193+ < FormDescription >
194+ When enabled, an .env file will be created during the
195+ build process. Disable this if you don't want to generate
196+ an environment file.
197+ </ FormDescription >
198+ </ div >
199+ < FormControl >
200+ < Switch
201+ checked = { field . value }
202+ onCheckedChange = { field . onChange }
203+ />
204+ </ FormControl >
205+ </ FormItem >
206+ ) }
207+ />
208+ ) }
170209 < div className = "flex flex-row justify-end gap-2" >
171210 { hasChanges && (
172211 < Button type = "button" variant = "outline" onClick = { handleCancel } >
0 commit comments