mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-07 15:05:23 +02:00
refactor: enhance project and environment handling across components and services by replacing projectId with environmentId, improving context clarity and authorization checks
This commit is contained in:
@@ -22,7 +22,7 @@ import { spawnAsync } from "../process/spawnAsync";
|
||||
|
||||
export type ComposeNested = InferResultType<
|
||||
"compose",
|
||||
{ project: true; mounts: true; domains: true }
|
||||
{ environment: { with: { project: true } }; mounts: true; domains: true }
|
||||
>;
|
||||
export const buildCompose = async (compose: ComposeNested, logPath: string) => {
|
||||
const writeStream = createWriteStream(logPath, { flags: "a" });
|
||||
@@ -72,7 +72,7 @@ export const buildCompose = async (compose: ComposeNested, logPath: string) => {
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
PATH: process.env.PATH,
|
||||
...(composeType === "stack" && {
|
||||
...getEnviromentVariablesObject(compose.env, compose.project.env),
|
||||
...getEnviromentVariablesObject(compose.env, compose.environment.project.env),
|
||||
}),
|
||||
},
|
||||
},
|
||||
@@ -202,7 +202,7 @@ const createEnvFile = (compose: ComposeNested) => {
|
||||
|
||||
const envFileContent = prepareEnvironmentVariables(
|
||||
envContent,
|
||||
compose.project.env,
|
||||
compose.environment.project.env,
|
||||
).join("\n");
|
||||
|
||||
if (!existsSync(dirname(envFilePath))) {
|
||||
@@ -232,7 +232,7 @@ export const getCreateEnvFileCommand = (compose: ComposeNested) => {
|
||||
|
||||
const envFileContent = prepareEnvironmentVariables(
|
||||
envContent,
|
||||
compose.project.env,
|
||||
compose.environment.project.env,
|
||||
).join("\n");
|
||||
|
||||
const encodedContent = encodeBase64(envFileContent);
|
||||
@@ -247,7 +247,7 @@ const getExportEnvCommand = (compose: ComposeNested) => {
|
||||
|
||||
const envVars = getEnviromentVariablesObject(
|
||||
compose.env,
|
||||
compose.project.env,
|
||||
compose.environment.project.env,
|
||||
);
|
||||
const exports = Object.entries(envVars)
|
||||
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
||||
|
||||
@@ -28,7 +28,7 @@ export const buildCustomDocker = async (
|
||||
dockerFilePath.substring(0, dockerFilePath.lastIndexOf("/") + 1) || ".";
|
||||
const args = prepareEnvironmentVariables(
|
||||
buildArgs,
|
||||
application.project.env,
|
||||
application.environment.project.env,
|
||||
);
|
||||
|
||||
const dockerContextPath = getDockerContextPath(application);
|
||||
@@ -51,7 +51,7 @@ export const buildCustomDocker = async (
|
||||
as it could be publicly exposed.
|
||||
*/
|
||||
if (!publishDirectory) {
|
||||
createEnvFile(dockerFilePath, env, application.project.env);
|
||||
createEnvFile(dockerFilePath, env, application.environment.project.env);
|
||||
}
|
||||
|
||||
await spawnAsync(
|
||||
@@ -92,7 +92,7 @@ export const getDockerCommand = (
|
||||
dockerFilePath.substring(0, dockerFilePath.lastIndexOf("/") + 1) || ".";
|
||||
const args = prepareEnvironmentVariables(
|
||||
buildArgs,
|
||||
application.project.env,
|
||||
application.environment.project.env,
|
||||
);
|
||||
|
||||
const dockerContextPath =
|
||||
@@ -121,7 +121,7 @@ export const getDockerCommand = (
|
||||
command += createEnvFileCommand(
|
||||
dockerFilePath,
|
||||
env,
|
||||
application.project.env,
|
||||
application.environment.project.env,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export const buildHeroku = async (
|
||||
const buildAppDirectory = getBuildAppDirectory(application);
|
||||
const envVariables = prepareEnvironmentVariables(
|
||||
env,
|
||||
application.project.env,
|
||||
application.environment.project.env,
|
||||
);
|
||||
try {
|
||||
const args = [
|
||||
@@ -53,7 +53,7 @@ export const getHerokuCommand = (
|
||||
const buildAppDirectory = getBuildAppDirectory(application);
|
||||
const envVariables = prepareEnvironmentVariables(
|
||||
env,
|
||||
application.project.env,
|
||||
application.environment.project.env,
|
||||
);
|
||||
|
||||
const args = [
|
||||
|
||||
@@ -17,13 +17,22 @@ import { buildNixpacks, getNixpacksCommand } from "./nixpacks";
|
||||
import { buildPaketo, getPaketoCommand } from "./paketo";
|
||||
import { buildRailpack, getRailpackCommand } from "./railpack";
|
||||
import { buildStatic, getStaticCommand } from "./static";
|
||||
import { findApplicationById } from "@dokploy/server/services/application";
|
||||
|
||||
// NIXPACKS codeDirectory = where is the path of the code directory
|
||||
// HEROKU codeDirectory = where is the path of the code directory
|
||||
// PAKETO codeDirectory = where is the path of the code directory
|
||||
// DOCKERFILE codeDirectory = where is the exact path of the (Dockerfile)
|
||||
export type ApplicationNested = Awaited<ReturnType<typeof findApplicationById>>;
|
||||
export type ApplicationNested = InferResultType<
|
||||
"applications",
|
||||
{
|
||||
mounts: true;
|
||||
security: true;
|
||||
redirects: true;
|
||||
ports: true;
|
||||
registry: true;
|
||||
environment: { with: { project: true } };
|
||||
}
|
||||
>;
|
||||
|
||||
export const buildApplication = async (
|
||||
application: ApplicationNested,
|
||||
|
||||
@@ -20,7 +20,7 @@ export const buildNixpacks = async (
|
||||
const buildContainerId = `${appName}-${nanoid(10)}`;
|
||||
const envVariables = prepareEnvironmentVariables(
|
||||
env,
|
||||
application.project.env,
|
||||
application.environment.project.env,
|
||||
);
|
||||
|
||||
const writeToStream = (data: string) => {
|
||||
@@ -101,7 +101,7 @@ export const getNixpacksCommand = (
|
||||
const buildContainerId = `${appName}-${nanoid(10)}`;
|
||||
const envVariables = prepareEnvironmentVariables(
|
||||
env,
|
||||
application.project.env,
|
||||
application.environment.project.env,
|
||||
);
|
||||
|
||||
const args = ["build", buildAppDirectory, "--name", appName];
|
||||
|
||||
@@ -12,7 +12,7 @@ export const buildPaketo = async (
|
||||
const buildAppDirectory = getBuildAppDirectory(application);
|
||||
const envVariables = prepareEnvironmentVariables(
|
||||
env,
|
||||
application.project.env,
|
||||
application.environment.project.env,
|
||||
);
|
||||
try {
|
||||
const args = [
|
||||
@@ -52,7 +52,7 @@ export const getPaketoCommand = (
|
||||
const buildAppDirectory = getBuildAppDirectory(application);
|
||||
const envVariables = prepareEnvironmentVariables(
|
||||
env,
|
||||
application.project.env,
|
||||
application.environment.project.env,
|
||||
);
|
||||
|
||||
const args = [
|
||||
|
||||
Reference in New Issue
Block a user