Merge pull request #828 from Dokploy/feat/custom-heroku-version

Feat/custom heroku version
This commit is contained in:
Mauricio Siu
2024-12-07 13:28:58 -06:00
committed by GitHub
9 changed files with 8041 additions and 2 deletions

View File

@@ -41,6 +41,7 @@ const mySchema = z.discriminatedUnion("buildType", [
}), }),
z.object({ z.object({
buildType: z.literal("heroku_buildpacks"), buildType: z.literal("heroku_buildpacks"),
herokuVersion: z.string().nullable().default(""),
}), }),
z.object({ z.object({
buildType: z.literal("paketo_buildpacks"), buildType: z.literal("paketo_buildpacks"),
@@ -90,6 +91,13 @@ export const ShowBuildChooseForm = ({ applicationId }: Props) => {
dockerBuildStage: data.dockerBuildStage || "", dockerBuildStage: data.dockerBuildStage || "",
}), }),
}); });
} else if (data.buildType === "heroku_buildpacks") {
form.reset({
buildType: data.buildType,
...(data.buildType && {
herokuVersion: data.herokuVersion || "",
}),
});
} else { } else {
form.reset({ form.reset({
buildType: data.buildType, buildType: data.buildType,
@@ -110,6 +118,8 @@ export const ShowBuildChooseForm = ({ applicationId }: Props) => {
data.buildType === "dockerfile" ? data.dockerContextPath : null, data.buildType === "dockerfile" ? data.dockerContextPath : null,
dockerBuildStage: dockerBuildStage:
data.buildType === "dockerfile" ? data.dockerBuildStage : null, data.buildType === "dockerfile" ? data.dockerBuildStage : null,
herokuVersion:
data.buildType === "heroku_buildpacks" ? data.herokuVersion : null,
}) })
.then(async () => { .then(async () => {
toast.success("Build type saved"); toast.success("Build type saved");
@@ -200,6 +210,28 @@ export const ShowBuildChooseForm = ({ applicationId }: Props) => {
); );
}} }}
/> />
{buildType === "heroku_buildpacks" && (
<FormField
control={form.control}
name="herokuVersion"
render={({ field }) => {
return (
<FormItem>
<FormLabel>Heroku Version (Optional)</FormLabel>
<FormControl>
<Input
placeholder={"Heroku Version (Default: 24)"}
{...field}
value={field.value ?? ""}
/>
</FormControl>
<FormMessage />
</FormItem>
);
}}
/>
)}
{buildType === "dockerfile" && ( {buildType === "dockerfile" && (
<> <>
<FormField <FormField

View File

@@ -0,0 +1 @@
ALTER TABLE "application" ADD COLUMN "herokuVersion" text;

View File

@@ -0,0 +1 @@
ALTER TABLE "application" ALTER COLUMN "herokuVersion" SET DEFAULT '24';

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -330,6 +330,20 @@
"when": 1732851191048, "when": 1732851191048,
"tag": "0046_purple_sleeper", "tag": "0046_purple_sleeper",
"breakpoints": true "breakpoints": true
},
{
"idx": 47,
"version": "6",
"when": 1733599090582,
"tag": "0047_tidy_revanche",
"breakpoints": true
},
{
"idx": 48,
"version": "6",
"when": 1733599163710,
"tag": "0048_flat_expediter",
"breakpoints": true
} }
] ]
} }

View File

@@ -296,6 +296,7 @@ export const applicationRouter = createTRPCRouter({
publishDirectory: input.publishDirectory, publishDirectory: input.publishDirectory,
dockerContextPath: input.dockerContextPath, dockerContextPath: input.dockerContextPath,
dockerBuildStage: input.dockerBuildStage, dockerBuildStage: input.dockerBuildStage,
herokuVersion: input.herokuVersion,
}); });
return true; return true;

View File

@@ -178,6 +178,7 @@ export const applications = pgTable("application", {
.notNull() .notNull()
.default("idle"), .default("idle"),
buildType: buildType("buildType").notNull().default("nixpacks"), buildType: buildType("buildType").notNull().default("nixpacks"),
herokuVersion: text("herokuVersion").default("24"),
publishDirectory: text("publishDirectory"), publishDirectory: text("publishDirectory"),
createdAt: text("createdAt") createdAt: text("createdAt")
.notNull() .notNull()
@@ -368,6 +369,7 @@ const createSchema = createInsertSchema(applications, {
"nixpacks", "nixpacks",
"static", "static",
]), ]),
herokuVersion: z.string().optional(),
publishDirectory: z.string().optional(), publishDirectory: z.string().optional(),
owner: z.string(), owner: z.string(),
healthCheckSwarm: HealthCheckSwarmSchema.nullable(), healthCheckSwarm: HealthCheckSwarmSchema.nullable(),
@@ -408,6 +410,7 @@ export const apiSaveBuildType = createSchema
dockerfile: true, dockerfile: true,
dockerContextPath: true, dockerContextPath: true,
dockerBuildStage: true, dockerBuildStage: true,
herokuVersion: true,
}) })
.required() .required()
.merge(createSchema.pick({ publishDirectory: true })); .merge(createSchema.pick({ publishDirectory: true }));

View File

@@ -22,7 +22,7 @@ export const buildHeroku = async (
"--path", "--path",
buildAppDirectory, buildAppDirectory,
"--builder", "--builder",
"heroku/builder:24", `heroku/builder:${application.herokuVersion || "24"}`,
]; ];
for (const env of envVariables) { for (const env of envVariables) {
@@ -58,7 +58,7 @@ export const getHerokuCommand = (
"--path", "--path",
buildAppDirectory, buildAppDirectory,
"--builder", "--builder",
"heroku/builder:24", `heroku/builder:${application.herokuVersion || "24"}`,
]; ];
for (const env of envVariables) { for (const env of envVariables) {