refactor: remove save on build on next app and integrate turbopack

This commit is contained in:
Mauricio Siu
2024-10-24 23:13:24 -06:00
parent cb586c9b74
commit 47aa223f87
93 changed files with 810 additions and 303 deletions

View File

@@ -1,5 +1,5 @@
import { IS_CLOUD, paths } from "@/server/constants";
import { updateAdmin } from "@/server/services/admin";
import { IS_CLOUD, paths } from "@dokploy/server/constants";
import { updateAdmin } from "@dokploy/server/services/admin";
import { type RotatingFileStream, createStream } from "rotating-file-stream";
import { db } from "../../db";
import { execAsync } from "../process/execAsync";

View File

@@ -1,5 +1,5 @@
import { findAdmin } from "@/server/services/admin";
import { getAllServers } from "@/server/services/server";
import { findAdmin } from "@dokploy/server/services/admin";
import { getAllServers } from "@dokploy/server/services/server";
import { scheduleJob } from "node-schedule";
import { db } from "../../db/index";
import {

View File

@@ -1,7 +1,7 @@
import path from "node:path";
import type { BackupSchedule } from "@/server/services/backup";
import type { Mariadb } from "@/server/services/mariadb";
import { findProjectById } from "@/server/services/project";
import type { BackupSchedule } from "@dokploy/server/services/backup";
import type { Mariadb } from "@dokploy/server/services/mariadb";
import { findProjectById } from "@dokploy/server/services/project";
import {
getRemoteServiceContainer,
getServiceContainer,

View File

@@ -1,7 +1,7 @@
import path from "node:path";
import type { BackupSchedule } from "@/server/services/backup";
import type { Mongo } from "@/server/services/mongo";
import { findProjectById } from "@/server/services/project";
import type { BackupSchedule } from "@dokploy/server/services/backup";
import type { Mongo } from "@dokploy/server/services/mongo";
import { findProjectById } from "@dokploy/server/services/project";
import {
getRemoteServiceContainer,
getServiceContainer,

View File

@@ -1,8 +1,8 @@
import { unlink } from "node:fs/promises";
import path from "node:path";
import type { BackupSchedule } from "@/server/services/backup";
import type { MySql } from "@/server/services/mysql";
import { findProjectById } from "@/server/services/project";
import type { BackupSchedule } from "@dokploy/server/services/backup";
import type { MySql } from "@dokploy/server/services/mysql";
import { findProjectById } from "@dokploy/server/services/project";
import {
getRemoteServiceContainer,
getServiceContainer,

View File

@@ -1,7 +1,7 @@
import path from "node:path";
import type { BackupSchedule } from "@/server/services/backup";
import type { Postgres } from "@/server/services/postgres";
import { findProjectById } from "@/server/services/project";
import type { BackupSchedule } from "@dokploy/server/services/backup";
import type { Postgres } from "@dokploy/server/services/postgres";
import { findProjectById } from "@dokploy/server/services/project";
import {
getRemoteServiceContainer,
getServiceContainer,

View File

@@ -1,5 +1,5 @@
import type { BackupSchedule } from "@/server/services/backup";
import type { Destination } from "@/server/services/destination";
import type { BackupSchedule } from "@dokploy/server/services/backup";
import type { Destination } from "@dokploy/server/services/destination";
import { scheduleJob, scheduledJobs } from "node-schedule";
import { runMariadbBackup } from "./mariadb";
import { runMongoBackup } from "./mongo";

View File

@@ -5,8 +5,8 @@ import {
writeFileSync,
} from "node:fs";
import { dirname, join } from "node:path";
import { paths } from "@/server/constants";
import type { InferResultType } from "@/server/types/with";
import { paths } from "@dokploy/server/constants";
import type { InferResultType } from "@dokploy/server/types/with";
import boxen from "boxen";
import {
writeDomainsToCompose,

View File

@@ -1,5 +1,5 @@
import type { WriteStream } from "node:fs";
import { prepareEnvironmentVariables } from "@/server/utils/docker/utils";
import { prepareEnvironmentVariables } from "@dokploy/server/utils/docker/utils";
import type { ApplicationNested } from ".";
import {
getBuildAppDirectory,

View File

@@ -1,8 +1,8 @@
import fs from "node:fs/promises";
import path, { join } from "node:path";
import { paths } from "@/server/constants";
import type { Application } from "@/server/services/application";
import { findServerById } from "@/server/services/server";
import { paths } from "@dokploy/server/constants";
import type { Application } from "@dokploy/server/services/application";
import { findServerById } from "@dokploy/server/services/server";
import AdmZip from "adm-zip";
import { Client, type SFTPWrapper } from "ssh2";
import {

View File

@@ -1,5 +1,5 @@
import { createWriteStream } from "node:fs";
import type { InferResultType } from "@/server/types/with";
import type { InferResultType } from "@dokploy/server/types/with";
import type { CreateServiceOptions } from "dockerode";
import { uploadImage } from "../cluster/upload";
import {

View File

@@ -1,6 +1,9 @@
import { type WriteStream, existsSync, mkdirSync } from "node:fs";
import path from "node:path";
import { buildStatic, getStaticCommand } from "@/server/utils/builders/static";
import {
buildStatic,
getStaticCommand,
} from "@dokploy/server/utils/builders/static";
import { nanoid } from "nanoid";
import type { ApplicationNested } from ".";
import { prepareEnvironmentVariables } from "../docker/utils";

View File

@@ -2,7 +2,7 @@ import type { WriteStream } from "node:fs";
import {
buildCustomDocker,
getDockerCommand,
} from "@/server/utils/builders/docker-file";
} from "@dokploy/server/utils/builders/docker-file";
import type { ApplicationNested } from ".";
import { createFile, getCreateFileCommand } from "../docker/utils";
import { getBuildAppDirectory } from "../filesystem/directory";

View File

@@ -1,4 +1,4 @@
import type { InferResultType } from "@/server/types/with";
import type { InferResultType } from "@dokploy/server/types/with";
import type { CreateServiceOptions } from "dockerode";
import {
calculateResources,

View File

@@ -1,4 +1,4 @@
import type { InferResultType } from "@/server/types/with";
import type { InferResultType } from "@dokploy/server/types/with";
import type { CreateServiceOptions } from "dockerode";
import {
calculateResources,

View File

@@ -1,4 +1,4 @@
import type { InferResultType } from "@/server/types/with";
import type { InferResultType } from "@dokploy/server/types/with";
import type { CreateServiceOptions } from "dockerode";
import {
calculateResources,

View File

@@ -1,4 +1,4 @@
import type { InferResultType } from "@/server/types/with";
import type { InferResultType } from "@dokploy/server/types/with";
import type { CreateServiceOptions } from "dockerode";
import {
calculateResources,

View File

@@ -1,4 +1,4 @@
import type { InferResultType } from "@/server/types/with";
import type { InferResultType } from "@dokploy/server/types/with";
import type { CreateServiceOptions } from "dockerode";
import {
calculateResources,

View File

@@ -1,5 +1,5 @@
import crypto from "node:crypto";
import { findComposeById } from "@/server/services/compose";
import { findComposeById } from "@dokploy/server/services/compose";
import { dump, load } from "js-yaml";
import { addSuffixToAllConfigs } from "./compose/configs";
import { addSuffixToAllNetworks } from "./compose/network";

View File

@@ -1,9 +1,9 @@
import fs, { existsSync, readFileSync } from "node:fs";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { paths } from "@/server/constants";
import type { Compose } from "@/server/services/compose";
import type { Domain } from "@/server/services/domain";
import { paths } from "@dokploy/server/constants";
import type { Compose } from "@dokploy/server/services/compose";
import type { Domain } from "@dokploy/server/services/domain";
import { dump, load } from "js-yaml";
import { execAsyncRemote } from "../process/execAsync";
import {

View File

@@ -1,7 +1,7 @@
import fs from "node:fs";
import path from "node:path";
import type { Readable } from "node:stream";
import { docker, paths } from "@/server/constants";
import { docker, paths } from "@dokploy/server/constants";
import type { ContainerInfo, ResourceRequirements } from "dockerode";
import { parse } from "dotenv";
import type { ApplicationNested } from "../builders";

View File

@@ -1,7 +1,7 @@
import fs, { promises as fsPromises } from "node:fs";
import path from "node:path";
import { paths } from "@/server/constants";
import type { Application } from "@/server/services/application";
import { paths } from "@dokploy/server/constants";
import type { Application } from "@dokploy/server/services/application";
import { execAsync, execAsyncRemote } from "../process/execAsync";
export const recreateDirectory = async (pathFolder: string): Promise<void> => {

View File

@@ -1,6 +1,6 @@
import { db } from "@/server/db";
import { notifications } from "@/server/db/schema";
import BuildFailedEmail from "@/server/emails/emails/build-failed";
import { db } from "@dokploy/server/db";
import { notifications } from "@dokploy/server/db/schema";
import BuildFailedEmail from "@dokploy/server/emails/emails/build-failed";
import { renderAsync } from "@react-email/components";
import { eq } from "drizzle-orm";
import {

View File

@@ -1,6 +1,6 @@
import { db } from "@/server/db";
import { notifications } from "@/server/db/schema";
import BuildSuccessEmail from "@/server/emails/emails/build-success";
import { db } from "@dokploy/server/db";
import { notifications } from "@dokploy/server/db/schema";
import BuildSuccessEmail from "@dokploy/server/emails/emails/build-success";
import { renderAsync } from "@react-email/components";
import { eq } from "drizzle-orm";
import {

View File

@@ -1,6 +1,6 @@
import { db } from "@/server/db";
import { notifications } from "@/server/db/schema";
import DatabaseBackupEmail from "@/server/emails/emails/database-backup";
import { db } from "@dokploy/server/db";
import { notifications } from "@dokploy/server/db/schema";
import DatabaseBackupEmail from "@dokploy/server/emails/emails/database-backup";
import { renderAsync } from "@react-email/components";
import { eq } from "drizzle-orm";
import {

View File

@@ -1,6 +1,6 @@
import { db } from "@/server/db";
import { notifications } from "@/server/db/schema";
import DockerCleanupEmail from "@/server/emails/emails/docker-cleanup";
import { db } from "@dokploy/server/db";
import { notifications } from "@dokploy/server/db/schema";
import DockerCleanupEmail from "@dokploy/server/emails/emails/docker-cleanup";
import { renderAsync } from "@react-email/components";
import { eq } from "drizzle-orm";
import {

View File

@@ -1,6 +1,6 @@
import { db } from "@/server/db";
import { notifications } from "@/server/db/schema";
import DokployRestartEmail from "@/server/emails/emails/dokploy-restart";
import { db } from "@dokploy/server/db";
import { notifications } from "@dokploy/server/db/schema";
import DokployRestartEmail from "@dokploy/server/emails/emails/dokploy-restart";
import { renderAsync } from "@react-email/components";
import { eq } from "drizzle-orm";
import {

View File

@@ -1,4 +1,9 @@
import type { discord, email, slack, telegram } from "@/server/db/schema";
import type {
discord,
email,
slack,
telegram,
} from "@dokploy/server/db/schema";
import nodemailer from "nodemailer";
export const sendEmailNotification = async (

View File

@@ -1,6 +1,6 @@
import { exec } from "node:child_process";
import util from "node:util";
import { findServerById } from "@/server/services/server";
import { findServerById } from "@dokploy/server/services/server";
import { Client } from "ssh2";
export const execAsync = util.promisify(exec);

View File

@@ -1,13 +1,13 @@
import { createWriteStream } from "node:fs";
import { join } from "node:path";
import { paths } from "@/server/constants";
import { paths } from "@dokploy/server/constants";
import type {
apiBitbucketTestConnection,
apiFindBitbucketBranches,
} from "@/server/db/schema";
import { findBitbucketById } from "@/server/services/bitbucket";
import type { Compose } from "@/server/services/compose";
import type { InferResultType } from "@/server/types/with";
} from "@dokploy/server/db/schema";
import { findBitbucketById } from "@dokploy/server/services/bitbucket";
import type { Compose } from "@dokploy/server/services/compose";
import type { InferResultType } from "@dokploy/server/types/with";
import { TRPCError } from "@trpc/server";
import { recreateDirectory } from "../filesystem/directory";
import { execAsyncRemote } from "../process/execAsync";

View File

@@ -1,8 +1,11 @@
import { createWriteStream } from "node:fs";
import path, { join } from "node:path";
import { paths } from "@/server/constants";
import type { Compose } from "@/server/services/compose";
import { findSSHKeyById, updateSSHKeyById } from "@/server/services/ssh-key";
import { paths } from "@dokploy/server/constants";
import type { Compose } from "@dokploy/server/services/compose";
import {
findSSHKeyById,
updateSSHKeyById,
} from "@dokploy/server/services/ssh-key";
import { TRPCError } from "@trpc/server";
import { recreateDirectory } from "../filesystem/directory";
import { execAsync, execAsyncRemote } from "../process/execAsync";

View File

@@ -1,16 +1,16 @@
import { createWriteStream } from "node:fs";
import { join } from "node:path";
import { paths } from "@/server/constants";
import type { InferResultType } from "@/server/types/with";
import { paths } from "@dokploy/server/constants";
import type { InferResultType } from "@dokploy/server/types/with";
import { createAppAuth } from "@octokit/auth-app";
import { TRPCError } from "@trpc/server";
import { Octokit } from "octokit";
import { recreateDirectory } from "../filesystem/directory";
import { spawnAsync } from "../process/spawnAsync";
import type { apiFindGithubBranches } from "@/server/db/schema";
import type { Compose } from "@/server/services/compose";
import { type Github, findGithubById } from "@/server/services/github";
import type { apiFindGithubBranches } from "@dokploy/server/db/schema";
import type { Compose } from "@dokploy/server/services/compose";
import { type Github, findGithubById } from "@dokploy/server/services/github";
import { execAsyncRemote } from "../process/execAsync";
export const authGithub = (githubProvider: Github): Octokit => {

View File

@@ -1,14 +1,14 @@
import { createWriteStream } from "node:fs";
import { join } from "node:path";
import { paths } from "@/server/constants";
import type { apiGitlabTestConnection } from "@/server/db/schema";
import type { Compose } from "@/server/services/compose";
import { paths } from "@dokploy/server/constants";
import type { apiGitlabTestConnection } from "@dokploy/server/db/schema";
import type { Compose } from "@dokploy/server/services/compose";
import {
type Gitlab,
findGitlabById,
updateGitlab,
} from "@/server/services/gitlab";
import type { InferResultType } from "@/server/types/with";
} from "@dokploy/server/services/gitlab";
import type { InferResultType } from "@dokploy/server/types/with";
import { TRPCError } from "@trpc/server";
import { recreateDirectory } from "../filesystem/directory";
import { execAsyncRemote } from "../process/execAsync";

View File

@@ -1,8 +1,8 @@
import { createWriteStream } from "node:fs";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { paths } from "@/server/constants";
import type { Compose } from "@/server/services/compose";
import { paths } from "@dokploy/server/constants";
import type { Compose } from "@dokploy/server/services/compose";
import { encodeBase64 } from "../docker/utils";
import { recreateDirectory } from "../filesystem/directory";
import { execAsyncRemote } from "../process/execAsync";

View File

@@ -1,5 +1,5 @@
import { docker } from "@/server/constants";
import { findServerById } from "@/server/services/server";
import { docker } from "@dokploy/server/constants";
import { findServerById } from "@dokploy/server/services/server";
import Dockerode from "dockerode";
export const getRemoteDocker = async (serverId?: string | null) => {

View File

@@ -1,7 +1,7 @@
import fs, { writeFileSync } from "node:fs";
import path from "node:path";
import { paths } from "@/server/constants";
import type { Domain } from "@/server/services/domain";
import { paths } from "@dokploy/server/constants";
import type { Domain } from "@dokploy/server/services/domain";
import { dump, load } from "js-yaml";
import { encodeBase64 } from "../docker/utils";
import { execAsyncRemote } from "../process/execAsync";

View File

@@ -1,4 +1,4 @@
import type { Domain } from "@/server/services/domain";
import type { Domain } from "@dokploy/server/services/domain";
import type { ApplicationNested } from "../builders";
import {
createServiceConfig,

View File

@@ -1,6 +1,6 @@
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { paths } from "@/server/constants";
import { paths } from "@dokploy/server/constants";
import { dump, load } from "js-yaml";
import type { ApplicationNested } from "../builders";
import { execAsyncRemote } from "../process/execAsync";

View File

@@ -1,4 +1,4 @@
import type { Redirect } from "@/server/services/redirect";
import type { Redirect } from "@dokploy/server/services/redirect";
import type { ApplicationNested } from "../builders";
import {
loadOrCreateConfig,

View File

@@ -1,4 +1,4 @@
import type { Security } from "@/server/services/security";
import type { Security } from "@dokploy/server/services/security";
import * as bcrypt from "bcrypt";
import type { ApplicationNested } from "../builders";
import {

View File

@@ -1,7 +1,7 @@
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { paths } from "@/server/constants";
import type { Admin } from "@/server/services/admin";
import { paths } from "@dokploy/server/constants";
import type { Admin } from "@dokploy/server/services/admin";
import { dump, load } from "js-yaml";
import { loadOrCreateConfig, writeTraefikConfig } from "./application";
import type { FileConfig } from "./file-types";