mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-28 06:28:47 +00:00
@@ -0,0 +1,209 @@
|
|||||||
|
import type { Registry } from "@dokploy/server";
|
||||||
|
import { getRegistryTag } from "@dokploy/server";
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
describe("getRegistryTag", () => {
|
||||||
|
// Helper to create a mock registry
|
||||||
|
const createMockRegistry = (overrides: Partial<Registry> = {}): Registry => {
|
||||||
|
return {
|
||||||
|
registryId: "test-registry-id",
|
||||||
|
registryName: "Test Registry",
|
||||||
|
username: "myuser",
|
||||||
|
password: "test-password",
|
||||||
|
registryUrl: "docker.io",
|
||||||
|
registryType: "cloud",
|
||||||
|
imagePrefix: null,
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
organizationId: "test-org-id",
|
||||||
|
...overrides,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("with username (no imagePrefix)", () => {
|
||||||
|
it("should handle simple image name without tag", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "nginx");
|
||||||
|
expect(result).toBe("docker.io/myuser/nginx");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle image name with tag", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "nginx:latest");
|
||||||
|
expect(result).toBe("docker.io/myuser/nginx:latest");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle image name with username already present (no duplication)", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "myuser/myprivaterepo");
|
||||||
|
// Should not duplicate username
|
||||||
|
expect(result).toBe("docker.io/myuser/myprivaterepo");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle image name with username and tag already present", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "myuser/myprivaterepo:latest");
|
||||||
|
// Should not duplicate username
|
||||||
|
expect(result).toBe("docker.io/myuser/myprivaterepo:latest");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle complex image name with username", () => {
|
||||||
|
const registry = createMockRegistry({ username: "siumauricio" });
|
||||||
|
const result = getRegistryTag(
|
||||||
|
registry,
|
||||||
|
"siumauricio/app-parse-multi-byte-port-e32uh7",
|
||||||
|
);
|
||||||
|
// Should not duplicate username
|
||||||
|
expect(result).toBe(
|
||||||
|
"docker.io/siumauricio/app-parse-multi-byte-port-e32uh7",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle image name with different username (should not duplicate)", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "otheruser/myprivaterepo");
|
||||||
|
expect(result).toBe("docker.io/myuser/myprivaterepo");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle image name with full registry URL (no username)", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "docker.io/nginx");
|
||||||
|
// Should add username since imageName doesn't have one
|
||||||
|
expect(result).toBe("docker.io/myuser/nginx");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle image name with custom registry URL and username", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "ghcr.io/myuser/repo");
|
||||||
|
// Should not duplicate username even if registry URL is different
|
||||||
|
expect(result).toBe("docker.io/myuser/repo");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle image name with custom registry URL (different username)", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "ghcr.io/otheruser/repo");
|
||||||
|
// Should use registry username, not the one in imageName
|
||||||
|
expect(result).toBe("docker.io/myuser/repo");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("with imagePrefix", () => {
|
||||||
|
it("should use imagePrefix instead of username", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
imagePrefix: "myorg",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "nginx");
|
||||||
|
expect(result).toBe("docker.io/myorg/nginx");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should use imagePrefix with image tag", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
imagePrefix: "myorg",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "nginx:latest");
|
||||||
|
expect(result).toBe("docker.io/myorg/nginx:latest");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle imagePrefix with username already in image name", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
imagePrefix: "myorg",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "myuser/myprivaterepo");
|
||||||
|
expect(result).toBe("docker.io/myorg/myprivaterepo");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle imagePrefix matching image name prefix", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
imagePrefix: "myorg",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "myorg/myprivaterepo");
|
||||||
|
// Should not duplicate prefix
|
||||||
|
expect(result).toBe("docker.io/myorg/myprivaterepo");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("without registryUrl", () => {
|
||||||
|
it("should work without registryUrl", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
registryUrl: "",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "nginx");
|
||||||
|
expect(result).toBe("myuser/nginx");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should work without registryUrl with imagePrefix", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
imagePrefix: "myorg",
|
||||||
|
registryUrl: "",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "nginx");
|
||||||
|
expect(result).toBe("myorg/nginx");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle username already present without registryUrl", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
registryUrl: "",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "myuser/myprivaterepo");
|
||||||
|
// Should not duplicate username
|
||||||
|
expect(result).toBe("myuser/myprivaterepo");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("with custom registryUrl", () => {
|
||||||
|
it("should handle custom registry URL", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
registryUrl: "ghcr.io",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "nginx");
|
||||||
|
expect(result).toBe("ghcr.io/myuser/nginx");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle custom registry URL with imagePrefix", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
imagePrefix: "myorg",
|
||||||
|
registryUrl: "ghcr.io",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "nginx");
|
||||||
|
expect(result).toBe("ghcr.io/myorg/nginx");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle custom registry URL with username already present", () => {
|
||||||
|
const registry = createMockRegistry({
|
||||||
|
username: "myuser",
|
||||||
|
registryUrl: "ghcr.io",
|
||||||
|
});
|
||||||
|
const result = getRegistryTag(registry, "myuser/myprivaterepo");
|
||||||
|
// Should not duplicate username
|
||||||
|
expect(result).toBe("ghcr.io/myuser/myprivaterepo");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("edge cases", () => {
|
||||||
|
it("should handle empty image name", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "");
|
||||||
|
expect(result).toBe("docker.io/myuser/");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle image name with multiple slashes", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "org/suborg/repo");
|
||||||
|
expect(result).toBe("docker.io/myuser/repo");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle image name with username at different position", () => {
|
||||||
|
const registry = createMockRegistry({ username: "myuser" });
|
||||||
|
const result = getRegistryTag(registry, "org/myuser/repo");
|
||||||
|
expect(result).toBe("docker.io/myuser/repo");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -28,6 +28,7 @@ const baseApp: ApplicationNested = {
|
|||||||
railpackVersion: "0.2.2",
|
railpackVersion: "0.2.2",
|
||||||
applicationId: "",
|
applicationId: "",
|
||||||
previewLabels: [],
|
previewLabels: [],
|
||||||
|
createEnvFile: true,
|
||||||
herokuVersion: "",
|
herokuVersion: "",
|
||||||
giteaBranch: "",
|
giteaBranch: "",
|
||||||
buildServerId: "",
|
buildServerId: "",
|
||||||
@@ -67,6 +68,7 @@ const baseApp: ApplicationNested = {
|
|||||||
previewWildcard: "",
|
previewWildcard: "",
|
||||||
environment: {
|
environment: {
|
||||||
env: "",
|
env: "",
|
||||||
|
isDefault: false,
|
||||||
environmentId: "",
|
environmentId: "",
|
||||||
name: "",
|
name: "",
|
||||||
createdAt: "",
|
createdAt: "",
|
||||||
|
|||||||
@@ -54,4 +54,22 @@ describe("processLogs", () => {
|
|||||||
const result = parseRawConfig(entryWithWhitespace);
|
const result = parseRawConfig(entryWithWhitespace);
|
||||||
expect(result.data).toHaveLength(2);
|
expect(result.data).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should filter out Dokploy dashboard requests", () => {
|
||||||
|
const dokployDashboardEntry = `{"ClientAddr":"172.71.187.131:9485","ClientHost":"172.71.187.131","ClientPort":"9485","ClientUsername":"-","DownstreamContentSize":14550,"DownstreamStatus":200,"Duration":57681682,"OriginContentSize":14550,"OriginDuration":57612242,"OriginStatus":200,"Overhead":69440,"RequestAddr":"hostinger.dokploy.com","RequestContentSize":0,"RequestCount":20142,"RequestHost":"hostinger.dokploy.com","RequestMethod":"GET","RequestPath":"/_next/data/cb_zzI4Rp9G7Q7djrFKh0/en/dashboard/traefik.json","RequestPort":"-","RequestProtocol":"HTTP/2.0","RequestScheme":"https","RetryAttempts":0,"RouterName":"dokploy-router-app-secure@file","ServiceAddr":"dokploy:3000","ServiceName":"dokploy-service-app@file","ServiceURL":"http://dokploy:3000","StartLocal":"2025-12-10T05:10:41.957755949Z","StartUTC":"2025-12-10T05:10:41.957755949Z","TLSCipher":"TLS_AES_128_GCM_SHA256","TLSVersion":"1.3","entryPointName":"websecure","level":"info","msg":"","time":"2025-12-10T05:10:42Z"}`;
|
||||||
|
|
||||||
|
// Test with only Dokploy dashboard entry - should be filtered out
|
||||||
|
const resultOnlyDokploy = parseRawConfig(dokployDashboardEntry);
|
||||||
|
expect(resultOnlyDokploy.data).toHaveLength(0);
|
||||||
|
expect(resultOnlyDokploy.totalCount).toBe(0);
|
||||||
|
|
||||||
|
// Test with mixed entries - Dokploy should be filtered, others should remain
|
||||||
|
const mixedEntries = `${dokployDashboardEntry}\n${sampleLogEntry}`;
|
||||||
|
const resultMixed = parseRawConfig(mixedEntries);
|
||||||
|
expect(resultMixed.data).toHaveLength(1);
|
||||||
|
expect(resultMixed.totalCount).toBe(1);
|
||||||
|
expect(resultMixed.data[0]?.ServiceName).not.toBe(
|
||||||
|
"dokploy-service-app@file",
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const baseApp: ApplicationNested = {
|
|||||||
rollbackActive: false,
|
rollbackActive: false,
|
||||||
applicationId: "",
|
applicationId: "",
|
||||||
previewLabels: [],
|
previewLabels: [],
|
||||||
|
createEnvFile: true,
|
||||||
herokuVersion: "",
|
herokuVersion: "",
|
||||||
giteaRepository: "",
|
giteaRepository: "",
|
||||||
giteaOwner: "",
|
giteaOwner: "",
|
||||||
@@ -49,6 +50,7 @@ const baseApp: ApplicationNested = {
|
|||||||
environmentId: "",
|
environmentId: "",
|
||||||
environment: {
|
environment: {
|
||||||
env: "",
|
env: "",
|
||||||
|
isDefault: false,
|
||||||
environmentId: "",
|
environmentId: "",
|
||||||
name: "",
|
name: "",
|
||||||
createdAt: "",
|
createdAt: "",
|
||||||
|
|||||||
@@ -208,6 +208,8 @@ export const AddDomain = ({ id, type, domainId = "", children }: Props) => {
|
|||||||
const certificateType = form.watch("certificateType");
|
const certificateType = form.watch("certificateType");
|
||||||
const https = form.watch("https");
|
const https = form.watch("https");
|
||||||
const domainType = form.watch("domainType");
|
const domainType = form.watch("domainType");
|
||||||
|
const host = form.watch("host");
|
||||||
|
const isTraefikMeDomain = host?.includes("traefik.me") || false;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -502,6 +504,13 @@ export const AddDomain = ({ id, type, domainId = "", children }: Props) => {
|
|||||||
to make your traefik.me domain work.
|
to make your traefik.me domain work.
|
||||||
</AlertBlock>
|
</AlertBlock>
|
||||||
)}
|
)}
|
||||||
|
{isTraefikMeDomain && (
|
||||||
|
<AlertBlock type="info">
|
||||||
|
<strong>Note:</strong> traefik.me is a public HTTP
|
||||||
|
service and does not support SSL/HTTPS. HTTPS and
|
||||||
|
certificate options will not have any effect.
|
||||||
|
</AlertBlock>
|
||||||
|
)}
|
||||||
<FormLabel>Host</FormLabel>
|
<FormLabel>Host</FormLabel>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
|
|||||||
@@ -5,14 +5,23 @@ import { toast } from "sonner";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "@/components/ui/card";
|
||||||
import { Form } from "@/components/ui/form";
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormDescription,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
} from "@/components/ui/form";
|
||||||
import { Secrets } from "@/components/ui/secrets";
|
import { Secrets } from "@/components/ui/secrets";
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
|
|
||||||
const addEnvironmentSchema = z.object({
|
const addEnvironmentSchema = z.object({
|
||||||
env: z.string(),
|
env: z.string(),
|
||||||
buildArgs: z.string(),
|
buildArgs: z.string(),
|
||||||
buildSecrets: z.string(),
|
buildSecrets: z.string(),
|
||||||
|
createEnvFile: z.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
type EnvironmentSchema = z.infer<typeof addEnvironmentSchema>;
|
type EnvironmentSchema = z.infer<typeof addEnvironmentSchema>;
|
||||||
@@ -39,6 +48,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
env: "",
|
env: "",
|
||||||
buildArgs: "",
|
buildArgs: "",
|
||||||
buildSecrets: "",
|
buildSecrets: "",
|
||||||
|
createEnvFile: true,
|
||||||
},
|
},
|
||||||
resolver: zodResolver(addEnvironmentSchema),
|
resolver: zodResolver(addEnvironmentSchema),
|
||||||
});
|
});
|
||||||
@@ -47,10 +57,12 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
const currentEnv = form.watch("env");
|
const currentEnv = form.watch("env");
|
||||||
const currentBuildArgs = form.watch("buildArgs");
|
const currentBuildArgs = form.watch("buildArgs");
|
||||||
const currentBuildSecrets = form.watch("buildSecrets");
|
const currentBuildSecrets = form.watch("buildSecrets");
|
||||||
|
const currentCreateEnvFile = form.watch("createEnvFile");
|
||||||
const hasChanges =
|
const hasChanges =
|
||||||
currentEnv !== (data?.env || "") ||
|
currentEnv !== (data?.env || "") ||
|
||||||
currentBuildArgs !== (data?.buildArgs || "") ||
|
currentBuildArgs !== (data?.buildArgs || "") ||
|
||||||
currentBuildSecrets !== (data?.buildSecrets || "");
|
currentBuildSecrets !== (data?.buildSecrets || "") ||
|
||||||
|
currentCreateEnvFile !== (data?.createEnvFile ?? true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -58,6 +70,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
env: data.env || "",
|
env: data.env || "",
|
||||||
buildArgs: data.buildArgs || "",
|
buildArgs: data.buildArgs || "",
|
||||||
buildSecrets: data.buildSecrets || "",
|
buildSecrets: data.buildSecrets || "",
|
||||||
|
createEnvFile: data.createEnvFile ?? true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [data, form]);
|
}, [data, form]);
|
||||||
@@ -67,6 +80,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
env: formData.env,
|
env: formData.env,
|
||||||
buildArgs: formData.buildArgs,
|
buildArgs: formData.buildArgs,
|
||||||
buildSecrets: formData.buildSecrets,
|
buildSecrets: formData.buildSecrets,
|
||||||
|
createEnvFile: formData.createEnvFile,
|
||||||
applicationId,
|
applicationId,
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
@@ -83,6 +97,7 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
env: data?.env || "",
|
env: data?.env || "",
|
||||||
buildArgs: data?.buildArgs || "",
|
buildArgs: data?.buildArgs || "",
|
||||||
buildSecrets: data?.buildSecrets || "",
|
buildSecrets: data?.buildSecrets || "",
|
||||||
|
createEnvFile: data?.createEnvFile ?? true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -167,6 +182,30 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
|
|||||||
placeholder="NPM_TOKEN=xyz"
|
placeholder="NPM_TOKEN=xyz"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{data?.buildType === "dockerfile" && (
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="createEnvFile"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex flex-row items-center justify-between p-3 border rounded-lg shadow-sm">
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<FormLabel>Create Environment File</FormLabel>
|
||||||
|
<FormDescription>
|
||||||
|
When enabled, an .env file will be created during the
|
||||||
|
build process. Disable this if you don't want to generate
|
||||||
|
an environment file.
|
||||||
|
</FormDescription>
|
||||||
|
</div>
|
||||||
|
<FormControl>
|
||||||
|
<Switch
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="flex flex-row justify-end gap-2">
|
<div className="flex flex-row justify-end gap-2">
|
||||||
{hasChanges && (
|
{hasChanges && (
|
||||||
<Button type="button" variant="outline" onClick={handleCancel}>
|
<Button type="button" variant="outline" onClick={handleCancel}>
|
||||||
|
|||||||
+10
@@ -86,6 +86,9 @@ export const AddPreviewDomain = ({
|
|||||||
resolver: zodResolver(domain),
|
resolver: zodResolver(domain),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const host = form.watch("host");
|
||||||
|
const isTraefikMeDomain = host?.includes("traefik.me") || false;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
form.reset({
|
form.reset({
|
||||||
@@ -157,6 +160,13 @@ export const AddPreviewDomain = ({
|
|||||||
name="host"
|
name="host"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
|
{isTraefikMeDomain && (
|
||||||
|
<AlertBlock type="info">
|
||||||
|
<strong>Note:</strong> traefik.me is a public HTTP
|
||||||
|
service and does not support SSL/HTTPS. HTTPS and
|
||||||
|
certificate options will not have any effect.
|
||||||
|
</AlertBlock>
|
||||||
|
)}
|
||||||
<FormLabel>Host</FormLabel>
|
<FormLabel>Host</FormLabel>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
|
|||||||
+10
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import { AlertBlock } from "@/components/shared/alert-block";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -100,6 +101,8 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const previewHttps = form.watch("previewHttps");
|
const previewHttps = form.watch("previewHttps");
|
||||||
|
const wildcardDomain = form.watch("wildcardDomain");
|
||||||
|
const isTraefikMeDomain = wildcardDomain?.includes("traefik.me") || false;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsEnabled(data?.isPreviewDeploymentsActive || false);
|
setIsEnabled(data?.isPreviewDeploymentsActive || false);
|
||||||
@@ -168,6 +171,13 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => {
|
|||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="grid gap-4">
|
<div className="grid gap-4">
|
||||||
|
{isTraefikMeDomain && (
|
||||||
|
<AlertBlock type="info">
|
||||||
|
<strong>Note:</strong> traefik.me is a public HTTP service and
|
||||||
|
does not support SSL/HTTPS. HTTPS and certificate options will
|
||||||
|
not have any effect.
|
||||||
|
</AlertBlock>
|
||||||
|
)}
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
setName("");
|
setName("");
|
||||||
setDescription("");
|
setDescription("");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error("Failed to create environment");
|
toast.error(
|
||||||
|
`Failed to create environment: ${error instanceof Error ? error.message : error}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -123,7 +125,9 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
setName("");
|
setName("");
|
||||||
setDescription("");
|
setDescription("");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error("Failed to update environment");
|
toast.error(
|
||||||
|
`Failed to update environment: ${error instanceof Error ? error.message : error}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -140,15 +144,18 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
setIsDeleteDialogOpen(false);
|
setIsDeleteDialogOpen(false);
|
||||||
setSelectedEnvironment(null);
|
setSelectedEnvironment(null);
|
||||||
|
|
||||||
// Redirect to production if we deleted the current environment
|
// Redirect to first available environment if we deleted the current environment
|
||||||
if (selectedEnvironment.environmentId === currentEnvironmentId) {
|
if (selectedEnvironment.environmentId === currentEnvironmentId) {
|
||||||
const productionEnv = environments?.find(
|
const firstEnv = environments?.find(
|
||||||
(env) => env.name === "production",
|
(env) => env.environmentId !== selectedEnvironment.environmentId,
|
||||||
);
|
);
|
||||||
if (productionEnv) {
|
if (firstEnv) {
|
||||||
router.push(
|
router.push(
|
||||||
`/dashboard/project/${projectId}/environment/${productionEnv.environmentId}`,
|
`/dashboard/project/${projectId}/environment/${firstEnv.environmentId}`,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
// No other environments, redirect to project page
|
||||||
|
router.push(`/dashboard/project/${projectId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -239,8 +246,8 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
{environment.name !== "production" && (
|
<div className="flex items-center gap-1 px-2">
|
||||||
<div className="flex items-center gap-1 px-2">
|
{!environment.isDefault && (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -252,22 +259,21 @@ export const AdvancedEnvironmentSelector = ({
|
|||||||
>
|
>
|
||||||
<PencilIcon className="h-3 w-3" />
|
<PencilIcon className="h-3 w-3" />
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
{canDeleteEnvironments && (
|
{canDeleteEnvironments && !environment.isDefault && (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-6 w-6 p-0 text-red-600 hover:text-red-700"
|
className="h-6 w-6 p-0 text-red-600 hover:text-red-700"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
openDeleteDialog(environment);
|
openDeleteDialog(environment);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TrashIcon className="h-3 w-3" />
|
<TrashIcon className="h-3 w-3" />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -89,24 +89,26 @@ export const SearchCommand = () => {
|
|||||||
<CommandGroup heading={"Projects"}>
|
<CommandGroup heading={"Projects"}>
|
||||||
<CommandList>
|
<CommandList>
|
||||||
{data?.map((project) => {
|
{data?.map((project) => {
|
||||||
const productionEnvironment = project.environments.find(
|
// Find default environment, or fall back to first environment
|
||||||
(environment) => environment.name === "production",
|
const defaultEnvironment =
|
||||||
);
|
project.environments.find(
|
||||||
|
(environment) => environment.isDefault,
|
||||||
|
) || project?.environments?.[0];
|
||||||
|
|
||||||
if (!productionEnvironment) return null;
|
if (!defaultEnvironment) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={project.projectId}
|
key={project.projectId}
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
router.push(
|
router.push(
|
||||||
`/dashboard/project/${project.projectId}/environment/${productionEnvironment!.environmentId}`,
|
`/dashboard/project/${project.projectId}/environment/${defaultEnvironment.environmentId}`,
|
||||||
);
|
);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<BookIcon className="size-4 text-muted-foreground mr-2" />
|
<BookIcon className="size-4 text-muted-foreground mr-2" />
|
||||||
{project.name} / {productionEnvironment!.name}
|
{project.name} / {defaultEnvironment.name}
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -45,7 +45,34 @@ const AddRegistrySchema = z.object({
|
|||||||
password: z.string().min(1, {
|
password: z.string().min(1, {
|
||||||
message: "Password is required",
|
message: "Password is required",
|
||||||
}),
|
}),
|
||||||
registryUrl: z.string(),
|
registryUrl: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.refine(
|
||||||
|
(val) => {
|
||||||
|
// If empty or undefined, skip validation (field is optional)
|
||||||
|
if (!val || val.trim().length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Validate that it's a valid hostname (no protocol, no path, optional port)
|
||||||
|
// Valid formats: example.com, registry.example.com, [::1], example.com:5000
|
||||||
|
// Invalid: https://example.com, example.com/path
|
||||||
|
const trimmed = val.trim();
|
||||||
|
// Check for protocol or path - these are not allowed
|
||||||
|
if (/^https?:\/\//i.test(trimmed) || trimmed.includes("/")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Basic hostname validation: allow alphanumeric, dots, hyphens, underscores, and IPv6 in brackets
|
||||||
|
// Allow optional port at the end
|
||||||
|
const hostnameRegex =
|
||||||
|
/^(?:\[[^\]]+\]|[a-zA-Z0-9](?:[a-zA-Z0-9._-]{0,253}[a-zA-Z0-9])?)(?::\d+)?$/;
|
||||||
|
return hostnameRegex.test(trimmed);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message:
|
||||||
|
"Invalid registry URL. Please enter only the hostname (e.g., example.com or registry.example.com). Do not include protocol (https://) or paths.",
|
||||||
|
},
|
||||||
|
),
|
||||||
imagePrefix: z.string(),
|
imagePrefix: z.string(),
|
||||||
serverId: z.string().optional(),
|
serverId: z.string().optional(),
|
||||||
});
|
});
|
||||||
@@ -99,6 +126,9 @@ export const HandleRegistry = ({ registryId }: Props) => {
|
|||||||
const registryName = form.watch("registryName");
|
const registryName = form.watch("registryName");
|
||||||
const imagePrefix = form.watch("imagePrefix");
|
const imagePrefix = form.watch("imagePrefix");
|
||||||
const serverId = form.watch("serverId");
|
const serverId = form.watch("serverId");
|
||||||
|
const selectedServer = servers?.find(
|
||||||
|
(server) => server.serverId === serverId,
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (registry) {
|
if (registry) {
|
||||||
@@ -125,7 +155,7 @@ export const HandleRegistry = ({ registryId }: Props) => {
|
|||||||
password: data.password,
|
password: data.password,
|
||||||
registryName: data.registryName,
|
registryName: data.registryName,
|
||||||
username: data.username,
|
username: data.username,
|
||||||
registryUrl: data.registryUrl,
|
registryUrl: data.registryUrl || "",
|
||||||
registryType: "cloud",
|
registryType: "cloud",
|
||||||
imagePrefix: data.imagePrefix,
|
imagePrefix: data.imagePrefix,
|
||||||
serverId: data.serverId,
|
serverId: data.serverId,
|
||||||
@@ -261,6 +291,10 @@ export const HandleRegistry = ({ registryId }: Props) => {
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Registry URL</FormLabel>
|
<FormLabel>Registry URL</FormLabel>
|
||||||
|
<FormDescription>
|
||||||
|
Enter only the hostname (e.g.,
|
||||||
|
aws_account_id.dkr.ecr.us-west-2.amazonaws.com).
|
||||||
|
</FormDescription>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
placeholder="aws_account_id.dkr.ecr.us-west-2.amazonaws.com"
|
placeholder="aws_account_id.dkr.ecr.us-west-2.amazonaws.com"
|
||||||
@@ -282,8 +316,40 @@ export const HandleRegistry = ({ registryId }: Props) => {
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Server {!isCloud && "(Optional)"}</FormLabel>
|
<FormLabel>Server {!isCloud && "(Optional)"}</FormLabel>
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
Select a server to test the registry. this will run the
|
{!isCloud ? (
|
||||||
following command on the server
|
<>
|
||||||
|
{serverId && serverId !== "none" && selectedServer ? (
|
||||||
|
<>
|
||||||
|
Authentication will be performed on{" "}
|
||||||
|
<strong>{selectedServer.name}</strong>. This
|
||||||
|
registry will be available on this server.
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
Choose where to authenticate with the registry. By
|
||||||
|
default, authentication occurs on the Dokploy
|
||||||
|
server. Select a specific server to authenticate
|
||||||
|
from that server instead.
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{serverId && serverId !== "none" && selectedServer ? (
|
||||||
|
<>
|
||||||
|
Authentication will be performed on{" "}
|
||||||
|
<strong>{selectedServer.name}</strong>. This
|
||||||
|
registry will be available on this server.
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
Select a server to authenticate with the registry.
|
||||||
|
The authentication will be performed from the
|
||||||
|
selected server.
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Select
|
<Select
|
||||||
@@ -345,7 +411,7 @@ export const HandleRegistry = ({ registryId }: Props) => {
|
|||||||
await testRegistry({
|
await testRegistry({
|
||||||
username: username,
|
username: username,
|
||||||
password: password,
|
password: password,
|
||||||
registryUrl: registryUrl,
|
registryUrl: registryUrl || "",
|
||||||
registryName: registryName,
|
registryName: registryName,
|
||||||
registryType: "cloud",
|
registryType: "cloud",
|
||||||
imagePrefix: imagePrefix,
|
imagePrefix: imagePrefix,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { ImpersonationBar } from "../dashboard/impersonation/impersonation-bar";
|
import { ImpersonationBar } from "../dashboard/impersonation/impersonation-bar";
|
||||||
import { ChatwootWidget } from "../shared/ChatwootWidget";
|
import { HubSpotWidget } from "../shared/HubSpotWidget";
|
||||||
import Page from "./side";
|
import Page from "./side";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -25,7 +25,9 @@ export const DashboardLayout = ({ children }: Props) => {
|
|||||||
<>
|
<>
|
||||||
<Page>{children}</Page>
|
<Page>{children}</Page>
|
||||||
{isCloud === true && isUserSubscribed === true && (
|
{isCloud === true && isUserSubscribed === true && (
|
||||||
<ChatwootWidget websiteToken="USCpQRKzHvFMssf3p6Eacae5" />
|
<>
|
||||||
|
<HubSpotWidget />
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{haveRootAccess === true && <ImpersonationBar />}
|
{haveRootAccess === true && <ImpersonationBar />}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import Script from "next/script";
|
||||||
|
|
||||||
|
export const HubSpotWidget = () => {
|
||||||
|
return (
|
||||||
|
<Script
|
||||||
|
id="hs-script-loader"
|
||||||
|
type="text/javascript"
|
||||||
|
src="//js-eu1.hs-scripts.com/147033433.js"
|
||||||
|
strategy="lazyOnload"
|
||||||
|
async
|
||||||
|
defer
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "application" ADD COLUMN "createEnvFile" boolean DEFAULT true NOT NULL;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE "environment" ADD COLUMN "isDefault" boolean DEFAULT false NOT NULL;
|
||||||
|
|
||||||
|
-- Set isDefault to true for existing production environments
|
||||||
|
UPDATE "environment" SET "isDefault" = true WHERE "name" = 'production';
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -918,6 +918,20 @@
|
|||||||
"when": 1765167657813,
|
"when": 1765167657813,
|
||||||
"tag": "0130_perpetual_screwball",
|
"tag": "0130_perpetual_screwball",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 131,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1765342621312,
|
||||||
|
"tag": "0131_volatile_beast",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 132,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1765346573500,
|
||||||
|
"tag": "0132_clean_layla_miller",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dokploy",
|
"name": "dokploy",
|
||||||
"version": "v0.26.0",
|
"version": "v0.26.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -81,41 +81,34 @@ export default async function handler(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!webhookImageName) {
|
// If webhook provides image information, validate it matches the configured image
|
||||||
res.status(301).json({
|
// If webhook doesn't provide image information, fall back to using the configured image (backward compatibility)
|
||||||
message: "Webhook Docker Image Name Not Found",
|
if (webhookImageName) {
|
||||||
});
|
// Validate image name matches
|
||||||
return;
|
if (webhookImageName !== applicationImageName) {
|
||||||
}
|
res.status(301).json({
|
||||||
|
message: `Application Image Name (${applicationImageName}) doesn't match request event payload Image Name (${webhookImageName}).`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Validate image name matches
|
if (!applicationDockerTag) {
|
||||||
if (webhookImageName !== applicationImageName) {
|
res.status(301).json({
|
||||||
res.status(301).json({
|
message: "Application Docker Tag Not Found",
|
||||||
message: `Application Image Name (${applicationImageName}) doesn't match request event payload Image Name (${webhookImageName}).`,
|
});
|
||||||
});
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!applicationDockerTag) {
|
if (webhookDockerTag) {
|
||||||
res.status(301).json({
|
if (webhookDockerTag !== applicationDockerTag) {
|
||||||
message: "Application Docker Tag Not Found",
|
res.status(301).json({
|
||||||
});
|
message: `Application Image Tag (${applicationDockerTag}) doesn't match request event payload Image Tag (${webhookDockerTag}).`,
|
||||||
return;
|
});
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if (!webhookDockerTag) {
|
}
|
||||||
res.status(301).json({
|
|
||||||
message: "Webhook Docker Tag Not Found",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (webhookDockerTag !== applicationDockerTag) {
|
|
||||||
res.status(301).json({
|
|
||||||
message: `Application Image Tag (${applicationDockerTag}) doesn't match request event payload Image Tag (${webhookDockerTag}).`,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
// If webhook doesn't provide image info, we'll use the configured image (old behavior)
|
||||||
} else if (sourceType === "github") {
|
} else if (sourceType === "github") {
|
||||||
const normalizedCommits = req.body?.commits?.flatMap(
|
const normalizedCommits = req.body?.commits?.flatMap(
|
||||||
(commit: any) => commit.modified,
|
(commit: any) => commit.modified,
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
env: input.env,
|
env: input.env,
|
||||||
buildArgs: input.buildArgs,
|
buildArgs: input.buildArgs,
|
||||||
buildSecrets: input.buildSecrets,
|
buildSecrets: input.buildSecrets,
|
||||||
|
createEnvFile: input.createEnvFile,
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -66,10 +66,12 @@ export const environmentRouter = createTRPCRouter({
|
|||||||
if (input.name === "production") {
|
if (input.name === "production") {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
message: "Environment name cannot be production",
|
message:
|
||||||
|
"You cannot create a environment with the name 'production'",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow users to create environments with any name, including "production"
|
||||||
const environment = await createEnvironment(input);
|
const environment = await createEnvironment(input);
|
||||||
|
|
||||||
if (ctx.user.role === "member") {
|
if (ctx.user.role === "member") {
|
||||||
@@ -243,13 +245,7 @@ export const environmentRouter = createTRPCRouter({
|
|||||||
try {
|
try {
|
||||||
const { environmentId, ...updateData } = input;
|
const { environmentId, ...updateData } = input;
|
||||||
|
|
||||||
if (updateData.name === "production") {
|
// Allow users to rename environments to any name, including "production"
|
||||||
throw new TRPCError({
|
|
||||||
code: "BAD_REQUEST",
|
|
||||||
message: "Environment name cannot be production",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx.user.role === "member") {
|
if (ctx.user.role === "member") {
|
||||||
await checkEnvironmentAccess(
|
await checkEnvironmentAccess(
|
||||||
ctx.user.id,
|
ctx.user.id,
|
||||||
@@ -259,6 +255,13 @@ export const environmentRouter = createTRPCRouter({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const currentEnvironment = await findEnvironmentById(environmentId);
|
const currentEnvironment = await findEnvironmentById(environmentId);
|
||||||
|
|
||||||
|
if (currentEnvironment.isDefault) {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "BAD_REQUEST",
|
||||||
|
message: "You cannot update the default environment",
|
||||||
|
});
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
currentEnvironment.project.organizationId !==
|
currentEnvironment.project.organizationId !==
|
||||||
ctx.session.activeOrganizationId
|
ctx.session.activeOrganizationId
|
||||||
|
|||||||
@@ -247,3 +247,18 @@
|
|||||||
.cm-lineWrapping {
|
.cm-lineWrapping {
|
||||||
@apply font-mono;
|
@apply font-mono;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* HubSpot Widget - Force light color-scheme to prevent white background */
|
||||||
|
#hubspot-messages-iframe-container,
|
||||||
|
#hubspot-messages-iframe-container * {
|
||||||
|
background-color: transparent !important;
|
||||||
|
color-scheme: light !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hubspot-messages-iframe-container .hs-shadow-container {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hubspot-conversations-iframe {
|
||||||
|
color-scheme: light !important;
|
||||||
|
}
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ export const applications = pgTable("application", {
|
|||||||
herokuVersion: text("herokuVersion").default("24"),
|
herokuVersion: text("herokuVersion").default("24"),
|
||||||
publishDirectory: text("publishDirectory"),
|
publishDirectory: text("publishDirectory"),
|
||||||
isStaticSpa: boolean("isStaticSpa"),
|
isStaticSpa: boolean("isStaticSpa"),
|
||||||
|
createEnvFile: boolean("createEnvFile").notNull().default(true),
|
||||||
createdAt: text("createdAt")
|
createdAt: text("createdAt")
|
||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
.$defaultFn(() => new Date().toISOString()),
|
||||||
@@ -332,6 +333,7 @@ const createSchema = createInsertSchema(applications, {
|
|||||||
herokuVersion: z.string().optional(),
|
herokuVersion: z.string().optional(),
|
||||||
publishDirectory: z.string().optional(),
|
publishDirectory: z.string().optional(),
|
||||||
isStaticSpa: z.boolean().optional(),
|
isStaticSpa: z.boolean().optional(),
|
||||||
|
createEnvFile: z.boolean().optional(),
|
||||||
owner: z.string(),
|
owner: z.string(),
|
||||||
healthCheckSwarm: HealthCheckSwarmSchema.nullable(),
|
healthCheckSwarm: HealthCheckSwarmSchema.nullable(),
|
||||||
restartPolicySwarm: RestartPolicySwarmSchema.nullable(),
|
restartPolicySwarm: RestartPolicySwarmSchema.nullable(),
|
||||||
@@ -501,6 +503,7 @@ export const apiSaveEnvironmentVariables = createSchema
|
|||||||
env: true,
|
env: true,
|
||||||
buildArgs: true,
|
buildArgs: true,
|
||||||
buildSecrets: true,
|
buildSecrets: true,
|
||||||
|
createEnvFile: true,
|
||||||
})
|
})
|
||||||
.required();
|
.required();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { relations } from "drizzle-orm";
|
import { relations } from "drizzle-orm";
|
||||||
import { pgTable, text } from "drizzle-orm/pg-core";
|
import { boolean, pgTable, text } from "drizzle-orm/pg-core";
|
||||||
import { createInsertSchema } from "drizzle-zod";
|
import { createInsertSchema } from "drizzle-zod";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
@@ -26,6 +26,7 @@ export const environments = pgTable("environment", {
|
|||||||
projectId: text("projectId")
|
projectId: text("projectId")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => projects.projectId, { onDelete: "cascade" }),
|
.references(() => projects.projectId, { onDelete: "cascade" }),
|
||||||
|
isDefault: boolean("isDefault").notNull().default(false),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const environmentRelations = relations(
|
export const environmentRelations = relations(
|
||||||
@@ -69,9 +70,14 @@ export const apiRemoveEnvironment = createSchema
|
|||||||
})
|
})
|
||||||
.required();
|
.required();
|
||||||
|
|
||||||
export const apiUpdateEnvironment = createSchema.partial().extend({
|
export const apiUpdateEnvironment = createSchema
|
||||||
environmentId: z.string().min(1),
|
.partial()
|
||||||
});
|
.extend({
|
||||||
|
environmentId: z.string().min(1),
|
||||||
|
})
|
||||||
|
.omit({
|
||||||
|
isDefault: true,
|
||||||
|
});
|
||||||
|
|
||||||
export const apiDuplicateEnvironment = createSchema
|
export const apiDuplicateEnvironment = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ export const findEnvironmentsByProjectId = async (projectId: string) => {
|
|||||||
|
|
||||||
export const deleteEnvironment = async (environmentId: string) => {
|
export const deleteEnvironment = async (environmentId: string) => {
|
||||||
const currentEnvironment = await findEnvironmentById(environmentId);
|
const currentEnvironment = await findEnvironmentById(environmentId);
|
||||||
if (currentEnvironment.name === "production") {
|
if (currentEnvironment.isDefault) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
message: "You cannot delete the production environment",
|
message: "You cannot delete the default environment",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const deletedEnvironment = await db
|
const deletedEnvironment = await db
|
||||||
@@ -162,9 +162,23 @@ export const duplicateEnvironment = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const createProductionEnvironment = async (projectId: string) => {
|
export const createProductionEnvironment = async (projectId: string) => {
|
||||||
return createEnvironment({
|
const newEnvironment = await db
|
||||||
name: "production",
|
.insert(environments)
|
||||||
description: "Production environment",
|
.values({
|
||||||
projectId,
|
name: "production",
|
||||||
});
|
description: "Production environment",
|
||||||
|
projectId,
|
||||||
|
isDefault: true,
|
||||||
|
})
|
||||||
|
.returning()
|
||||||
|
.then((value) => value[0]);
|
||||||
|
|
||||||
|
if (!newEnvironment) {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "BAD_REQUEST",
|
||||||
|
message: "Error creating the production environment",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return newEnvironment;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -99,6 +99,11 @@ export function parseRawConfig(
|
|||||||
.compact()
|
.compact()
|
||||||
.value();
|
.value();
|
||||||
|
|
||||||
|
// Filter out Dokploy dashboard requests
|
||||||
|
parsedLogs = parsedLogs.filter(
|
||||||
|
(log) => log.ServiceName !== "dokploy-service-app@file",
|
||||||
|
);
|
||||||
|
|
||||||
// Apply date range filter if provided
|
// Apply date range filter if provided
|
||||||
if (dateRange?.start || dateRange?.end) {
|
if (dateRange?.start || dateRange?.end) {
|
||||||
parsedLogs = parsedLogs.filter((log) => {
|
parsedLogs = parsedLogs.filter((log) => {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export const initCronJobs = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (admin.user.enableDockerCleanup) {
|
if (admin?.user?.enableDockerCleanup) {
|
||||||
scheduleJob("docker-cleanup", "0 0 * * *", async () => {
|
scheduleJob("docker-cleanup", "0 0 * * *", async () => {
|
||||||
console.log(
|
console.log(
|
||||||
`Docker Cleanup ${new Date().toLocaleString()}] Running docker cleanup`,
|
`Docker Cleanup ${new Date().toLocaleString()}] Running docker cleanup`,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
getDockerContextPath,
|
getDockerContextPath,
|
||||||
} from "../filesystem/directory";
|
} from "../filesystem/directory";
|
||||||
import type { ApplicationNested } from ".";
|
import type { ApplicationNested } from ".";
|
||||||
|
import { createEnvFileCommand } from "./utils";
|
||||||
|
|
||||||
export const getDockerCommand = (application: ApplicationNested) => {
|
export const getDockerCommand = (application: ApplicationNested) => {
|
||||||
const {
|
const {
|
||||||
@@ -18,6 +19,7 @@ export const getDockerCommand = (application: ApplicationNested) => {
|
|||||||
buildSecrets,
|
buildSecrets,
|
||||||
dockerBuildStage,
|
dockerBuildStage,
|
||||||
cleanCache,
|
cleanCache,
|
||||||
|
createEnvFile,
|
||||||
} = application;
|
} = application;
|
||||||
const dockerFilePath = getBuildAppDirectory(application);
|
const dockerFilePath = getBuildAppDirectory(application);
|
||||||
|
|
||||||
@@ -60,6 +62,21 @@ export const getDockerCommand = (application: ApplicationNested) => {
|
|||||||
.map(([key, value]) => `${key}=${quote([value])}`)
|
.map(([key, value]) => `${key}=${quote([value])}`)
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|
||||||
|
/*
|
||||||
|
Do not generate an environment file when publishDirectory is specified,
|
||||||
|
as it could be publicly exposed.
|
||||||
|
Also respect the createEnvFile flag.
|
||||||
|
*/
|
||||||
|
let command = "";
|
||||||
|
if (!publishDirectory && createEnvFile) {
|
||||||
|
command += createEnvFileCommand(
|
||||||
|
dockerFilePath,
|
||||||
|
env,
|
||||||
|
application.environment.project.env,
|
||||||
|
application.environment.env,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
for (const key in secrets) {
|
for (const key in secrets) {
|
||||||
// Although buildx is smart enough to know we may be referring to an environment variable name,
|
// Although buildx is smart enough to know we may be referring to an environment variable name,
|
||||||
// we still make sure it doesn't fall back to `type=file`.
|
// we still make sure it doesn't fall back to `type=file`.
|
||||||
@@ -67,7 +84,7 @@ export const getDockerCommand = (application: ApplicationNested) => {
|
|||||||
commandArgs.push("--secret", `type=env,id=${key}`);
|
commandArgs.push("--secret", `type=env,id=${key}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const command = `
|
command += `
|
||||||
echo "Building ${appName}" ;
|
echo "Building ${appName}" ;
|
||||||
cd ${dockerContextPath} || {
|
cd ${dockerContextPath} || {
|
||||||
echo "❌ The path ${dockerContextPath} does not exist" ;
|
echo "❌ The path ${dockerContextPath} does not exist" ;
|
||||||
|
|||||||
@@ -74,11 +74,40 @@ export const uploadImageRemoteCommand = async (
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Extract the repository name from imageName by taking the last part after '/'
|
||||||
|
* Examples:
|
||||||
|
* - "nginx" -> "nginx"
|
||||||
|
* - "nginx:latest" -> "nginx:latest"
|
||||||
|
* - "myuser/myrepo" -> "myrepo"
|
||||||
|
* - "myuser/myrepo:tag" -> "myrepo:tag"
|
||||||
|
* - "docker.io/myuser/myrepo" -> "myrepo"
|
||||||
|
*/
|
||||||
|
const extractRepositoryName = (imageName: string): string => {
|
||||||
|
const lastSlashIndex = imageName.lastIndexOf("/");
|
||||||
|
|
||||||
|
// If no '/', return the imageName as is
|
||||||
|
if (lastSlashIndex === -1) {
|
||||||
|
return imageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract everything after the last '/'
|
||||||
|
return imageName.substring(lastSlashIndex + 1);
|
||||||
|
};
|
||||||
|
|
||||||
export const getRegistryTag = (registry: Registry, imageName: string) => {
|
export const getRegistryTag = (registry: Registry, imageName: string) => {
|
||||||
const { registryUrl, imagePrefix, username } = registry;
|
const { registryUrl, imagePrefix, username } = registry;
|
||||||
return imagePrefix
|
|
||||||
? `${registryUrl ? `${registryUrl}/` : ""}${imagePrefix}/${imageName}`
|
// Extract the repository name (last part after '/')
|
||||||
: `${registryUrl ? `${registryUrl}/` : ""}${username}/${imageName}`;
|
const repositoryName = extractRepositoryName(imageName);
|
||||||
|
|
||||||
|
// Build the final tag using registry's username/prefix
|
||||||
|
const targetPrefix = imagePrefix || username;
|
||||||
|
const finalRegistry = registryUrl || "";
|
||||||
|
|
||||||
|
return finalRegistry
|
||||||
|
? `${finalRegistry}/${targetPrefix}/${repositoryName}`
|
||||||
|
: `${targetPrefix}/${repositoryName}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRegistryCommands = (
|
const getRegistryCommands = (
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ export const readMonitoringConfig = async (readAll = false) => {
|
|||||||
trimmed.endsWith("}")
|
trimmed.endsWith("}")
|
||||||
) {
|
) {
|
||||||
const log = JSON.parse(trimmed);
|
const log = JSON.parse(trimmed);
|
||||||
|
// Exclude Dokploy service app and Dashboard requests
|
||||||
if (log.ServiceName !== "dokploy-service-app@file") {
|
if (log.ServiceName !== "dokploy-service-app@file") {
|
||||||
content += `${line}\n`;
|
content += `${line}\n`;
|
||||||
validCount++;
|
validCount++;
|
||||||
|
|||||||
Reference in New Issue
Block a user