mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-06 04:02:16 +00: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:
@@ -56,13 +56,20 @@ const baseApp: ApplicationNested = {
|
|||||||
previewPort: 3000,
|
previewPort: 3000,
|
||||||
previewLimit: 0,
|
previewLimit: 0,
|
||||||
previewWildcard: "",
|
previewWildcard: "",
|
||||||
project: {
|
environment: {
|
||||||
env: "",
|
environmentId: "",
|
||||||
organizationId: "",
|
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
|
||||||
createdAt: "",
|
createdAt: "",
|
||||||
|
description: "",
|
||||||
projectId: "",
|
projectId: "",
|
||||||
|
project: {
|
||||||
|
env: "",
|
||||||
|
organizationId: "",
|
||||||
|
name: "",
|
||||||
|
description: "",
|
||||||
|
createdAt: "",
|
||||||
|
projectId: "",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
buildArgs: null,
|
buildArgs: null,
|
||||||
buildPath: "/",
|
buildPath: "/",
|
||||||
@@ -92,6 +99,7 @@ const baseApp: ApplicationNested = {
|
|||||||
dockerfile: null,
|
dockerfile: null,
|
||||||
dockerImage: null,
|
dockerImage: null,
|
||||||
dropBuildPath: null,
|
dropBuildPath: null,
|
||||||
|
environmentId: "",
|
||||||
enabled: null,
|
enabled: null,
|
||||||
env: null,
|
env: null,
|
||||||
healthCheckSwarm: null,
|
healthCheckSwarm: null,
|
||||||
@@ -106,7 +114,6 @@ const baseApp: ApplicationNested = {
|
|||||||
password: null,
|
password: null,
|
||||||
placementSwarm: null,
|
placementSwarm: null,
|
||||||
ports: [],
|
ports: [],
|
||||||
projectId: "",
|
|
||||||
publishDirectory: null,
|
publishDirectory: null,
|
||||||
isStaticSpa: null,
|
isStaticSpa: null,
|
||||||
redirects: [],
|
redirects: [],
|
||||||
|
|||||||
@@ -36,13 +36,21 @@ const baseApp: ApplicationNested = {
|
|||||||
previewLimit: 0,
|
previewLimit: 0,
|
||||||
previewCustomCertResolver: null,
|
previewCustomCertResolver: null,
|
||||||
previewWildcard: "",
|
previewWildcard: "",
|
||||||
project: {
|
environmentId: "",
|
||||||
env: "",
|
environment: {
|
||||||
organizationId: "",
|
environmentId: "",
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
|
||||||
createdAt: "",
|
createdAt: "",
|
||||||
|
description: "",
|
||||||
projectId: "",
|
projectId: "",
|
||||||
|
project: {
|
||||||
|
env: "",
|
||||||
|
organizationId: "",
|
||||||
|
name: "",
|
||||||
|
description: "",
|
||||||
|
createdAt: "",
|
||||||
|
projectId: "",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
buildPath: "/",
|
buildPath: "/",
|
||||||
gitlabPathNamespace: "",
|
gitlabPathNamespace: "",
|
||||||
@@ -85,7 +93,6 @@ const baseApp: ApplicationNested = {
|
|||||||
password: null,
|
password: null,
|
||||||
placementSwarm: null,
|
placementSwarm: null,
|
||||||
ports: [],
|
ports: [],
|
||||||
projectId: "",
|
|
||||||
publishDirectory: null,
|
publishDirectory: null,
|
||||||
isStaticSpa: null,
|
isStaticSpa: null,
|
||||||
redirects: [],
|
redirects: [],
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export const DeleteService = ({ id, type }: Props) => {
|
|||||||
deleteVolumes,
|
deleteVolumes,
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
push(`/dashboard/project/${result?.projectId}`);
|
push(`/dashboard/project/${result?.environment?.projectId}/environment/${result?.environment?.environmentId}`);
|
||||||
toast.success("deleted successfully");
|
toast.success("deleted successfully");
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import { Badge } from "@/components/ui/badge";
|
|||||||
import { AlertBlock } from "@/components/shared/alert-block";
|
import { AlertBlock } from "@/components/shared/alert-block";
|
||||||
import { findEnvironmentById } from "@dokploy/server";
|
import { findEnvironmentById } from "@dokploy/server";
|
||||||
|
|
||||||
type Environment = Awaited<ReturnType<typeof findEnvironmentById>>;
|
type Environment = Omit<Awaited<ReturnType<typeof findEnvironmentById>>, "project">;
|
||||||
interface AdvancedEnvironmentSelectorProps {
|
interface AdvancedEnvironmentSelectorProps {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
currentEnvironmentId?: string;
|
currentEnvironmentId?: string;
|
||||||
@@ -242,17 +242,6 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
>
|
>
|
||||||
<PencilIcon className="h-3 w-3" />
|
<PencilIcon className="h-3 w-3" />
|
||||||
</Button>
|
</Button>
|
||||||
{/* <Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="h-6 w-6 p-0"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
handleDuplicateEnvironment(environment);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CopyIcon className="h-3 w-3" />
|
|
||||||
</Button> */}
|
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export const HandleProject = ({ projectId }: Props) => {
|
|||||||
toast.success(projectId ? "Project Updated" : "Project Created");
|
toast.success(projectId ? "Project Updated" : "Project Created");
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
if (!projectId) {
|
if (!projectId) {
|
||||||
router.push(`/dashboard/project/${data?.projectId}`);
|
router.push(`/dashboard/project/${data?.project?.projectId}/environment/${data?.environment?.environmentId}`);
|
||||||
} else {
|
} else {
|
||||||
refetch();
|
refetch();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ export default async function handler(
|
|||||||
const composeResult = await db.query.compose.findFirst({
|
const composeResult = await db.query.compose.findFirst({
|
||||||
where: eq(compose.refreshToken, refreshToken as string),
|
where: eq(compose.refreshToken, refreshToken as string),
|
||||||
with: {
|
with: {
|
||||||
project: true,
|
environment: {
|
||||||
|
with: {
|
||||||
|
project: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
bitbucket: true,
|
bitbucket: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result[0];
|
return application;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
stop: protectedProcedure
|
stop: protectedProcedure
|
||||||
|
|||||||
@@ -208,7 +208,6 @@ export const composeRouter = createTRPCRouter({
|
|||||||
message: "You are not authorized to delete this compose",
|
message: "You are not authorized to delete this compose",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
4;
|
|
||||||
|
|
||||||
const result = await db
|
const result = await db
|
||||||
.delete(composeTable)
|
.delete(composeTable)
|
||||||
@@ -227,7 +226,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result[0];
|
return composeResult;
|
||||||
}),
|
}),
|
||||||
cleanQueues: protectedProcedure
|
cleanQueues: protectedProcedure
|
||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const redirectsRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (
|
if (
|
||||||
application.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -34,7 +34,7 @@ export const redirectsRouter = createTRPCRouter({
|
|||||||
const redirect = await findRedirectById(input.redirectId);
|
const redirect = await findRedirectById(input.redirectId);
|
||||||
const application = await findApplicationById(redirect.applicationId);
|
const application = await findApplicationById(redirect.applicationId);
|
||||||
if (
|
if (
|
||||||
application.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -49,7 +49,7 @@ export const redirectsRouter = createTRPCRouter({
|
|||||||
const redirect = await findRedirectById(input.redirectId);
|
const redirect = await findRedirectById(input.redirectId);
|
||||||
const application = await findApplicationById(redirect.applicationId);
|
const application = await findApplicationById(redirect.applicationId);
|
||||||
if (
|
if (
|
||||||
application.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
@@ -64,7 +64,7 @@ export const redirectsRouter = createTRPCRouter({
|
|||||||
const redirect = await findRedirectById(input.redirectId);
|
const redirect = await findRedirectById(input.redirectId);
|
||||||
const application = await findApplicationById(redirect.applicationId);
|
const application = await findApplicationById(redirect.applicationId);
|
||||||
if (
|
if (
|
||||||
application.project.organizationId !== ctx.session.activeOrganizationId
|
application.environment.project.organizationId !== ctx.session.activeOrganizationId
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
code: "UNAUTHORIZED",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
createDeploymentBackup,
|
createDeploymentBackup,
|
||||||
updateDeploymentStatus,
|
updateDeploymentStatus,
|
||||||
} from "@dokploy/server/services/deployment";
|
} from "@dokploy/server/services/deployment";
|
||||||
|
import { findEnvironmentById } from "@dokploy/server/services/environment";
|
||||||
import { findProjectById } from "@dokploy/server/services/project";
|
import { findProjectById } from "@dokploy/server/services/project";
|
||||||
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
||||||
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||||
@@ -13,8 +14,9 @@ export const runComposeBackup = async (
|
|||||||
compose: Compose,
|
compose: Compose,
|
||||||
backup: BackupSchedule,
|
backup: BackupSchedule,
|
||||||
) => {
|
) => {
|
||||||
const { projectId, name } = compose;
|
const { environmentId, name } = compose;
|
||||||
const project = await findProjectById(projectId);
|
const environment = await findEnvironmentById(environmentId);
|
||||||
|
const project = await findProjectById(environment.projectId);
|
||||||
const { prefix, databaseType } = backup;
|
const { prefix, databaseType } = backup;
|
||||||
const destination = backup.destination;
|
const destination = backup.destination;
|
||||||
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
updateDeploymentStatus,
|
updateDeploymentStatus,
|
||||||
} from "@dokploy/server/services/deployment";
|
} from "@dokploy/server/services/deployment";
|
||||||
import type { Mariadb } from "@dokploy/server/services/mariadb";
|
import type { Mariadb } from "@dokploy/server/services/mariadb";
|
||||||
|
import { findEnvironmentById } from "@dokploy/server/services/environment";
|
||||||
import { findProjectById } from "@dokploy/server/services/project";
|
import { findProjectById } from "@dokploy/server/services/project";
|
||||||
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
||||||
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||||
@@ -13,8 +14,9 @@ export const runMariadbBackup = async (
|
|||||||
mariadb: Mariadb,
|
mariadb: Mariadb,
|
||||||
backup: BackupSchedule,
|
backup: BackupSchedule,
|
||||||
) => {
|
) => {
|
||||||
const { projectId, name } = mariadb;
|
const { environmentId, name } = mariadb;
|
||||||
const project = await findProjectById(projectId);
|
const environment = await findEnvironmentById(environmentId);
|
||||||
|
const project = await findProjectById(environment.projectId);
|
||||||
const { prefix } = backup;
|
const { prefix } = backup;
|
||||||
const destination = backup.destination;
|
const destination = backup.destination;
|
||||||
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ import {
|
|||||||
updateDeploymentStatus,
|
updateDeploymentStatus,
|
||||||
} from "@dokploy/server/services/deployment";
|
} from "@dokploy/server/services/deployment";
|
||||||
import type { Mongo } from "@dokploy/server/services/mongo";
|
import type { Mongo } from "@dokploy/server/services/mongo";
|
||||||
|
import { findEnvironmentById } from "@dokploy/server/services/environment";
|
||||||
import { findProjectById } from "@dokploy/server/services/project";
|
import { findProjectById } from "@dokploy/server/services/project";
|
||||||
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
||||||
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||||
import { getBackupCommand, getS3Credentials, normalizeS3Path } from "./utils";
|
import { getBackupCommand, getS3Credentials, normalizeS3Path } from "./utils";
|
||||||
|
|
||||||
export const runMongoBackup = async (mongo: Mongo, backup: BackupSchedule) => {
|
export const runMongoBackup = async (mongo: Mongo, backup: BackupSchedule) => {
|
||||||
const { projectId, name } = mongo;
|
const { environmentId, name } = mongo;
|
||||||
const project = await findProjectById(projectId);
|
const environment = await findEnvironmentById(environmentId);
|
||||||
|
const project = await findProjectById(environment.projectId);
|
||||||
const { prefix } = backup;
|
const { prefix } = backup;
|
||||||
const destination = backup.destination;
|
const destination = backup.destination;
|
||||||
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ import {
|
|||||||
updateDeploymentStatus,
|
updateDeploymentStatus,
|
||||||
} from "@dokploy/server/services/deployment";
|
} from "@dokploy/server/services/deployment";
|
||||||
import type { MySql } from "@dokploy/server/services/mysql";
|
import type { MySql } from "@dokploy/server/services/mysql";
|
||||||
|
import { findEnvironmentById } from "@dokploy/server/services/environment";
|
||||||
import { findProjectById } from "@dokploy/server/services/project";
|
import { findProjectById } from "@dokploy/server/services/project";
|
||||||
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
||||||
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||||
import { getBackupCommand, getS3Credentials, normalizeS3Path } from "./utils";
|
import { getBackupCommand, getS3Credentials, normalizeS3Path } from "./utils";
|
||||||
|
|
||||||
export const runMySqlBackup = async (mysql: MySql, backup: BackupSchedule) => {
|
export const runMySqlBackup = async (mysql: MySql, backup: BackupSchedule) => {
|
||||||
const { projectId, name } = mysql;
|
const { environmentId, name } = mysql;
|
||||||
const project = await findProjectById(projectId);
|
const environment = await findEnvironmentById(environmentId);
|
||||||
|
const project = await findProjectById(environment.projectId);
|
||||||
const { prefix } = backup;
|
const { prefix } = backup;
|
||||||
const destination = backup.destination;
|
const destination = backup.destination;
|
||||||
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
updateDeploymentStatus,
|
updateDeploymentStatus,
|
||||||
} from "@dokploy/server/services/deployment";
|
} from "@dokploy/server/services/deployment";
|
||||||
import type { Postgres } from "@dokploy/server/services/postgres";
|
import type { Postgres } from "@dokploy/server/services/postgres";
|
||||||
|
import { findEnvironmentById } from "@dokploy/server/services/environment";
|
||||||
import { findProjectById } from "@dokploy/server/services/project";
|
import { findProjectById } from "@dokploy/server/services/project";
|
||||||
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
||||||
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||||
@@ -13,8 +14,9 @@ export const runPostgresBackup = async (
|
|||||||
postgres: Postgres,
|
postgres: Postgres,
|
||||||
backup: BackupSchedule,
|
backup: BackupSchedule,
|
||||||
) => {
|
) => {
|
||||||
const { name, projectId } = postgres;
|
const { name, environmentId } = postgres;
|
||||||
const project = await findProjectById(projectId);
|
const environment = await findEnvironmentById(environmentId);
|
||||||
|
const project = await findProjectById(environment.projectId);
|
||||||
|
|
||||||
const deployment = await createDeploymentBackup({
|
const deployment = await createDeploymentBackup({
|
||||||
backupId: backup.backupId,
|
backupId: backup.backupId,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { spawnAsync } from "../process/spawnAsync";
|
|||||||
|
|
||||||
export type ComposeNested = InferResultType<
|
export type ComposeNested = InferResultType<
|
||||||
"compose",
|
"compose",
|
||||||
{ project: true; mounts: true; domains: true }
|
{ environment: { with: { project: true } }; mounts: true; domains: true }
|
||||||
>;
|
>;
|
||||||
export const buildCompose = async (compose: ComposeNested, logPath: string) => {
|
export const buildCompose = async (compose: ComposeNested, logPath: string) => {
|
||||||
const writeStream = createWriteStream(logPath, { flags: "a" });
|
const writeStream = createWriteStream(logPath, { flags: "a" });
|
||||||
@@ -72,7 +72,7 @@ export const buildCompose = async (compose: ComposeNested, logPath: string) => {
|
|||||||
NODE_ENV: process.env.NODE_ENV,
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
PATH: process.env.PATH,
|
PATH: process.env.PATH,
|
||||||
...(composeType === "stack" && {
|
...(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(
|
const envFileContent = prepareEnvironmentVariables(
|
||||||
envContent,
|
envContent,
|
||||||
compose.project.env,
|
compose.environment.project.env,
|
||||||
).join("\n");
|
).join("\n");
|
||||||
|
|
||||||
if (!existsSync(dirname(envFilePath))) {
|
if (!existsSync(dirname(envFilePath))) {
|
||||||
@@ -232,7 +232,7 @@ export const getCreateEnvFileCommand = (compose: ComposeNested) => {
|
|||||||
|
|
||||||
const envFileContent = prepareEnvironmentVariables(
|
const envFileContent = prepareEnvironmentVariables(
|
||||||
envContent,
|
envContent,
|
||||||
compose.project.env,
|
compose.environment.project.env,
|
||||||
).join("\n");
|
).join("\n");
|
||||||
|
|
||||||
const encodedContent = encodeBase64(envFileContent);
|
const encodedContent = encodeBase64(envFileContent);
|
||||||
@@ -247,7 +247,7 @@ const getExportEnvCommand = (compose: ComposeNested) => {
|
|||||||
|
|
||||||
const envVars = getEnviromentVariablesObject(
|
const envVars = getEnviromentVariablesObject(
|
||||||
compose.env,
|
compose.env,
|
||||||
compose.project.env,
|
compose.environment.project.env,
|
||||||
);
|
);
|
||||||
const exports = Object.entries(envVars)
|
const exports = Object.entries(envVars)
|
||||||
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const buildCustomDocker = async (
|
|||||||
dockerFilePath.substring(0, dockerFilePath.lastIndexOf("/") + 1) || ".";
|
dockerFilePath.substring(0, dockerFilePath.lastIndexOf("/") + 1) || ".";
|
||||||
const args = prepareEnvironmentVariables(
|
const args = prepareEnvironmentVariables(
|
||||||
buildArgs,
|
buildArgs,
|
||||||
application.project.env,
|
application.environment.project.env,
|
||||||
);
|
);
|
||||||
|
|
||||||
const dockerContextPath = getDockerContextPath(application);
|
const dockerContextPath = getDockerContextPath(application);
|
||||||
@@ -51,7 +51,7 @@ export const buildCustomDocker = async (
|
|||||||
as it could be publicly exposed.
|
as it could be publicly exposed.
|
||||||
*/
|
*/
|
||||||
if (!publishDirectory) {
|
if (!publishDirectory) {
|
||||||
createEnvFile(dockerFilePath, env, application.project.env);
|
createEnvFile(dockerFilePath, env, application.environment.project.env);
|
||||||
}
|
}
|
||||||
|
|
||||||
await spawnAsync(
|
await spawnAsync(
|
||||||
@@ -92,7 +92,7 @@ export const getDockerCommand = (
|
|||||||
dockerFilePath.substring(0, dockerFilePath.lastIndexOf("/") + 1) || ".";
|
dockerFilePath.substring(0, dockerFilePath.lastIndexOf("/") + 1) || ".";
|
||||||
const args = prepareEnvironmentVariables(
|
const args = prepareEnvironmentVariables(
|
||||||
buildArgs,
|
buildArgs,
|
||||||
application.project.env,
|
application.environment.project.env,
|
||||||
);
|
);
|
||||||
|
|
||||||
const dockerContextPath =
|
const dockerContextPath =
|
||||||
@@ -121,7 +121,7 @@ export const getDockerCommand = (
|
|||||||
command += createEnvFileCommand(
|
command += createEnvFileCommand(
|
||||||
dockerFilePath,
|
dockerFilePath,
|
||||||
env,
|
env,
|
||||||
application.project.env,
|
application.environment.project.env,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export const buildHeroku = async (
|
|||||||
const buildAppDirectory = getBuildAppDirectory(application);
|
const buildAppDirectory = getBuildAppDirectory(application);
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
env,
|
env,
|
||||||
application.project.env,
|
application.environment.project.env,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const args = [
|
const args = [
|
||||||
@@ -53,7 +53,7 @@ export const getHerokuCommand = (
|
|||||||
const buildAppDirectory = getBuildAppDirectory(application);
|
const buildAppDirectory = getBuildAppDirectory(application);
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
env,
|
env,
|
||||||
application.project.env,
|
application.environment.project.env,
|
||||||
);
|
);
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
|
|||||||
@@ -17,13 +17,22 @@ import { buildNixpacks, getNixpacksCommand } from "./nixpacks";
|
|||||||
import { buildPaketo, getPaketoCommand } from "./paketo";
|
import { buildPaketo, getPaketoCommand } from "./paketo";
|
||||||
import { buildRailpack, getRailpackCommand } from "./railpack";
|
import { buildRailpack, getRailpackCommand } from "./railpack";
|
||||||
import { buildStatic, getStaticCommand } from "./static";
|
import { buildStatic, getStaticCommand } from "./static";
|
||||||
import { findApplicationById } from "@dokploy/server/services/application";
|
|
||||||
|
|
||||||
// NIXPACKS codeDirectory = where is the path of the code directory
|
// NIXPACKS codeDirectory = where is the path of the code directory
|
||||||
// HEROKU 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
|
// PAKETO codeDirectory = where is the path of the code directory
|
||||||
// DOCKERFILE codeDirectory = where is the exact path of the (Dockerfile)
|
// 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 (
|
export const buildApplication = async (
|
||||||
application: ApplicationNested,
|
application: ApplicationNested,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const buildNixpacks = async (
|
|||||||
const buildContainerId = `${appName}-${nanoid(10)}`;
|
const buildContainerId = `${appName}-${nanoid(10)}`;
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
env,
|
env,
|
||||||
application.project.env,
|
application.environment.project.env,
|
||||||
);
|
);
|
||||||
|
|
||||||
const writeToStream = (data: string) => {
|
const writeToStream = (data: string) => {
|
||||||
@@ -101,7 +101,7 @@ export const getNixpacksCommand = (
|
|||||||
const buildContainerId = `${appName}-${nanoid(10)}`;
|
const buildContainerId = `${appName}-${nanoid(10)}`;
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
env,
|
env,
|
||||||
application.project.env,
|
application.environment.project.env,
|
||||||
);
|
);
|
||||||
|
|
||||||
const args = ["build", buildAppDirectory, "--name", appName];
|
const args = ["build", buildAppDirectory, "--name", appName];
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const buildPaketo = async (
|
|||||||
const buildAppDirectory = getBuildAppDirectory(application);
|
const buildAppDirectory = getBuildAppDirectory(application);
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
env,
|
env,
|
||||||
application.project.env,
|
application.environment.project.env,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const args = [
|
const args = [
|
||||||
@@ -52,7 +52,7 @@ export const getPaketoCommand = (
|
|||||||
const buildAppDirectory = getBuildAppDirectory(application);
|
const buildAppDirectory = getBuildAppDirectory(application);
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
env,
|
env,
|
||||||
application.project.env,
|
application.environment.project.env,
|
||||||
);
|
);
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { getRemoteDocker } from "../servers/remote-docker";
|
|||||||
|
|
||||||
export type MariadbNested = InferResultType<
|
export type MariadbNested = InferResultType<
|
||||||
"mariadb",
|
"mariadb",
|
||||||
{ mounts: true; project: true }
|
{ mounts: true; environment: { with: { project: true } } }
|
||||||
>;
|
>;
|
||||||
export const buildMariadb = async (mariadb: MariadbNested) => {
|
export const buildMariadb = async (mariadb: MariadbNested) => {
|
||||||
const {
|
const {
|
||||||
@@ -54,7 +54,7 @@ export const buildMariadb = async (mariadb: MariadbNested) => {
|
|||||||
});
|
});
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
defaultMariadbEnv,
|
defaultMariadbEnv,
|
||||||
mariadb.project.env,
|
mariadb.environment.project.env,
|
||||||
);
|
);
|
||||||
const volumesMount = generateVolumeMounts(mounts);
|
const volumesMount = generateVolumeMounts(mounts);
|
||||||
const bindsMount = generateBindMounts(mounts);
|
const bindsMount = generateBindMounts(mounts);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { getRemoteDocker } from "../servers/remote-docker";
|
|||||||
|
|
||||||
export type MongoNested = InferResultType<
|
export type MongoNested = InferResultType<
|
||||||
"mongo",
|
"mongo",
|
||||||
{ mounts: true; project: true }
|
{ mounts: true; environment: { with: { project: true } } }
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const buildMongo = async (mongo: MongoNested) => {
|
export const buildMongo = async (mongo: MongoNested) => {
|
||||||
@@ -102,7 +102,7 @@ ${command ?? "wait $MONGOD_PID"}`;
|
|||||||
|
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
defaultMongoEnv,
|
defaultMongoEnv,
|
||||||
mongo.project.env,
|
mongo.environment.project.env,
|
||||||
);
|
);
|
||||||
const volumesMount = generateVolumeMounts(mounts);
|
const volumesMount = generateVolumeMounts(mounts);
|
||||||
const bindsMount = generateBindMounts(mounts);
|
const bindsMount = generateBindMounts(mounts);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { getRemoteDocker } from "../servers/remote-docker";
|
|||||||
|
|
||||||
export type MysqlNested = InferResultType<
|
export type MysqlNested = InferResultType<
|
||||||
"mysql",
|
"mysql",
|
||||||
{ mounts: true; project: true }
|
{ mounts: true; environment: { with: { project: true } } }
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const buildMysql = async (mysql: MysqlNested) => {
|
export const buildMysql = async (mysql: MysqlNested) => {
|
||||||
@@ -60,7 +60,7 @@ export const buildMysql = async (mysql: MysqlNested) => {
|
|||||||
});
|
});
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
defaultMysqlEnv,
|
defaultMysqlEnv,
|
||||||
mysql.project.env,
|
mysql.environment.project.env,
|
||||||
);
|
);
|
||||||
const volumesMount = generateVolumeMounts(mounts);
|
const volumesMount = generateVolumeMounts(mounts);
|
||||||
const bindsMount = generateBindMounts(mounts);
|
const bindsMount = generateBindMounts(mounts);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { getRemoteDocker } from "../servers/remote-docker";
|
|||||||
|
|
||||||
export type PostgresNested = InferResultType<
|
export type PostgresNested = InferResultType<
|
||||||
"postgres",
|
"postgres",
|
||||||
{ mounts: true; project: true }
|
{ mounts: true; environment: { with: { project: true } } }
|
||||||
>;
|
>;
|
||||||
export const buildPostgres = async (postgres: PostgresNested) => {
|
export const buildPostgres = async (postgres: PostgresNested) => {
|
||||||
const {
|
const {
|
||||||
@@ -53,7 +53,7 @@ export const buildPostgres = async (postgres: PostgresNested) => {
|
|||||||
});
|
});
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
defaultPostgresEnv,
|
defaultPostgresEnv,
|
||||||
postgres.project.env,
|
postgres.environment.project.env,
|
||||||
);
|
);
|
||||||
const volumesMount = generateVolumeMounts(mounts);
|
const volumesMount = generateVolumeMounts(mounts);
|
||||||
const bindsMount = generateBindMounts(mounts);
|
const bindsMount = generateBindMounts(mounts);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { getRemoteDocker } from "../servers/remote-docker";
|
|||||||
|
|
||||||
export type RedisNested = InferResultType<
|
export type RedisNested = InferResultType<
|
||||||
"redis",
|
"redis",
|
||||||
{ mounts: true; project: true }
|
{ mounts: true; environment: { with: { project: true } } }
|
||||||
>;
|
>;
|
||||||
export const buildRedis = async (redis: RedisNested) => {
|
export const buildRedis = async (redis: RedisNested) => {
|
||||||
const {
|
const {
|
||||||
@@ -51,7 +51,7 @@ export const buildRedis = async (redis: RedisNested) => {
|
|||||||
});
|
});
|
||||||
const envVariables = prepareEnvironmentVariables(
|
const envVariables = prepareEnvironmentVariables(
|
||||||
defaultRedisEnv,
|
defaultRedisEnv,
|
||||||
redis.project.env,
|
redis.environment.project.env,
|
||||||
);
|
);
|
||||||
const volumesMount = generateVolumeMounts(mounts);
|
const volumesMount = generateVolumeMounts(mounts);
|
||||||
const bindsMount = generateBindMounts(mounts);
|
const bindsMount = generateBindMounts(mounts);
|
||||||
|
|||||||
Reference in New Issue
Block a user