mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix(nixpacks): adjust build path on nixpacks static
This commit is contained in:
parent
7cce02f74d
commit
b48b9765cd
@ -1,4 +1,4 @@
|
|||||||
import type { WriteStream } from "node:fs";
|
import { mkdirSync, type WriteStream, existsSync } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { buildStatic, getStaticCommand } from "@/server/utils/builders/static";
|
import { buildStatic, getStaticCommand } from "@/server/utils/builders/static";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
@ -42,7 +42,6 @@ export const buildNixpacks = async (
|
|||||||
and copy the artifacts on the host filesystem.
|
and copy the artifacts on the host filesystem.
|
||||||
Then, remove the container and create a static build.
|
Then, remove the container and create a static build.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (publishDirectory) {
|
if (publishDirectory) {
|
||||||
await spawnAsync(
|
await spawnAsync(
|
||||||
"docker",
|
"docker",
|
||||||
@ -50,12 +49,22 @@ export const buildNixpacks = async (
|
|||||||
writeToStream,
|
writeToStream,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const localPath = path.join(buildAppDirectory, publishDirectory);
|
||||||
|
|
||||||
|
if (!existsSync(path.dirname(localPath))) {
|
||||||
|
mkdirSync(path.dirname(localPath), { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://docs.docker.com/reference/cli/docker/container/cp/
|
||||||
|
const isDirectory =
|
||||||
|
publishDirectory.endsWith("/") || !path.extname(publishDirectory);
|
||||||
|
|
||||||
await spawnAsync(
|
await spawnAsync(
|
||||||
"docker",
|
"docker",
|
||||||
[
|
[
|
||||||
"cp",
|
"cp",
|
||||||
`${buildContainerId}:/app/${publishDirectory}`,
|
`${buildContainerId}:/app/${publishDirectory}${isDirectory ? "/." : ""}`,
|
||||||
path.join(buildAppDirectory, publishDirectory),
|
localPath,
|
||||||
],
|
],
|
||||||
writeToStream,
|
writeToStream,
|
||||||
);
|
);
|
||||||
@ -108,9 +117,14 @@ echo "✅ Nixpacks build completed." >> ${logPath};
|
|||||||
Then, remove the container and create a static build.
|
Then, remove the container and create a static build.
|
||||||
*/
|
*/
|
||||||
if (publishDirectory) {
|
if (publishDirectory) {
|
||||||
|
const localPath = path.join(buildAppDirectory, publishDirectory);
|
||||||
|
const isDirectory =
|
||||||
|
publishDirectory.endsWith("/") || !path.extname(publishDirectory);
|
||||||
|
|
||||||
bashCommand += `
|
bashCommand += `
|
||||||
docker create --name ${buildContainerId} ${appName}
|
docker create --name ${buildContainerId} ${appName}
|
||||||
docker cp ${buildContainerId}:/app/${publishDirectory} ${path.join(buildAppDirectory, publishDirectory)} >> ${logPath} 2>> ${logPath} || {
|
mkdir -p ${localPath}
|
||||||
|
docker cp ${buildContainerId}:/app/${publishDirectory}${isDirectory ? "/." : ""} ${path.join(buildAppDirectory, publishDirectory)} >> ${logPath} 2>> ${logPath} || {
|
||||||
docker rm ${buildContainerId}
|
docker rm ${buildContainerId}
|
||||||
echo "❌ Copying ${publishDirectory} to ${path.join(buildAppDirectory, publishDirectory)} failed" >> ${logPath};
|
echo "❌ Copying ${publishDirectory} to ${path.join(buildAppDirectory, publishDirectory)} failed" >> ${logPath};
|
||||||
exit 1;
|
exit 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user