mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Merge pull request #396 from Dokploy/389-is-the-traefik-env-non-persistent
fix(traefik): make env be persistent between restarts
This commit is contained in:
@@ -132,7 +132,7 @@ TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_HTTP_CHALLENGE_DNS_PROVIDER=cloudflare
|
|||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button
|
<Button
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
disabled={canEdit}
|
disabled={canEdit || isLoading}
|
||||||
form="hook-form-update-server-traefik-config"
|
form="hook-form-update-server-traefik-config"
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { chmodSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
import { chmodSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import type { CreateServiceOptions } from "dockerode";
|
import type { ContainerTaskSpec, CreateServiceOptions } from "dockerode";
|
||||||
import { dump } from "js-yaml";
|
import { dump } from "js-yaml";
|
||||||
import { DYNAMIC_TRAEFIK_PATH, MAIN_TRAEFIK_PATH, docker } from "../constants";
|
import { DYNAMIC_TRAEFIK_PATH, MAIN_TRAEFIK_PATH, docker } from "../constants";
|
||||||
import { pullImage } from "../utils/docker/utils";
|
import { pullImage } from "../utils/docker/utils";
|
||||||
@@ -18,7 +18,7 @@ interface TraefikOptions {
|
|||||||
|
|
||||||
export const initializeTraefik = async ({
|
export const initializeTraefik = async ({
|
||||||
enableDashboard = false,
|
enableDashboard = false,
|
||||||
env = [],
|
env,
|
||||||
}: TraefikOptions = {}) => {
|
}: TraefikOptions = {}) => {
|
||||||
const imageName = "traefik:v2.5";
|
const imageName = "traefik:v2.5";
|
||||||
const containerName = "dokploy-traefik";
|
const containerName = "dokploy-traefik";
|
||||||
@@ -85,9 +85,23 @@ export const initializeTraefik = async ({
|
|||||||
|
|
||||||
const service = docker.getService(containerName);
|
const service = docker.getService(containerName);
|
||||||
const inspect = await service.inspect();
|
const inspect = await service.inspect();
|
||||||
|
|
||||||
|
const existingEnv = inspect.Spec.TaskTemplate.ContainerSpec.Env || [];
|
||||||
|
const updatedEnv = !env ? existingEnv : env;
|
||||||
|
|
||||||
|
const updatedSettings = {
|
||||||
|
...settings,
|
||||||
|
TaskTemplate: {
|
||||||
|
...settings.TaskTemplate,
|
||||||
|
ContainerSpec: {
|
||||||
|
...(settings?.TaskTemplate as ContainerTaskSpec).ContainerSpec,
|
||||||
|
Env: updatedEnv,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
await service.update({
|
await service.update({
|
||||||
version: Number.parseInt(inspect.Version.Index),
|
version: Number.parseInt(inspect.Version.Index),
|
||||||
...settings,
|
...updatedSettings,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Traefik Started ✅");
|
console.log("Traefik Started ✅");
|
||||||
|
|||||||
Reference in New Issue
Block a user