mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: update
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
|||||||
removeUserById,
|
removeUserById,
|
||||||
setupWebMonitoring,
|
setupWebMonitoring,
|
||||||
updateAdminById,
|
updateAdminById,
|
||||||
|
updateUser,
|
||||||
} from "@dokploy/server";
|
} from "@dokploy/server";
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
@@ -101,6 +102,9 @@ export const adminRouter = createTRPCRouter({
|
|||||||
message: "You are not allowed to assign permissions",
|
message: "You are not allowed to assign permissions",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
await updateUser(user.id, {
|
||||||
|
...input,
|
||||||
|
});
|
||||||
// await db
|
// await db
|
||||||
// .update(users)
|
// .update(users)
|
||||||
// .set({
|
// .set({
|
||||||
@@ -130,32 +134,33 @@ export const adminRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// await updateAdminById(admin.adminId, {
|
await updateUser(user.id, {
|
||||||
// metricsConfig: {
|
metricsConfig: {
|
||||||
// server: {
|
server: {
|
||||||
// type: "Dokploy",
|
type: "Dokploy",
|
||||||
// refreshRate: input.metricsConfig.server.refreshRate,
|
refreshRate: input.metricsConfig.server.refreshRate,
|
||||||
// port: input.metricsConfig.server.port,
|
port: input.metricsConfig.server.port,
|
||||||
// token: input.metricsConfig.server.token,
|
token: input.metricsConfig.server.token,
|
||||||
// cronJob: input.metricsConfig.server.cronJob,
|
cronJob: input.metricsConfig.server.cronJob,
|
||||||
// urlCallback: input.metricsConfig.server.urlCallback,
|
urlCallback: input.metricsConfig.server.urlCallback,
|
||||||
// retentionDays: input.metricsConfig.server.retentionDays,
|
retentionDays: input.metricsConfig.server.retentionDays,
|
||||||
// thresholds: {
|
thresholds: {
|
||||||
// cpu: input.metricsConfig.server.thresholds.cpu,
|
cpu: input.metricsConfig.server.thresholds.cpu,
|
||||||
// memory: input.metricsConfig.server.thresholds.memory,
|
memory: input.metricsConfig.server.thresholds.memory,
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// containers: {
|
containers: {
|
||||||
// refreshRate: input.metricsConfig.containers.refreshRate,
|
refreshRate: input.metricsConfig.containers.refreshRate,
|
||||||
// services: {
|
services: {
|
||||||
// include: input.metricsConfig.containers.services.include || [],
|
include: input.metricsConfig.containers.services.include || [],
|
||||||
// exclude: input.metricsConfig.containers.services.exclude || [],
|
exclude: input.metricsConfig.containers.services.exclude || [],
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
// const currentServer = await setupWebMonitoring(admin.adminId);
|
|
||||||
// return currentServer;
|
const currentServer = await setupWebMonitoring(user.id);
|
||||||
|
return currentServer;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
|
await checkServiceAccess(ctx.user.id, input.projectId, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_CLOUD && !input.serverId) {
|
if (IS_CLOUD && !input.serverId) {
|
||||||
@@ -81,7 +81,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
const newApplication = await createApplication(input);
|
const newApplication = await createApplication(input);
|
||||||
|
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await addNewService(ctx.user.authId, newApplication.applicationId);
|
await addNewService(ctx.user.id, newApplication.applicationId);
|
||||||
}
|
}
|
||||||
return newApplication;
|
return newApplication;
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
@@ -99,11 +99,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneApplication)
|
.input(apiFindOneApplication)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(
|
await checkServiceAccess(ctx.user.id, input.applicationId, "access");
|
||||||
ctx.user.authId,
|
|
||||||
input.applicationId,
|
|
||||||
"access",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
if (application.project.userId !== ctx.user.ownerId) {
|
if (application.project.userId !== ctx.user.ownerId) {
|
||||||
@@ -145,11 +141,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneApplication)
|
.input(apiFindOneApplication)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(
|
await checkServiceAccess(ctx.user.id, input.applicationId, "delete");
|
||||||
ctx.user.authId,
|
|
||||||
input.applicationId,
|
|
||||||
"delete",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
const application = await findApplicationById(input.applicationId);
|
const application = await findApplicationById(input.applicationId);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
createUser,
|
createUser,
|
||||||
findAuthByEmail,
|
findAuthByEmail,
|
||||||
findAuthById,
|
findAuthById,
|
||||||
|
findUserById,
|
||||||
generate2FASecret,
|
generate2FASecret,
|
||||||
getUserByToken,
|
getUserByToken,
|
||||||
lucia,
|
lucia,
|
||||||
@@ -24,6 +25,7 @@ import {
|
|||||||
sendDiscordNotification,
|
sendDiscordNotification,
|
||||||
sendEmailNotification,
|
sendEmailNotification,
|
||||||
updateAuthById,
|
updateAuthById,
|
||||||
|
updateUser,
|
||||||
validateRequest,
|
validateRequest,
|
||||||
verify2FA,
|
verify2FA,
|
||||||
} from "@dokploy/server";
|
} from "@dokploy/server";
|
||||||
@@ -252,19 +254,18 @@ export const authRouter = createTRPCRouter({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
generateToken: protectedProcedure.mutation(async ({ ctx, input }) => {
|
generateToken: protectedProcedure.mutation(async ({ ctx, input }) => {
|
||||||
const auth = await findAuthById(ctx.user.authId);
|
const auth = await findUserById(ctx.user.id);
|
||||||
|
console.log(auth);
|
||||||
|
|
||||||
if (auth.token) {
|
if (auth.token) {
|
||||||
await luciaToken.invalidateSession(auth.token);
|
await luciaToken.invalidateSession(auth.token);
|
||||||
}
|
}
|
||||||
const session = await luciaToken.createSession(auth?.id || "", {
|
// const session = await luciaToken.createSession(auth?.id || "", {
|
||||||
expiresIn: 60 * 60 * 24 * 30,
|
// expiresIn: 60 * 60 * 24 * 30,
|
||||||
});
|
// });
|
||||||
|
// await updateUser(auth.id, {
|
||||||
await updateAuthById(auth.id, {
|
// token: session.id,
|
||||||
token: session.id,
|
// });
|
||||||
});
|
|
||||||
|
|
||||||
return auth;
|
return auth;
|
||||||
}),
|
}),
|
||||||
verifyToken: protectedProcedure.mutation(async () => {
|
verifyToken: protectedProcedure.mutation(async () => {
|
||||||
@@ -276,7 +277,7 @@ export const authRouter = createTRPCRouter({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
generate2FASecret: protectedProcedure.query(async ({ ctx }) => {
|
generate2FASecret: protectedProcedure.query(async ({ ctx }) => {
|
||||||
return await generate2FASecret(ctx.user.authId);
|
return await generate2FASecret(ctx.user.id);
|
||||||
}),
|
}),
|
||||||
verify2FASetup: protectedProcedure
|
verify2FASetup: protectedProcedure
|
||||||
.input(apiVerify2FA)
|
.input(apiVerify2FA)
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import {
|
|||||||
findDomainsByComposeId,
|
findDomainsByComposeId,
|
||||||
findProjectById,
|
findProjectById,
|
||||||
findServerById,
|
findServerById,
|
||||||
|
findUserById,
|
||||||
loadServices,
|
loadServices,
|
||||||
randomizeComposeFile,
|
randomizeComposeFile,
|
||||||
randomizeIsolatedDeploymentComposeFile,
|
randomizeIsolatedDeploymentComposeFile,
|
||||||
@@ -61,7 +62,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ ctx, input }) => {
|
.mutation(async ({ ctx, input }) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
|
await checkServiceAccess(ctx.user.id, input.projectId, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_CLOUD && !input.serverId) {
|
if (IS_CLOUD && !input.serverId) {
|
||||||
@@ -80,7 +81,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
const newService = await createCompose(input);
|
const newService = await createCompose(input);
|
||||||
|
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await addNewService(ctx.user.authId, newService.composeId);
|
await addNewService(ctx.user.id, newService.composeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newService;
|
return newService;
|
||||||
@@ -93,7 +94,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiFindCompose)
|
.input(apiFindCompose)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.composeId, "access");
|
await checkServiceAccess(ctx.user.id, input.composeId, "access");
|
||||||
}
|
}
|
||||||
|
|
||||||
const compose = await findComposeById(input.composeId);
|
const compose = await findComposeById(input.composeId);
|
||||||
@@ -122,7 +123,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiDeleteCompose)
|
.input(apiDeleteCompose)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.composeId, "delete");
|
await checkServiceAccess(ctx.user.id, input.composeId, "delete");
|
||||||
}
|
}
|
||||||
const composeResult = await findComposeById(input.composeId);
|
const composeResult = await findComposeById(input.composeId);
|
||||||
|
|
||||||
@@ -376,7 +377,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
.input(apiCreateComposeByTemplate)
|
.input(apiCreateComposeByTemplate)
|
||||||
.mutation(async ({ ctx, input }) => {
|
.mutation(async ({ ctx, input }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
|
await checkServiceAccess(ctx.user.id, input.projectId, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_CLOUD && !input.serverId) {
|
if (IS_CLOUD && !input.serverId) {
|
||||||
@@ -390,7 +391,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
|
|
||||||
const generate = await loadTemplateModule(input.id as TemplatesKeys);
|
const generate = await loadTemplateModule(input.id as TemplatesKeys);
|
||||||
|
|
||||||
const admin = await findAdminById(ctx.user.adminId);
|
const admin = await findUserById(ctx.user.ownerId);
|
||||||
let serverIp = admin.serverIp || "127.0.0.1";
|
let serverIp = admin.serverIp || "127.0.0.1";
|
||||||
|
|
||||||
const project = await findProjectById(input.projectId);
|
const project = await findProjectById(input.projectId);
|
||||||
@@ -419,7 +420,7 @@ export const composeRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await addNewService(ctx.user.authId, compose.composeId);
|
await addNewService(ctx.user.id, compose.composeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mounts && mounts?.length > 0) {
|
if (mounts && mounts?.length > 0) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
|
await checkServiceAccess(ctx.user.id, input.projectId, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_CLOUD && !input.serverId) {
|
if (IS_CLOUD && !input.serverId) {
|
||||||
@@ -57,7 +57,7 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
const newMariadb = await createMariadb(input);
|
const newMariadb = await createMariadb(input);
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await addNewService(ctx.user.authId, newMariadb.mariadbId);
|
await addNewService(ctx.user.id, newMariadb.mariadbId);
|
||||||
}
|
}
|
||||||
|
|
||||||
await createMount({
|
await createMount({
|
||||||
@@ -80,7 +80,7 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneMariaDB)
|
.input(apiFindOneMariaDB)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.mariadbId, "access");
|
await checkServiceAccess(ctx.user.id, input.mariadbId, "access");
|
||||||
}
|
}
|
||||||
const mariadb = await findMariadbById(input.mariadbId);
|
const mariadb = await findMariadbById(input.mariadbId);
|
||||||
if (mariadb.project.userId !== ctx.user.ownerId) {
|
if (mariadb.project.userId !== ctx.user.ownerId) {
|
||||||
@@ -202,7 +202,7 @@ export const mariadbRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneMariaDB)
|
.input(apiFindOneMariaDB)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.mariadbId, "delete");
|
await checkServiceAccess(ctx.user.id, input.mariadbId, "delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
const mongo = await findMariadbById(input.mariadbId);
|
const mongo = await findMariadbById(input.mariadbId);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
|
await checkServiceAccess(ctx.user.id, input.projectId, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_CLOUD && !input.serverId) {
|
if (IS_CLOUD && !input.serverId) {
|
||||||
@@ -56,7 +56,7 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
const newMongo = await createMongo(input);
|
const newMongo = await createMongo(input);
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await addNewService(ctx.user.authId, newMongo.mongoId);
|
await addNewService(ctx.user.id, newMongo.mongoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
await createMount({
|
await createMount({
|
||||||
@@ -83,7 +83,7 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneMongo)
|
.input(apiFindOneMongo)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.mongoId, "access");
|
await checkServiceAccess(ctx.user.id, input.mongoId, "access");
|
||||||
}
|
}
|
||||||
|
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
@@ -243,7 +243,7 @@ export const mongoRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneMongo)
|
.input(apiFindOneMongo)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.mongoId, "delete");
|
await checkServiceAccess(ctx.user.id, input.mongoId, "delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
const mongo = await findMongoById(input.mongoId);
|
const mongo = await findMongoById(input.mongoId);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
|
await checkServiceAccess(ctx.user.id, input.projectId, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_CLOUD && !input.serverId) {
|
if (IS_CLOUD && !input.serverId) {
|
||||||
@@ -59,7 +59,7 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
|
|
||||||
const newMysql = await createMysql(input);
|
const newMysql = await createMysql(input);
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await addNewService(ctx.user.authId, newMysql.mysqlId);
|
await addNewService(ctx.user.id, newMysql.mysqlId);
|
||||||
}
|
}
|
||||||
|
|
||||||
await createMount({
|
await createMount({
|
||||||
@@ -86,7 +86,7 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneMySql)
|
.input(apiFindOneMySql)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.mysqlId, "access");
|
await checkServiceAccess(ctx.user.id, input.mysqlId, "access");
|
||||||
}
|
}
|
||||||
const mysql = await findMySqlById(input.mysqlId);
|
const mysql = await findMySqlById(input.mysqlId);
|
||||||
if (mysql.project.userId !== ctx.user.ownerId) {
|
if (mysql.project.userId !== ctx.user.ownerId) {
|
||||||
@@ -241,7 +241,7 @@ export const mysqlRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneMySql)
|
.input(apiFindOneMySql)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.mysqlId, "delete");
|
await checkServiceAccess(ctx.user.id, input.mysqlId, "delete");
|
||||||
}
|
}
|
||||||
const mongo = await findMySqlById(input.mysqlId);
|
const mongo = await findMySqlById(input.mysqlId);
|
||||||
if (mongo.project.userId !== ctx.user.ownerId) {
|
if (mongo.project.userId !== ctx.user.ownerId) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
|
await checkServiceAccess(ctx.user.id, input.projectId, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_CLOUD && !input.serverId) {
|
if (IS_CLOUD && !input.serverId) {
|
||||||
@@ -64,7 +64,7 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
const newPostgres = await createPostgres(input);
|
const newPostgres = await createPostgres(input);
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await addNewService(ctx.user.authId, newPostgres.postgresId);
|
await addNewService(ctx.user.id, newPostgres.postgresId);
|
||||||
}
|
}
|
||||||
|
|
||||||
await createMount({
|
await createMount({
|
||||||
@@ -91,7 +91,7 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.input(apiFindOnePostgres)
|
.input(apiFindOnePostgres)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.postgresId, "access");
|
await checkServiceAccess(ctx.user.id, input.postgresId, "access");
|
||||||
}
|
}
|
||||||
|
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
@@ -222,7 +222,7 @@ export const postgresRouter = createTRPCRouter({
|
|||||||
.input(apiFindOnePostgres)
|
.input(apiFindOnePostgres)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.postgresId, "delete");
|
await checkServiceAccess(ctx.user.id, input.postgresId, "delete");
|
||||||
}
|
}
|
||||||
const postgres = await findPostgresById(input.postgresId);
|
const postgres = await findPostgresById(input.postgresId);
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ import {
|
|||||||
checkProjectAccess,
|
checkProjectAccess,
|
||||||
createProject,
|
createProject,
|
||||||
deleteProject,
|
deleteProject,
|
||||||
findAdminById,
|
|
||||||
findProjectById,
|
findProjectById,
|
||||||
findUserByAuthId,
|
findUserByAuthId,
|
||||||
|
findUserById,
|
||||||
updateProjectById,
|
updateProjectById,
|
||||||
} from "@dokploy/server";
|
} from "@dokploy/server";
|
||||||
|
|
||||||
@@ -37,10 +37,10 @@ export const projectRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ ctx, input }) => {
|
.mutation(async ({ ctx, input }) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkProjectAccess(ctx.user.authId, "create");
|
await checkProjectAccess(ctx.user.id, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
const admin = await findAdminById(ctx.user.adminId);
|
const admin = await findUserById(ctx.user.ownerId);
|
||||||
|
|
||||||
if (admin.serversQuantity === 0 && IS_CLOUD) {
|
if (admin.serversQuantity === 0 && IS_CLOUD) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
@@ -49,9 +49,9 @@ export const projectRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const project = await createProject(input, ctx.user.adminId);
|
const project = await createProject(input, ctx.user.ownerId);
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await addNewProject(ctx.user.authId, project.projectId);
|
await addNewProject(ctx.user.id, project.projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
@@ -68,9 +68,9 @@ export const projectRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneProject)
|
.input(apiFindOneProject)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
const { accessedServices } = await findUserByAuthId(ctx.user.authId);
|
const { accessedServices } = await findUserByAuthId(ctx.user.id);
|
||||||
|
|
||||||
await checkProjectAccess(ctx.user.authId, "access", input.projectId);
|
await checkProjectAccess(ctx.user.id, "access", input.projectId);
|
||||||
|
|
||||||
const project = await db.query.projects.findFirst({
|
const project = await db.query.projects.findFirst({
|
||||||
where: and(
|
where: and(
|
||||||
@@ -126,7 +126,7 @@ export const projectRouter = createTRPCRouter({
|
|||||||
all: protectedProcedure.query(async ({ ctx }) => {
|
all: protectedProcedure.query(async ({ ctx }) => {
|
||||||
// console.log(ctx.user);
|
// console.log(ctx.user);
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
const { accessedProjects, accessedServices } = await findUserByAuthId(
|
const { accessedProjects, accessedServices } = await findUserById(
|
||||||
ctx.user.id,
|
ctx.user.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ export const projectRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkProjectAccess(ctx.user.authId, "delete");
|
await checkProjectAccess(ctx.user.id, "delete");
|
||||||
}
|
}
|
||||||
const currentProject = await findProjectById(input.projectId);
|
const currentProject = await findProjectById(input.projectId);
|
||||||
if (currentProject.userId !== ctx.user.ownerId) {
|
if (currentProject.userId !== ctx.user.ownerId) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
|
await checkServiceAccess(ctx.user.id, input.projectId, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_CLOUD && !input.serverId) {
|
if (IS_CLOUD && !input.serverId) {
|
||||||
@@ -56,7 +56,7 @@ export const redisRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
const newRedis = await createRedis(input);
|
const newRedis = await createRedis(input);
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await addNewService(ctx.user.authId, newRedis.redisId);
|
await addNewService(ctx.user.id, newRedis.redisId);
|
||||||
}
|
}
|
||||||
|
|
||||||
await createMount({
|
await createMount({
|
||||||
@@ -76,7 +76,7 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneRedis)
|
.input(apiFindOneRedis)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.redisId, "access");
|
await checkServiceAccess(ctx.user.id, input.redisId, "access");
|
||||||
}
|
}
|
||||||
|
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
@@ -233,7 +233,7 @@ export const redisRouter = createTRPCRouter({
|
|||||||
.input(apiFindOneRedis)
|
.input(apiFindOneRedis)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
if (ctx.user.rol === "user") {
|
if (ctx.user.rol === "user") {
|
||||||
await checkServiceAccess(ctx.user.authId, input.redisId, "delete");
|
await checkServiceAccess(ctx.user.id, input.redisId, "delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
const redis = await findRedisById(input.redisId);
|
const redis = await findRedisById(input.redisId);
|
||||||
|
|||||||
@@ -120,8 +120,7 @@ export const stripeRouter = createTRPCRouter({
|
|||||||
|
|
||||||
canCreateMoreServers: adminProcedure.query(async ({ ctx }) => {
|
canCreateMoreServers: adminProcedure.query(async ({ ctx }) => {
|
||||||
const user = await findUserById(ctx.user.ownerId);
|
const user = await findUserById(ctx.user.ownerId);
|
||||||
console.log(user);
|
const servers = await findServersByUserId(user.id);
|
||||||
// const servers = await findServersByUserId(user.id);
|
|
||||||
|
|
||||||
if (!IS_CLOUD) {
|
if (!IS_CLOUD) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import { relations } from "drizzle-orm";
|
||||||
import { boolean, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
import { boolean, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
import { users_temp } from "./user";
|
import { users_temp } from "./user";
|
||||||
import { relations } from "drizzle-orm";
|
|
||||||
|
|
||||||
export const account = pgTable("account", {
|
export const account = pgTable("account", {
|
||||||
id: text("id")
|
id: text("id")
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { z } from "zod";
|
|||||||
import { admins } from "./admin";
|
import { admins } from "./admin";
|
||||||
import { auth } from "./auth";
|
import { auth } from "./auth";
|
||||||
import { certificateType } from "./shared";
|
import { certificateType } from "./shared";
|
||||||
|
import { account } from "./account";
|
||||||
/**
|
/**
|
||||||
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
|
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
|
||||||
* database instance for multiple projects.
|
* database instance for multiple projects.
|
||||||
@@ -185,10 +186,14 @@ export const users_temp = pgTable("user_temp", {
|
|||||||
serversQuantity: integer("serversQuantity").notNull().default(0),
|
serversQuantity: integer("serversQuantity").notNull().default(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const usersRelations = relations(users, ({ one }) => ({
|
export const usersRelations = relations(users_temp, ({ one }) => ({
|
||||||
auth: one(auth, {
|
// auth: one(auth, {
|
||||||
fields: [users.authId],
|
// fields: [users.authId],
|
||||||
references: [auth.id],
|
// references: [auth.id],
|
||||||
|
// }),
|
||||||
|
account: one(account, {
|
||||||
|
fields: [users_temp.id],
|
||||||
|
references: [account.userId],
|
||||||
}),
|
}),
|
||||||
// admin: one(admins, {
|
// admin: one(admins, {
|
||||||
// fields: [users.adminId],
|
// fields: [users.adminId],
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ export const createInvitation = async (
|
|||||||
export const findUserById = async (userId: string) => {
|
export const findUserById = async (userId: string) => {
|
||||||
const user = await db.query.users_temp.findFirst({
|
const user = await db.query.users_temp.findFirst({
|
||||||
where: eq(users_temp.id, userId),
|
where: eq(users_temp.id, userId),
|
||||||
|
// with: {
|
||||||
|
// account: true,
|
||||||
|
// },
|
||||||
});
|
});
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import encode from "hi-base32";
|
|||||||
import { TOTP } from "otpauth";
|
import { TOTP } from "otpauth";
|
||||||
import QRCode from "qrcode";
|
import QRCode from "qrcode";
|
||||||
import { IS_CLOUD } from "../constants";
|
import { IS_CLOUD } from "../constants";
|
||||||
|
import { findUserById } from "./admin";
|
||||||
|
|
||||||
export type Auth = typeof auth.$inferSelect;
|
export type Auth = typeof auth.$inferSelect;
|
||||||
|
|
||||||
@@ -131,14 +132,14 @@ export const updateAuthById = async (
|
|||||||
return result[0];
|
return result[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const generate2FASecret = async (authId: string) => {
|
export const generate2FASecret = async (userId: string) => {
|
||||||
const auth = await findAuthById(authId);
|
const user = await findUserById(userId);
|
||||||
|
|
||||||
const base32_secret = generateBase32Secret();
|
const base32_secret = generateBase32Secret();
|
||||||
|
|
||||||
const totp = new TOTP({
|
const totp = new TOTP({
|
||||||
issuer: "Dokploy",
|
issuer: "Dokploy",
|
||||||
label: `${auth?.email}`,
|
label: `${user?.email}`,
|
||||||
algorithm: "SHA1",
|
algorithm: "SHA1",
|
||||||
digits: 6,
|
digits: 6,
|
||||||
secret: base32_secret,
|
secret: base32_secret,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export const createServer = async (
|
|||||||
.values({
|
.values({
|
||||||
...input,
|
...input,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
})
|
})
|
||||||
.returning()
|
.returning()
|
||||||
.then((value) => value[0]);
|
.then((value) => value[0]);
|
||||||
|
|||||||
@@ -2,21 +2,22 @@ import { db } from "@dokploy/server/db";
|
|||||||
import type { users_temp } from "@dokploy/server/db/schema";
|
import type { users_temp } from "@dokploy/server/db/schema";
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
|
import { findUserById } from "./admin";
|
||||||
|
|
||||||
export type User = typeof users_temp.$inferSelect;
|
export type User = typeof users_temp.$inferSelect;
|
||||||
|
|
||||||
export const findUserById = async (userId: string) => {
|
// export const findUserById = async (userId: string) => {
|
||||||
const userR = await db.query.user.findFirst({
|
// // const userR = await db.query.user.findFirst({
|
||||||
where: eq(user.userId, userId),
|
// // where: eq(user.userId, userId),
|
||||||
});
|
// // });
|
||||||
if (!userR) {
|
// // if (!userR) {
|
||||||
throw new TRPCError({
|
// // throw new TRPCError({
|
||||||
code: "NOT_FOUND",
|
// // code: "NOT_FOUND",
|
||||||
message: "User not found",
|
// // message: "User not found",
|
||||||
});
|
// // });
|
||||||
}
|
// // }
|
||||||
return user;
|
// // return user;
|
||||||
};
|
// };
|
||||||
|
|
||||||
export const findUserByAuthId = async (authId: string) => {
|
export const findUserByAuthId = async (authId: string) => {
|
||||||
const userR = await db.query.user.findFirst({
|
const userR = await db.query.user.findFirst({
|
||||||
@@ -46,33 +47,32 @@ export const findUsers = async (adminId: string) => {
|
|||||||
return currentUsers;
|
return currentUsers;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addNewProject = async (authId: string, projectId: string) => {
|
export const addNewProject = async (userId: string, projectId: string) => {
|
||||||
const userR = await findUserByAuthId(authId);
|
const userR = await findUserById(userId);
|
||||||
|
|
||||||
await db
|
// await db
|
||||||
.update(user)
|
// .update(user)
|
||||||
.set({
|
// .set({
|
||||||
accessedProjects: [...userR.accessedProjects, projectId],
|
// accessedProjects: [...userR.accessedProjects, projectId],
|
||||||
})
|
// })
|
||||||
.where(eq(user.authId, authId));
|
// .where(eq(user.authId, authId));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addNewService = async (authId: string, serviceId: string) => {
|
export const addNewService = async (userId: string, serviceId: string) => {
|
||||||
const userR = await findUserByAuthId(authId);
|
const userR = await findUserById(userId);
|
||||||
await db
|
// await db
|
||||||
.update(user)
|
// .update(user)
|
||||||
.set({
|
// .set({
|
||||||
accessedServices: [...userR.accessedServices, serviceId],
|
// accessedServices: [...userR.accessedServices, serviceId],
|
||||||
})
|
// })
|
||||||
.where(eq(user.authId, authId));
|
// .where(eq(user.userId, userId));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const canPerformCreationService = async (
|
export const canPerformCreationService = async (
|
||||||
userId: string,
|
userId: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
) => {
|
) => {
|
||||||
const { accessedProjects, canCreateServices } =
|
const { accessedProjects, canCreateServices } = await findUserById(userId);
|
||||||
await findUserByAuthId(userId);
|
|
||||||
const haveAccessToProject = accessedProjects.includes(projectId);
|
const haveAccessToProject = accessedProjects.includes(projectId);
|
||||||
|
|
||||||
if (canCreateServices && haveAccessToProject) {
|
if (canCreateServices && haveAccessToProject) {
|
||||||
@@ -86,7 +86,7 @@ export const canPerformAccessService = async (
|
|||||||
userId: string,
|
userId: string,
|
||||||
serviceId: string,
|
serviceId: string,
|
||||||
) => {
|
) => {
|
||||||
const { accessedServices } = await findUserByAuthId(userId);
|
const { accessedServices } = await findUserById(userId);
|
||||||
const haveAccessToService = accessedServices.includes(serviceId);
|
const haveAccessToService = accessedServices.includes(serviceId);
|
||||||
|
|
||||||
if (haveAccessToService) {
|
if (haveAccessToService) {
|
||||||
@@ -97,11 +97,10 @@ export const canPerformAccessService = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const canPeformDeleteService = async (
|
export const canPeformDeleteService = async (
|
||||||
authId: string,
|
userId: string,
|
||||||
serviceId: string,
|
serviceId: string,
|
||||||
) => {
|
) => {
|
||||||
const { accessedServices, canDeleteServices } =
|
const { accessedServices, canDeleteServices } = await findUserById(userId);
|
||||||
await findUserByAuthId(authId);
|
|
||||||
const haveAccessToService = accessedServices.includes(serviceId);
|
const haveAccessToService = accessedServices.includes(serviceId);
|
||||||
|
|
||||||
if (canDeleteServices && haveAccessToService) {
|
if (canDeleteServices && haveAccessToService) {
|
||||||
@@ -111,8 +110,8 @@ export const canPeformDeleteService = async (
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const canPerformCreationProject = async (authId: string) => {
|
export const canPerformCreationProject = async (userId: string) => {
|
||||||
const { canCreateProjects } = await findUserByAuthId(authId);
|
const { canCreateProjects } = await findUserById(userId);
|
||||||
|
|
||||||
if (canCreateProjects) {
|
if (canCreateProjects) {
|
||||||
return true;
|
return true;
|
||||||
@@ -121,8 +120,8 @@ export const canPerformCreationProject = async (authId: string) => {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const canPerformDeleteProject = async (authId: string) => {
|
export const canPerformDeleteProject = async (userId: string) => {
|
||||||
const { canDeleteProjects } = await findUserByAuthId(authId);
|
const { canDeleteProjects } = await findUserById(userId);
|
||||||
|
|
||||||
if (canDeleteProjects) {
|
if (canDeleteProjects) {
|
||||||
return true;
|
return true;
|
||||||
@@ -132,10 +131,10 @@ export const canPerformDeleteProject = async (authId: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const canPerformAccessProject = async (
|
export const canPerformAccessProject = async (
|
||||||
authId: string,
|
userId: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
) => {
|
) => {
|
||||||
const { accessedProjects } = await findUserByAuthId(authId);
|
const { accessedProjects } = await findUserById(userId);
|
||||||
|
|
||||||
const haveAccessToProject = accessedProjects.includes(projectId);
|
const haveAccessToProject = accessedProjects.includes(projectId);
|
||||||
|
|
||||||
@@ -145,26 +144,26 @@ export const canPerformAccessProject = async (
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const canAccessToTraefikFiles = async (authId: string) => {
|
export const canAccessToTraefikFiles = async (userId: string) => {
|
||||||
const { canAccessToTraefikFiles } = await findUserByAuthId(authId);
|
const { canAccessToTraefikFiles } = await findUserById(userId);
|
||||||
return canAccessToTraefikFiles;
|
return canAccessToTraefikFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const checkServiceAccess = async (
|
export const checkServiceAccess = async (
|
||||||
authId: string,
|
userId: string,
|
||||||
serviceId: string,
|
serviceId: string,
|
||||||
action = "access" as "access" | "create" | "delete",
|
action = "access" as "access" | "create" | "delete",
|
||||||
) => {
|
) => {
|
||||||
let hasPermission = false;
|
let hasPermission = false;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "create":
|
case "create":
|
||||||
hasPermission = await canPerformCreationService(authId, serviceId);
|
hasPermission = await canPerformCreationService(userId, serviceId);
|
||||||
break;
|
break;
|
||||||
case "access":
|
case "access":
|
||||||
hasPermission = await canPerformAccessService(authId, serviceId);
|
hasPermission = await canPerformAccessService(userId, serviceId);
|
||||||
break;
|
break;
|
||||||
case "delete":
|
case "delete":
|
||||||
hasPermission = await canPeformDeleteService(authId, serviceId);
|
hasPermission = await canPeformDeleteService(userId, serviceId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
hasPermission = false;
|
hasPermission = false;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { findServerById } from "@dokploy/server/services/server";
|
import { findServerById } from "@dokploy/server/services/server";
|
||||||
import type { ContainerCreateOptions } from "dockerode";
|
import type { ContainerCreateOptions } from "dockerode";
|
||||||
import { IS_CLOUD } from "../constants";
|
import { IS_CLOUD } from "../constants";
|
||||||
import { findAdminById } from "../services/admin";
|
import { findAdminById, findUserById } from "../services/admin";
|
||||||
import { getDokployImageTag } from "../services/settings";
|
import { getDokployImageTag } from "../services/settings";
|
||||||
import { pullImage, pullRemoteImage } from "../utils/docker/utils";
|
import { pullImage, pullRemoteImage } from "../utils/docker/utils";
|
||||||
import { execAsync, execAsyncRemote } from "../utils/process/execAsync";
|
import { execAsync, execAsyncRemote } from "../utils/process/execAsync";
|
||||||
@@ -80,8 +80,8 @@ export const setupMonitoring = async (serverId: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setupWebMonitoring = async (adminId: string) => {
|
export const setupWebMonitoring = async (userId: string) => {
|
||||||
const admin = await findAdminById(adminId);
|
const user = await findUserById(userId);
|
||||||
|
|
||||||
const containerName = "dokploy-monitoring";
|
const containerName = "dokploy-monitoring";
|
||||||
let imageName = "dokploy/monitoring:latest";
|
let imageName = "dokploy/monitoring:latest";
|
||||||
@@ -96,7 +96,7 @@ export const setupWebMonitoring = async (adminId: string) => {
|
|||||||
|
|
||||||
const settings: ContainerCreateOptions = {
|
const settings: ContainerCreateOptions = {
|
||||||
name: containerName,
|
name: containerName,
|
||||||
Env: [`METRICS_CONFIG=${JSON.stringify(admin?.metricsConfig)}`],
|
Env: [`METRICS_CONFIG=${JSON.stringify(user?.metricsConfig)}`],
|
||||||
Image: imageName,
|
Image: imageName,
|
||||||
HostConfig: {
|
HostConfig: {
|
||||||
// Memory: 100 * 1024 * 1024, // 100MB en bytes
|
// Memory: 100 * 1024 * 1024, // 100MB en bytes
|
||||||
@@ -104,9 +104,9 @@ export const setupWebMonitoring = async (adminId: string) => {
|
|||||||
// CapAdd: ["NET_ADMIN", "SYS_ADMIN"],
|
// CapAdd: ["NET_ADMIN", "SYS_ADMIN"],
|
||||||
// Privileged: true,
|
// Privileged: true,
|
||||||
PortBindings: {
|
PortBindings: {
|
||||||
[`${admin.metricsConfig.server.port}/tcp`]: [
|
[`${user?.metricsConfig?.server?.port}/tcp`]: [
|
||||||
{
|
{
|
||||||
HostPort: admin.metricsConfig.server.port.toString(),
|
HostPort: user?.metricsConfig?.server?.port.toString(),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -120,7 +120,7 @@ export const setupWebMonitoring = async (adminId: string) => {
|
|||||||
// NetworkMode: "host",
|
// NetworkMode: "host",
|
||||||
},
|
},
|
||||||
ExposedPorts: {
|
ExposedPorts: {
|
||||||
[`${admin.metricsConfig.server.port}/tcp`]: {},
|
[`${user?.metricsConfig?.server?.port}/tcp`]: {},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const docker = await getRemoteDocker();
|
const docker = await getRemoteDocker();
|
||||||
|
|||||||
Reference in New Issue
Block a user