mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 11:08:46 +00:00
Merge branch 'canary' into 3197-requests-page-started-showing-my-own-dashboard-requests
This commit is contained in:
@@ -28,6 +28,7 @@ const baseApp: ApplicationNested = {
|
|||||||
railpackVersion: "0.2.2",
|
railpackVersion: "0.2.2",
|
||||||
applicationId: "",
|
applicationId: "",
|
||||||
previewLabels: [],
|
previewLabels: [],
|
||||||
|
createEnvFile: true,
|
||||||
herokuVersion: "",
|
herokuVersion: "",
|
||||||
giteaBranch: "",
|
giteaBranch: "",
|
||||||
buildServerId: "",
|
buildServerId: "",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const baseApp: ApplicationNested = {
|
|||||||
rollbackActive: false,
|
rollbackActive: false,
|
||||||
applicationId: "",
|
applicationId: "",
|
||||||
previewLabels: [],
|
previewLabels: [],
|
||||||
|
createEnvFile: true,
|
||||||
herokuVersion: "",
|
herokuVersion: "",
|
||||||
giteaRepository: "",
|
giteaRepository: "",
|
||||||
giteaOwner: "",
|
giteaOwner: "",
|
||||||
|
|||||||
@@ -5,14 +5,23 @@ import { toast } from "sonner";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card } from "@/components/ui/card";
|
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 { Secrets } from "@/components/ui/secrets";
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
|
|
||||||
const addEnvironmentSchema = z.object({
|
const addEnvironmentSchema = z.object({
|
||||||
env: z.string(),
|
env: z.string(),
|
||||||
buildArgs: z.string(),
|
buildArgs: z.string(),
|
||||||
buildSecrets: z.string(),
|
buildSecrets: z.string(),
|
||||||
|
createEnvFile: z.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
type EnvironmentSchema = z.infer<typeof addEnvironmentSchema>;
|
type EnvironmentSchema = z.infer<typeof addEnvironmentSchema>;
|
||||||
@@ -39,6 +48,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
env: "",
|
env: "",
|
||||||
buildArgs: "",
|
buildArgs: "",
|
||||||
buildSecrets: "",
|
buildSecrets: "",
|
||||||
|
createEnvFile: true,
|
||||||
},
|
},
|
||||||
resolver: zodResolver(addEnvironmentSchema),
|
resolver: zodResolver(addEnvironmentSchema),
|
||||||
});
|
});
|
||||||
@@ -47,10 +57,12 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
const currentEnv = form.watch("env");
|
const currentEnv = form.watch("env");
|
||||||
const currentBuildArgs = form.watch("buildArgs");
|
const currentBuildArgs = form.watch("buildArgs");
|
||||||
const currentBuildSecrets = form.watch("buildSecrets");
|
const currentBuildSecrets = form.watch("buildSecrets");
|
||||||
|
const currentCreateEnvFile = form.watch("createEnvFile");
|
||||||
const hasChanges =
|
const hasChanges =
|
||||||
currentEnv !== (data?.env || "") ||
|
currentEnv !== (data?.env || "") ||
|
||||||
currentBuildArgs !== (data?.buildArgs || "") ||
|
currentBuildArgs !== (data?.buildArgs || "") ||
|
||||||
currentBuildSecrets !== (data?.buildSecrets || "");
|
currentBuildSecrets !== (data?.buildSecrets || "") ||
|
||||||
|
currentCreateEnvFile !== (data?.createEnvFile ?? true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -58,6 +70,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
env: data.env || "",
|
env: data.env || "",
|
||||||
buildArgs: data.buildArgs || "",
|
buildArgs: data.buildArgs || "",
|
||||||
buildSecrets: data.buildSecrets || "",
|
buildSecrets: data.buildSecrets || "",
|
||||||
|
createEnvFile: data.createEnvFile ?? true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [data, form]);
|
}, [data, form]);
|
||||||
@@ -67,6 +80,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
env: formData.env,
|
env: formData.env,
|
||||||
buildArgs: formData.buildArgs,
|
buildArgs: formData.buildArgs,
|
||||||
buildSecrets: formData.buildSecrets,
|
buildSecrets: formData.buildSecrets,
|
||||||
|
createEnvFile: formData.createEnvFile,
|
||||||
applicationId,
|
applicationId,
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
@@ -83,6 +97,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
env: data?.env || "",
|
env: data?.env || "",
|
||||||
buildArgs: data?.buildArgs || "",
|
buildArgs: data?.buildArgs || "",
|
||||||
buildSecrets: data?.buildSecrets || "",
|
buildSecrets: data?.buildSecrets || "",
|
||||||
|
createEnvFile: data?.createEnvFile ?? true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -167,6 +182,30 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
placeholder="NPM_TOKEN=xyz"
|
placeholder="NPM_TOKEN=xyz"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{data?.buildType === "dockerfile" && (
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="createEnvFile"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex flex-row items-center justify-between p-3 border rounded-lg shadow-sm">
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<FormLabel>Create Environment File</FormLabel>
|
||||||
|
<FormDescription>
|
||||||
|
When enabled, an .env file will be created during the
|
||||||
|
build process. Disable this if you don't want to generate
|
||||||
|
an environment file.
|
||||||
|
</FormDescription>
|
||||||
|
</div>
|
||||||
|
<FormControl>
|
||||||
|
<Switch
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="flex flex-row justify-end gap-2">
|
<div className="flex flex-row justify-end gap-2">
|
||||||
{hasChanges && (
|
{hasChanges && (
|
||||||
<Button type="button" variant="outline" onClick={handleCancel}>
|
<Button type="button" variant="outline" onClick={handleCancel}>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "application" ADD COLUMN "createEnvFile" boolean DEFAULT true NOT NULL;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -918,6 +918,13 @@
|
|||||||
"when": 1765167657813,
|
"when": 1765167657813,
|
||||||
"tag": "0130_perpetual_screwball",
|
"tag": "0130_perpetual_screwball",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 131,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1765342621312,
|
||||||
|
"tag": "0131_volatile_beast",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dokploy",
|
"name": "dokploy",
|
||||||
"version": "v0.26.0",
|
"version": "v0.26.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -81,41 +81,34 @@ export default async function handler(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!webhookImageName) {
|
// If webhook provides image information, validate it matches the configured image
|
||||||
res.status(301).json({
|
// If webhook doesn't provide image information, fall back to using the configured image (backward compatibility)
|
||||||
message: "Webhook Docker Image Name Not Found",
|
if (webhookImageName) {
|
||||||
});
|
// Validate image name matches
|
||||||
return;
|
if (webhookImageName !== applicationImageName) {
|
||||||
}
|
res.status(301).json({
|
||||||
|
message: `Application Image Name (${applicationImageName}) doesn't match request event payload Image Name (${webhookImageName}).`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Validate image name matches
|
if (!applicationDockerTag) {
|
||||||
if (webhookImageName !== applicationImageName) {
|
res.status(301).json({
|
||||||
res.status(301).json({
|
message: "Application Docker Tag Not Found",
|
||||||
message: `Application Image Name (${applicationImageName}) doesn't match request event payload Image Name (${webhookImageName}).`,
|
});
|
||||||
});
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!applicationDockerTag) {
|
if (webhookDockerTag) {
|
||||||
res.status(301).json({
|
if (webhookDockerTag !== applicationDockerTag) {
|
||||||
message: "Application Docker Tag Not Found",
|
res.status(301).json({
|
||||||
});
|
message: `Application Image Tag (${applicationDockerTag}) doesn't match request event payload Image Tag (${webhookDockerTag}).`,
|
||||||
return;
|
});
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (!webhookDockerTag) {
|
}
|
||||||
res.status(301).json({
|
|
||||||
message: "Webhook Docker Tag Not Found",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (webhookDockerTag !== applicationDockerTag) {
|
|
||||||
res.status(301).json({
|
|
||||||
message: `Application Image Tag (${applicationDockerTag}) doesn't match request event payload Image Tag (${webhookDockerTag}).`,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
// If webhook doesn't provide image info, we'll use the configured image (old behavior)
|
||||||
} else if (sourceType === "github") {
|
} else if (sourceType === "github") {
|
||||||
const normalizedCommits = req.body?.commits?.flatMap(
|
const normalizedCommits = req.body?.commits?.flatMap(
|
||||||
(commit: any) => commit.modified,
|
(commit: any) => commit.modified,
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
env: input.env,
|
env: input.env,
|
||||||
buildArgs: input.buildArgs,
|
buildArgs: input.buildArgs,
|
||||||
buildSecrets: input.buildSecrets,
|
buildSecrets: input.buildSecrets,
|
||||||
|
createEnvFile: input.createEnvFile,
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ export const applications = pgTable("application", {
|
|||||||
herokuVersion: text("herokuVersion").default("24"),
|
herokuVersion: text("herokuVersion").default("24"),
|
||||||
publishDirectory: text("publishDirectory"),
|
publishDirectory: text("publishDirectory"),
|
||||||
isStaticSpa: boolean("isStaticSpa"),
|
isStaticSpa: boolean("isStaticSpa"),
|
||||||
|
createEnvFile: boolean("createEnvFile").notNull().default(true),
|
||||||
createdAt: text("createdAt")
|
createdAt: text("createdAt")
|
||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
.$defaultFn(() => new Date().toISOString()),
|
||||||
@@ -332,6 +333,7 @@ const createSchema = createInsertSchema(applications, {
|
|||||||
herokuVersion: z.string().optional(),
|
herokuVersion: z.string().optional(),
|
||||||
publishDirectory: z.string().optional(),
|
publishDirectory: z.string().optional(),
|
||||||
isStaticSpa: z.boolean().optional(),
|
isStaticSpa: z.boolean().optional(),
|
||||||
|
createEnvFile: z.boolean().optional(),
|
||||||
owner: z.string(),
|
owner: z.string(),
|
||||||
healthCheckSwarm: HealthCheckSwarmSchema.nullable(),
|
healthCheckSwarm: HealthCheckSwarmSchema.nullable(),
|
||||||
restartPolicySwarm: RestartPolicySwarmSchema.nullable(),
|
restartPolicySwarm: RestartPolicySwarmSchema.nullable(),
|
||||||
@@ -501,6 +503,7 @@ export const apiSaveEnvironmentVariables = createSchema
|
|||||||
env: true,
|
env: true,
|
||||||
buildArgs: true,
|
buildArgs: true,
|
||||||
buildSecrets: true,
|
buildSecrets: true,
|
||||||
|
createEnvFile: true,
|
||||||
})
|
})
|
||||||
.required();
|
.required();
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export const initCronJobs = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (admin.user.enableDockerCleanup) {
|
if (admin?.user?.enableDockerCleanup) {
|
||||||
scheduleJob("docker-cleanup", "0 0 * * *", async () => {
|
scheduleJob("docker-cleanup", "0 0 * * *", async () => {
|
||||||
console.log(
|
console.log(
|
||||||
`Docker Cleanup ${new Date().toLocaleString()}] Running docker cleanup`,
|
`Docker Cleanup ${new Date().toLocaleString()}] Running docker cleanup`,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
getDockerContextPath,
|
getDockerContextPath,
|
||||||
} from "../filesystem/directory";
|
} from "../filesystem/directory";
|
||||||
import type { ApplicationNested } from ".";
|
import type { ApplicationNested } from ".";
|
||||||
|
import { createEnvFileCommand } from "./utils";
|
||||||
|
|
||||||
export const getDockerCommand = (application: ApplicationNested) => {
|
export const getDockerCommand = (application: ApplicationNested) => {
|
||||||
const {
|
const {
|
||||||
@@ -18,6 +19,7 @@ export const getDockerCommand = (application: ApplicationNested) => {
|
|||||||
buildSecrets,
|
buildSecrets,
|
||||||
dockerBuildStage,
|
dockerBuildStage,
|
||||||
cleanCache,
|
cleanCache,
|
||||||
|
createEnvFile,
|
||||||
} = application;
|
} = application;
|
||||||
const dockerFilePath = getBuildAppDirectory(application);
|
const dockerFilePath = getBuildAppDirectory(application);
|
||||||
|
|
||||||
@@ -60,6 +62,21 @@ export const getDockerCommand = (application: ApplicationNested) => {
|
|||||||
.map(([key, value]) => `${key}=${quote([value])}`)
|
.map(([key, value]) => `${key}=${quote([value])}`)
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|
||||||
|
/*
|
||||||
|
Do not generate an environment file when publishDirectory is specified,
|
||||||
|
as it could be publicly exposed.
|
||||||
|
Also respect the createEnvFile flag.
|
||||||
|
*/
|
||||||
|
let command = "";
|
||||||
|
if (!publishDirectory && createEnvFile) {
|
||||||
|
command += createEnvFileCommand(
|
||||||
|
dockerFilePath,
|
||||||
|
env,
|
||||||
|
application.environment.project.env,
|
||||||
|
application.environment.env,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
for (const key in secrets) {
|
for (const key in secrets) {
|
||||||
// Although buildx is smart enough to know we may be referring to an environment variable name,
|
// Although buildx is smart enough to know we may be referring to an environment variable name,
|
||||||
// we still make sure it doesn't fall back to `type=file`.
|
// we still make sure it doesn't fall back to `type=file`.
|
||||||
@@ -67,7 +84,7 @@ export const getDockerCommand = (application: ApplicationNested) => {
|
|||||||
commandArgs.push("--secret", `type=env,id=${key}`);
|
commandArgs.push("--secret", `type=env,id=${key}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const command = `
|
command += `
|
||||||
echo "Building ${appName}" ;
|
echo "Building ${appName}" ;
|
||||||
cd ${dockerContextPath} || {
|
cd ${dockerContextPath} || {
|
||||||
echo "❌ The path ${dockerContextPath} does not exist" ;
|
echo "❌ The path ${dockerContextPath} does not exist" ;
|
||||||
|
|||||||
Reference in New Issue
Block a user