Skip to content

Commit

Permalink
Merge pull request #367 from Dokploy/canary
Browse files Browse the repository at this point in the history
v0.7.1
  • Loading branch information
Siumauricio authored Aug 19, 2024
2 parents 452793c + afbe42a commit d5c6a60
Show file tree
Hide file tree
Showing 70 changed files with 673 additions and 578 deletions.
17 changes: 12 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,26 @@ import {
generateRandomDomain,
type Template,
type Schema,
type DomainSchema,
} from "../utils";

export function generate(schema: Schema): Template {
// do your stuff here, like create a new domain, generate random passwords, mounts.
const mainServiceHash = generateHash(schema.projectName);
const randomDomain = generateRandomDomain(schema);
const mainDomain = generateRandomDomain(schema);
const secretBase = generateBase64(64);
const toptKeyBase = generateBase64(32);

const domains: DomainSchema[] = [
{
host: mainDomain,
port: 8000,
serviceName: "plausible",
},
];

const envs = [
// If you want to show a domain in the UI, please add the prefix _HOST at the end of the variable name.
`PLAUSIBLE_HOST=${randomDomain}`,
"PLAUSIBLE_PORT=8000",
`BASE_URL=http://${randomDomain}`,
`BASE_URL=http://${mainDomain}`,
`SECRET_KEY_BASE=${secretBase}`,
`TOTP_VAULT_KEY=${toptKeyBase}`,
`HASH=${mainServiceHash}`,
Expand All @@ -195,6 +201,7 @@ export function generate(schema: Schema): Template {
return {
envs,
mounts,
domains,
};
}
```
Expand Down
26 changes: 26 additions & 0 deletions LICENSE.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# License

## Core License (Apache License 2.0)

Copyright 2024 Mauricio Siu.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.

## Additional Terms for Specific Features

The following additional terms apply to the multi-node support and Docker Compose file support features of Dokploy. In the event of a conflict, these provisions shall take precedence over those in the Apache License:

- **Self-Hosted Version Free**: All features of Dokploy, including multi-node support and Docker Compose file support, will always be free to use in the self-hosted version.
- **Restriction on Resale**: The multi-node support and Docker Compose file support features cannot be sold or offered as a service by any party other than the copyright holder without prior written consent.
- **Modification Distribution**: Any modifications to the multi-node support and Docker Compose file support features must be distributed freely and cannot be sold or offered as a service.

For further inquiries or permissions, please contact us directly.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ export const AddManager = () => {
<div className="flex flex-col gap-2.5 text-sm">
<span>1. Go to your new server and run the following command</span>
<span className="bg-muted rounded-lg p-2 flex justify-between">
curl https://get.docker.com | sh -s -- --version 24.0
curl https://get.docker.com | sh -s -- --version {data?.version}
<button
type="button"
className="self-center"
onClick={() => {
copy("curl https://get.docker.com | sh -s -- --version 24.0");
copy(
`curl https://get.docker.com | sh -s -- --version ${data?.version}`,
);
toast.success("Copied to clipboard");
}}
>
Expand All @@ -43,12 +45,12 @@ export const AddManager = () => {
cluster
</span>
<span className="bg-muted rounded-lg p-2 flex">
{data}
{data?.command}
<button
type="button"
className="self-start"
onClick={() => {
copy(data || "");
copy(data?.command || "");
toast.success("Copied to clipboard");
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ export const AddWorker = () => {
<div className="flex flex-col gap-2.5 text-sm">
<span>1. Go to your new server and run the following command</span>
<span className="bg-muted rounded-lg p-2 flex justify-between">
curl https://get.docker.com | sh -s -- --version 24.0
curl https://get.docker.com | sh -s -- --version {data?.version}
<button
type="button"
className="self-center"
onClick={() => {
copy("curl https://get.docker.com | sh -s -- --version 24.0");
copy(
`curl https://get.docker.com | sh -s -- --version ${data?.version}`,
);
toast.success("Copied to clipboard");
}}
>
Expand All @@ -42,12 +44,12 @@ export const AddWorker = () => {
</span>

<span className="bg-muted rounded-lg p-2 flex">
{data}
{data?.command}
<button
type="button"
className="self-start"
onClick={() => {
copy(data || "");
copy(data?.command || "");
toast.success("Copied to clipboard");
}}
>
Expand Down
45 changes: 25 additions & 20 deletions apps/dokploy/components/dashboard/settings/web-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { api } from "@/utils/api";
import { toast } from "sonner";
import { DockerTerminalModal } from "./web-server/docker-terminal-modal";
import { EditTraefikEnv } from "./web-server/edit-traefik-env";
import { ShowMainTraefikConfig } from "./web-server/show-main-traefik-config";
import { ShowModalLogs } from "./web-server/show-modal-logs";
import { ShowServerMiddlewareConfig } from "./web-server/show-server-middleware-config";
Expand Down Expand Up @@ -67,6 +68,9 @@ export const WebServer = () => {
const { mutateAsync: updateDockerCleanup } =
api.settings.updateDockerCleanup.useMutation();

const { data: haveTraefikDashboardPortEnabled, refetch: refetchDashboard } =
api.settings.haveTraefikDashboardPortEnabled.useQuery();

return (
<Card className="rounded-lg w-full bg-transparent">
<CardHeader>
Expand Down Expand Up @@ -167,37 +171,38 @@ export const WebServer = () => {
<span>View Traefik config</span>
</DropdownMenuItem>
</ShowMainTraefikConfig>
<EditTraefikEnv>
<DropdownMenuItem
onSelect={(e) => e.preventDefault()}
className="w-full cursor-pointer space-x-3"
>
<span>Modify Env</span>
</DropdownMenuItem>
</EditTraefikEnv>

<DropdownMenuItem
onClick={async () => {
await toggleDashboard({
enableDashboard: true,
})
.then(async () => {
toast.success("Dashboard Enabled");
})
.catch(() => {
toast.error("Error to enable Dashboard");
});
}}
className="w-full cursor-pointer space-x-3"
>
<span>Enable Dashboard</span>
</DropdownMenuItem>
<DropdownMenuItem
onClick={async () => {
await toggleDashboard({
enableDashboard: false,
enableDashboard: !haveTraefikDashboardPortEnabled,
})
.then(async () => {
toast.success("Dashboard Disabled");
toast.success(
`${haveTraefikDashboardPortEnabled ? "Disabled" : "Enabled"} Dashboard`,
);
refetchDashboard();
})
.catch(() => {
toast.error("Error to disable Dashboard");
toast.error(
`${haveTraefikDashboardPortEnabled ? "Disabled" : "Enabled"} Dashboard`,
);
});
}}
className="w-full cursor-pointer space-x-3"
>
<span>Disable Dashboard</span>
<span>
{haveTraefikDashboardPortEnabled ? "Disable" : "Enable"}{" "}
Dashboard
</span>
</DropdownMenuItem>

<DockerTerminalModal appName="dokploy-traefik">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import { AlertBlock } from "@/components/shared/alert-block";
import { CodeEditor } from "@/components/shared/code-editor";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { api } from "@/utils/api";
import { zodResolver } from "@hookform/resolvers/zod";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";

const schema = z.object({
env: z.string(),
});

type Schema = z.infer<typeof schema>;

interface Props {
children?: React.ReactNode;
}

export const EditTraefikEnv = ({ children }: Props) => {
const [canEdit, setCanEdit] = useState(true);

const { data } = api.settings.readTraefikEnv.useQuery();

const { mutateAsync, isLoading, error, isError } =
api.settings.writeTraefikEnv.useMutation();

const form = useForm<Schema>({
defaultValues: {
env: data || "",
},
disabled: canEdit,
resolver: zodResolver(schema),
});

useEffect(() => {
if (data) {
form.reset({
env: data || "",
});
}
}, [form, form.reset, data]);

const onSubmit = async (data: Schema) => {
await mutateAsync(data.env)
.then(async () => {
toast.success("Traefik Env Updated");
})
.catch(() => {
toast.error("Error to update the traefik env");
});
};

return (
<Dialog>
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-4xl">
<DialogHeader>
<DialogTitle>Update Traefik Env</DialogTitle>
<DialogDescription>Update the traefik env</DialogDescription>
</DialogHeader>
{isError && <AlertBlock type="error">{error?.message}</AlertBlock>}

<Form {...form}>
<form
id="hook-form-update-server-traefik-config"
onSubmit={form.handleSubmit(onSubmit)}
className="w-full space-y-4 relative overflow-auto"
>
<div className="flex flex-col">
<FormField
control={form.control}
name="env"
render={({ field }) => (
<FormItem className="relative">
<FormLabel>Env</FormLabel>
<FormControl>
<CodeEditor
language="properties"
wrapperClassName="h-[35rem] font-mono"
placeholder={`TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_EMAIL=test@localhost.com
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_STORAGE=/etc/dokploy/traefik/dynamic/acme.json
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_HTTP_CHALLENGE=true
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_HTTP_CHALLENGE_PRETTY=true
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_HTTP_CHALLENGE_ENTRYPOINT=web
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_HTTP_CHALLENGE_DNS_CHALLENGE=true
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_HTTP_CHALLENGE_DNS_PROVIDER=cloudflare
`}
{...field}
/>
</FormControl>

<pre>
<FormMessage />
</pre>
<div className="flex justify-end absolute z-50 right-6 top-0">
<Button
className="shadow-sm"
variant="secondary"
type="button"
onClick={async () => {
setCanEdit(!canEdit);
}}
>
{canEdit ? "Unlock" : "Lock"}
</Button>
</div>
</FormItem>
)}
/>
</div>
</form>

<DialogFooter>
<Button
isLoading={isLoading}
disabled={canEdit}
form="hook-form-update-server-traefik-config"
type="submit"
>
Update
</Button>
</DialogFooter>
</Form>
</DialogContent>
</Dialog>
);
};
2 changes: 1 addition & 1 deletion apps/dokploy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dokploy",
"version": "v0.7.0",
"version": "v0.7.1",
"private": true,
"license": "Apache-2.0",
"type": "module",
Expand Down
Binary file added apps/dokploy/public/templates/soketi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 15 additions & 6 deletions apps/dokploy/server/api/routers/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,23 @@ export const clusterRouter = createTRPCRouter({
}),
addWorker: protectedProcedure.query(async ({ input }) => {
const result = await docker.swarmInspect();
return `docker swarm join --token ${
result.JoinTokens.Worker
} ${await getPublicIpWithFallback()}:2377`;
const docker_version = await docker.version();

return {
command: `docker swarm join --token ${
result.JoinTokens.Worker
} ${await getPublicIpWithFallback()}:2377`,
version: docker_version.Version,
};
}),
addManager: protectedProcedure.query(async ({ input }) => {
const result = await docker.swarmInspect();
return `docker swarm join --token ${
result.JoinTokens.Manager
} ${await getPublicIpWithFallback()}:2377`;
const docker_version = await docker.version();
return {
command: `docker swarm join --token ${
result.JoinTokens.Manager
} ${await getPublicIpWithFallback()}:2377`,
version: docker_version.Version,
};
}),
});
Loading

0 comments on commit d5c6a60

Please sign in to comment.