Skip to content

Commit

Permalink
feat(#130): allow to pass enviroment variables to assign custom port …
Browse files Browse the repository at this point in the history
…on traefik
  • Loading branch information
Siumauricio committed Jun 8, 2024
1 parent 3dcd89c commit 4e3aaa2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions server/setup/traefik-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import type { MainTraefikConfig } from "../utils/traefik/types";
import type { FileConfig } from "../utils/traefik/file-types";
import type { CreateServiceOptions } from "dockerode";

const TRAEFIK_SSL_PORT =
Number.parseInt(process.env.TRAEFIK_SSL_PORT ?? "", 10) || 443;
const TRAEFIK_PORT = Number.parseInt(process.env.TRAEFIK_PORT ?? "", 10) || 80;

export const initializeTraefik = async () => {
const imageName = "traefik:v2.5";
const containerName = "dokploy-traefik";
Expand Down Expand Up @@ -47,12 +51,12 @@ export const initializeTraefik = async () => {
Ports: [
{
TargetPort: 443,
PublishedPort: 443,
PublishedPort: TRAEFIK_SSL_PORT,
PublishMode: "host",
},
{
TargetPort: 80,
PublishedPort: 80,
PublishedPort: TRAEFIK_PORT,
PublishMode: "host",
},
{
Expand Down Expand Up @@ -146,10 +150,10 @@ export const createDefaultTraefikConfig = () => {
},
entryPoints: {
web: {
address: ":80",
address: `:${TRAEFIK_PORT}`,
},
websecure: {
address: ":443",
address: `:${TRAEFIK_SSL_PORT}`,
...(process.env.NODE_ENV === "production" && {
http: {
tls: {
Expand Down

0 comments on commit 4e3aaa2

Please sign in to comment.