From dd32ea436b3a01dd8a99f9d535821517c7a591ef Mon Sep 17 00:00:00 2001 From: claimableperch Date: Tue, 29 Oct 2024 14:39:00 +0000 Subject: [PATCH] feat(environment): allow to specify container runtime environment variables --- lib/modules/createConfig.js | 1 + lib/templates/docker-compose.ejs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/modules/createConfig.js b/lib/modules/createConfig.js index 8a5339c..8af2f13 100644 --- a/lib/modules/createConfig.js +++ b/lib/modules/createConfig.js @@ -142,6 +142,7 @@ const createConfig = async (packageDir, hasVolumeSupport = true) => { port: config.port || 80, dbPort: config.dbPort || 3306, volumes: hasVolumeSupport ? volumes : false, + env: config.env || {}, }, ); diff --git a/lib/templates/docker-compose.ejs b/lib/templates/docker-compose.ejs index 80eb3b5..48723ad 100644 --- a/lib/templates/docker-compose.ejs +++ b/lib/templates/docker-compose.ejs @@ -4,6 +4,9 @@ services: depends_on: - db build: . + environment: + CYPRESS_TEST: 1 <% Object.entries( env ).forEach(([n,v]) => { %> + <%= n %> : <%= v %> <% }); %> ports: - <%= port %>:80 <% if (volumes) { %>volumes: <% volumes.forEach((volume) => { %>