mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-13 23:45:17 +00:00
Merge pull request #3591 from vtomasr5/allow-zipdrop-build-server
fix: extract ZIP drop deployment to build server when configured
This commit is contained in:
@@ -17,10 +17,13 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { appName } = application;
|
const { appName } = application;
|
||||||
const { APPLICATIONS_PATH } = paths(!!application.serverId);
|
// Use buildServerId if set, otherwise fall back to serverId
|
||||||
|
// This ensures the code is extracted to the server where the build will run
|
||||||
|
const targetServerId = application.buildServerId || application.serverId;
|
||||||
|
const { APPLICATIONS_PATH } = paths(!!targetServerId);
|
||||||
const outputPath = join(APPLICATIONS_PATH, appName, "code");
|
const outputPath = join(APPLICATIONS_PATH, appName, "code");
|
||||||
if (application.serverId) {
|
if (targetServerId) {
|
||||||
await recreateDirectoryRemote(outputPath, application.serverId);
|
await recreateDirectoryRemote(outputPath, targetServerId);
|
||||||
} else {
|
} else {
|
||||||
await recreateDirectory(outputPath);
|
await recreateDirectory(outputPath);
|
||||||
}
|
}
|
||||||
@@ -46,8 +49,8 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
|
|||||||
? rootEntries[0]?.entryName.split("/")[0]
|
? rootEntries[0]?.entryName.split("/")[0]
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
if (application.serverId) {
|
if (targetServerId) {
|
||||||
sftp = await getSFTPConnection(application.serverId);
|
sftp = await getSFTPConnection(targetServerId);
|
||||||
}
|
}
|
||||||
for (const entry of zipEntries) {
|
for (const entry of zipEntries) {
|
||||||
let filePath = entry.entryName;
|
let filePath = entry.entryName;
|
||||||
@@ -75,15 +78,12 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (application.serverId) {
|
if (targetServerId) {
|
||||||
if (!entry.isDirectory) {
|
if (!entry.isDirectory) {
|
||||||
if (sftp === null) throw new Error("No SFTP connection available");
|
if (sftp === null) throw new Error("No SFTP connection available");
|
||||||
try {
|
try {
|
||||||
const dirPath = path.dirname(fullPath);
|
const dirPath = path.dirname(fullPath);
|
||||||
await execAsyncRemote(
|
await execAsyncRemote(targetServerId, `mkdir -p "${dirPath}"`);
|
||||||
application.serverId,
|
|
||||||
`mkdir -p "${dirPath}"`,
|
|
||||||
);
|
|
||||||
await uploadFileToServer(sftp, entry.getData(), fullPath);
|
await uploadFileToServer(sftp, entry.getData(), fullPath);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Error uploading file ${fullPath}:`, err);
|
console.error(`Error uploading file ${fullPath}:`, err);
|
||||||
|
|||||||
Reference in New Issue
Block a user