Skip to content

Commit

Permalink
Merge pull request #67 from manjime83/patch-1
Browse files Browse the repository at this point in the history
fix: Properly parse environment variables
  • Loading branch information
Siumauricio authored May 9, 2024
2 parents 9ba09de + a83834f commit 9554818
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions server/utils/docker/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { APPLICATIONS_PATH, docker } from "@/server/constants";
import type { ContainerInfo, ResourceRequirements } from "dockerode";
import type { ApplicationNested } from "../builders";
import { execAsync } from "../process/execAsync";
import { parse } from "dotenv";

interface RegistryAuth {
username: string;
Expand Down Expand Up @@ -154,15 +155,7 @@ export const removeService = async (appName: string) => {
};

export const prepareEnvironmentVariables = (env: string | null) =>
env
?.split("\n")
.map((line) => line.trim()) // Trim whitespace
.filter((line) => line && !line.startsWith("#")) // Exclude empty lines and comments
.map((envVar) => {
let [key, value] = envVar.split("=", 2);
value = value?.replace(/^"(.*)"$/, "$1"); // Remove surrounding double quotes
return `${key}=${value}`;
}) || [];
Object.entries(parse(env ?? "")).map(([key, value]) => `${key}=${value}`);

export const generateVolumeMounts = (mounts: ApplicationNested["mounts"]) => {
if (!mounts || mounts.length === 0) {
Expand Down

0 comments on commit 9554818

Please sign in to comment.