Merge pull request #3640 from Dokploy/3636-bug-build-server-env-file-creation-fails---no-such-file-or-directory-on-remote-build-server

3636 bug build server env file creation fails   no such file or directory on remote build server
This commit is contained in:
Mauricio Siu
2026-02-07 23:35:22 -06:00
committed by GitHub
6 changed files with 18 additions and 31 deletions
@@ -175,7 +175,7 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
services?.find((c) => c.containerId === containerId)?.error && ( services?.find((c) => c.containerId === containerId)?.error && (
<div className="rounded-md bg-destructive/10 border border-destructive/20 px-3 py-2 text-sm text-destructive"> <div className="rounded-md bg-destructive/10 border border-destructive/20 px-3 py-2 text-sm text-destructive">
<span className="font-medium">Error: </span> <span className="font-medium">Error: </span>
{services.find((c) => c.containerId === containerId)?.error} {services?.find((c) => c.containerId === containerId)?.error}
</div> </div>
)} )}
<DockerLogs <DockerLogs
+1 -2
View File
@@ -34,14 +34,13 @@ export const setupDeploymentLogsWebSocketServer = (
// Generate unique connection ID for tracking // Generate unique connection ID for tracking
const connectionId = `deployment-logs-${Date.now()}-${Math.random().toString(36).substring(7)}`; const connectionId = `deployment-logs-${Date.now()}-${Math.random().toString(36).substring(7)}`;
if (!logPath) { if (!logPath) {
console.log(`[${connectionId}] logPath no provided`); console.log(`[${connectionId}] logPath no provided`);
ws.close(4000, "logPath no provided"); ws.close(4000, "logPath no provided");
return; return;
} }
if (!readValidDirectory(logPath)) { if (!readValidDirectory(logPath, serverId)) {
ws.close(4000, "Invalid log path"); ws.close(4000, "Invalid log path");
return; return;
} }
+5 -2
View File
@@ -32,8 +32,11 @@ export const isValidShell = (shell: string): boolean => {
return allowedShells.includes(shell); return allowedShells.includes(shell);
}; };
export const readValidDirectory = (directory: string) => { export const readValidDirectory = (
const { BASE_PATH } = paths(); directory: string,
serverId?: string | null,
) => {
const { BASE_PATH } = paths(!!serverId);
const resolvedBase = path.resolve(BASE_PATH); const resolvedBase = path.resolve(BASE_PATH);
const resolvedDir = path.resolve(directory); const resolvedDir = path.resolve(directory);
+9 -6
View File
@@ -174,6 +174,10 @@ export const deployApplication = async ({
}) => { }) => {
const application = await findApplicationById(applicationId); const application = await findApplicationById(applicationId);
const serverId = application.buildServerId || application.serverId; const serverId = application.buildServerId || application.serverId;
const applicationEntity = {
...application,
serverId: serverId,
};
const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`; const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`;
const deployment = await createDeployment({ const deployment = await createDeployment({
@@ -185,15 +189,15 @@ export const deployApplication = async ({
try { try {
let command = "set -e;"; let command = "set -e;";
if (application.sourceType === "github") { if (application.sourceType === "github") {
command += await cloneGithubRepository(application); command += await cloneGithubRepository(applicationEntity);
} else if (application.sourceType === "gitlab") { } else if (application.sourceType === "gitlab") {
command += await cloneGitlabRepository(application); command += await cloneGitlabRepository(applicationEntity);
} else if (application.sourceType === "gitea") { } else if (application.sourceType === "gitea") {
command += await cloneGiteaRepository(application); command += await cloneGiteaRepository(applicationEntity);
} else if (application.sourceType === "bitbucket") { } else if (application.sourceType === "bitbucket") {
command += await cloneBitbucketRepository(application); command += await cloneBitbucketRepository(applicationEntity);
} else if (application.sourceType === "git") { } else if (application.sourceType === "git") {
command += await cloneGitRepository(application); command += await cloneGitRepository(applicationEntity);
} else if (application.sourceType === "docker") { } else if (application.sourceType === "docker") {
command += await buildRemoteDocker(application); command += await buildRemoteDocker(application);
} }
@@ -258,7 +262,6 @@ export const deployApplication = async ({
type: "application", type: "application",
serverId: serverId, serverId: serverId,
}); });
if (commitInfo) { if (commitInfo) {
await updateDeployment(deployment.deploymentId, { await updateDeployment(deployment.deploymentId, {
title: commitInfo.message, title: commitInfo.message,
@@ -1,25 +1,6 @@
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path"; import { dirname, join } from "node:path";
import { encodeBase64, prepareEnvironmentVariables } from "../docker/utils"; import { encodeBase64, prepareEnvironmentVariables } from "../docker/utils";
export const createEnvFile = (
directory: string,
env: string | null,
projectEnv?: string | null,
environmentEnv?: string | null,
) => {
const envFilePath = join(dirname(directory), ".env");
if (!existsSync(dirname(envFilePath))) {
mkdirSync(dirname(envFilePath), { recursive: true });
}
const envFileContent = prepareEnvironmentVariables(
env,
projectEnv,
environmentEnv,
).join("\n");
writeFileSync(envFilePath, envFileContent);
};
export const createEnvFileCommand = ( export const createEnvFileCommand = (
directory: string, directory: string,
env: string | null, env: string | null,
@@ -102,7 +102,8 @@ export const removeMonitoringDirectory = async (
}; };
export const getBuildAppDirectory = (application: Application) => { export const getBuildAppDirectory = (application: Application) => {
const { APPLICATIONS_PATH } = paths(!!application.serverId); const serverId = application.buildServerId || application.serverId;
const { APPLICATIONS_PATH } = paths(!!serverId);
const { appName, buildType, sourceType, customGitBuildPath, dockerfile } = const { appName, buildType, sourceType, customGitBuildPath, dockerfile } =
application; application;
let buildPath = ""; let buildPath = "";