dank-ai 1.0.49 → 1.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/docker/manager.js +38 -1
- package/package.json +1 -1
package/lib/docker/manager.js
CHANGED
|
@@ -1925,6 +1925,29 @@ class DockerManager {
|
|
|
1925
1925
|
ignorePatterns = await this.readDankIgnore(projectDir);
|
|
1926
1926
|
}
|
|
1927
1927
|
|
|
1928
|
+
// Explicitly copy .env file from project root if it exists
|
|
1929
|
+
// This ensures .env is available at runtime even if it's filtered by .dankignore
|
|
1930
|
+
// We copy to context root (not agent-code/) so it ends up at /app/.env where dotenv.config() looks
|
|
1931
|
+
const envFilePath = path.join(projectRoot, '.env');
|
|
1932
|
+
this.logger.info(`🔍 Checking for .env file at: ${envFilePath}`);
|
|
1933
|
+
|
|
1934
|
+
if (await fs.pathExists(envFilePath)) {
|
|
1935
|
+
this.logger.info(`✅ .env file found at project root`);
|
|
1936
|
+
const shouldIgnore = this.shouldIgnoreFile(envFilePath, projectRoot, ignorePatterns);
|
|
1937
|
+
|
|
1938
|
+
if (!shouldIgnore) {
|
|
1939
|
+
const destPath = path.join(contextDir, '.env');
|
|
1940
|
+
await fs.copy(envFilePath, destPath);
|
|
1941
|
+
this.logger.info(`📝 Copied .env from project root to context root`);
|
|
1942
|
+
} else {
|
|
1943
|
+
this.logger.info(`⏭️ Skipped .env (matched .dankignore pattern)`);
|
|
1944
|
+
this.logger.info(` To include .env, remove it from .dankignore`);
|
|
1945
|
+
}
|
|
1946
|
+
} else {
|
|
1947
|
+
this.logger.info(`⚠️ .env file not found at project root: ${envFilePath}`);
|
|
1948
|
+
this.logger.info(` Environment variables will not be available at runtime`);
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1928
1951
|
if (ignorePatterns.length > 0) {
|
|
1929
1952
|
this.logger.info(`📋 Using .dankignore with ${ignorePatterns.length} pattern(s)`);
|
|
1930
1953
|
} else {
|
|
@@ -2015,11 +2038,25 @@ WORKDIR /app
|
|
|
2015
2038
|
` : '';
|
|
2016
2039
|
|
|
2017
2040
|
// Create Dockerfile for agent
|
|
2041
|
+
// Copy .env file to /app/ (where entrypoint runs) so dotenv.config() can find it
|
|
2042
|
+
const envFileInContext = path.join(contextDir, '.env');
|
|
2043
|
+
const hasEnvFile = await fs.pathExists(envFileInContext);
|
|
2044
|
+
|
|
2045
|
+
if (hasEnvFile) {
|
|
2046
|
+
this.logger.info(`📝 .env file found in build context, will be copied to /app/.env in container`);
|
|
2047
|
+
} else {
|
|
2048
|
+
this.logger.info(`⚠️ .env file not found in build context, will not be available in container`);
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
const envCopyStep = hasEnvFile
|
|
2052
|
+
? `# Copy .env file to /app/ (where entrypoint runs)\nCOPY .env /app/.env\n`
|
|
2053
|
+
: '';
|
|
2054
|
+
|
|
2018
2055
|
const dockerfile = `FROM ${baseImageName}
|
|
2019
2056
|
${npmInstallStep}
|
|
2020
2057
|
# Copy agent code
|
|
2021
2058
|
COPY agent-code/ /app/agent-code/
|
|
2022
|
-
${envStatements}
|
|
2059
|
+
${envCopyStep}${envStatements}
|
|
2023
2060
|
USER dankuser
|
|
2024
2061
|
`;
|
|
2025
2062
|
|