fix: Resolve Docker temp directory permission issues

- Updated Dockerfile to create local temp directory with proper permissions
- Added volume mount for backend/temp in docker-compose.yml
- Improved temp directory fallback logic with multiple alternatives
- Added unique timestamps to test files to avoid conflicts
- Better logging to identify which temp directory is being used
- Try process.cwd()/temp before falling back to OS temp directory

This should resolve the persistent EACCES permission errors in Docker
containers by ensuring the backend uses a writable temp directory.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-08-19 22:02:45 +02:00
parent 26a86e0746
commit feae9882bc
6 changed files with 380 additions and 14 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"startTime": 1755632885258, "startTime": 1755633733445,
"totalTasks": 1, "totalTasks": 1,
"successfulTasks": 1, "successfulTasks": 1,
"failedTasks": 0, "failedTasks": 0,
+348
View File
@@ -958,5 +958,353 @@
"cpuLoad": 0.16291155133928573, "cpuLoad": 0.16291155133928573,
"platform": "darwin", "platform": "darwin",
"uptime": 4319026 "uptime": 4319026
},
{
"timestamp": 1755632903581,
"memoryTotal": 25769803776,
"memoryUsed": 25694552064,
"memoryFree": 75251712,
"memoryUsagePercent": 99.7079849243164,
"memoryEfficiency": 0.29201507568359375,
"cpuCount": 14,
"cpuLoad": 0.13040597098214285,
"platform": "darwin",
"uptime": 4319056
},
{
"timestamp": 1755632933583,
"memoryTotal": 25769803776,
"memoryUsed": 25345081344,
"memoryFree": 424722432,
"memoryUsagePercent": 98.35186004638672,
"memoryEfficiency": 1.6481399536132812,
"cpuCount": 14,
"cpuLoad": 0.13249860491071427,
"platform": "darwin",
"uptime": 4319086
},
{
"timestamp": 1755632963583,
"memoryTotal": 25769803776,
"memoryUsed": 25497124864,
"memoryFree": 272678912,
"memoryUsagePercent": 98.94186655680338,
"memoryEfficiency": 1.058133443196624,
"cpuCount": 14,
"cpuLoad": 0.15499441964285715,
"platform": "darwin",
"uptime": 4319116
},
{
"timestamp": 1755632993584,
"memoryTotal": 25769803776,
"memoryUsed": 25640550400,
"memoryFree": 129253376,
"memoryUsagePercent": 99.49843088785806,
"memoryEfficiency": 0.5015691121419366,
"cpuCount": 14,
"cpuLoad": 0.17867606026785715,
"platform": "darwin",
"uptime": 4319146
},
{
"timestamp": 1755633023585,
"memoryTotal": 25769803776,
"memoryUsed": 25329664000,
"memoryFree": 440139776,
"memoryUsagePercent": 98.29203287760416,
"memoryEfficiency": 1.7079671223958428,
"cpuCount": 14,
"cpuLoad": 0.15506417410714285,
"platform": "darwin",
"uptime": 4319176
},
{
"timestamp": 1755633053586,
"memoryTotal": 25769803776,
"memoryUsed": 25427017728,
"memoryFree": 342786048,
"memoryUsagePercent": 98.66981506347656,
"memoryEfficiency": 1.3301849365234375,
"cpuCount": 14,
"cpuLoad": 0.13581194196428573,
"platform": "darwin",
"uptime": 4319206
},
{
"timestamp": 1755633083588,
"memoryTotal": 25769803776,
"memoryUsed": 25350651904,
"memoryFree": 419151872,
"memoryUsagePercent": 98.37347666422525,
"memoryEfficiency": 1.626523335774749,
"cpuCount": 14,
"cpuLoad": 0.12785993303571427,
"platform": "darwin",
"uptime": 4319236
},
{
"timestamp": 1755633113588,
"memoryTotal": 25769803776,
"memoryUsed": 25331482624,
"memoryFree": 438321152,
"memoryUsagePercent": 98.29909006754556,
"memoryEfficiency": 1.7009099324544366,
"cpuCount": 14,
"cpuLoad": 0.13274274553571427,
"platform": "darwin",
"uptime": 4319266
},
{
"timestamp": 1755633143589,
"memoryTotal": 25769803776,
"memoryUsed": 25370427392,
"memoryFree": 399376384,
"memoryUsagePercent": 98.45021565755209,
"memoryEfficiency": 1.5497843424479072,
"cpuCount": 14,
"cpuLoad": 0.11261858258928571,
"platform": "darwin",
"uptime": 4319296
},
{
"timestamp": 1755633173591,
"memoryTotal": 25769803776,
"memoryUsed": 25557172224,
"memoryFree": 212631552,
"memoryUsagePercent": 99.17488098144531,
"memoryEfficiency": 0.8251190185546875,
"cpuCount": 14,
"cpuLoad": 0.14198521205357142,
"platform": "darwin",
"uptime": 4319326
},
{
"timestamp": 1755633203591,
"memoryTotal": 25769803776,
"memoryUsed": 25592725504,
"memoryFree": 177078272,
"memoryUsagePercent": 99.31284586588541,
"memoryEfficiency": 0.6871541341145928,
"cpuCount": 14,
"cpuLoad": 0.12465122767857142,
"platform": "darwin",
"uptime": 4319356
},
{
"timestamp": 1755633233592,
"memoryTotal": 25769803776,
"memoryUsed": 25635733504,
"memoryFree": 134070272,
"memoryUsagePercent": 99.4797388712565,
"memoryEfficiency": 0.5202611287434991,
"cpuCount": 14,
"cpuLoad": 0.117431640625,
"platform": "darwin",
"uptime": 4319386
},
{
"timestamp": 1755633263592,
"memoryTotal": 25769803776,
"memoryUsed": 25571426304,
"memoryFree": 198377472,
"memoryUsagePercent": 99.23019409179688,
"memoryEfficiency": 0.769805908203125,
"cpuCount": 14,
"cpuLoad": 0.16399274553571427,
"platform": "darwin",
"uptime": 4319416
},
{
"timestamp": 1755633293594,
"memoryTotal": 25769803776,
"memoryUsed": 25405407232,
"memoryFree": 364396544,
"memoryUsagePercent": 98.58595530192056,
"memoryEfficiency": 1.4140446980794366,
"cpuCount": 14,
"cpuLoad": 0.15984235491071427,
"platform": "darwin",
"uptime": 4319446
},
{
"timestamp": 1755633323595,
"memoryTotal": 25769803776,
"memoryUsed": 25420562432,
"memoryFree": 349241344,
"memoryUsagePercent": 98.64476521809897,
"memoryEfficiency": 1.3552347819010322,
"cpuCount": 14,
"cpuLoad": 0.14934430803571427,
"platform": "darwin",
"uptime": 4319476
},
{
"timestamp": 1755633353596,
"memoryTotal": 25769803776,
"memoryUsed": 25585844224,
"memoryFree": 183959552,
"memoryUsagePercent": 99.28614298502603,
"memoryEfficiency": 0.7138570149739678,
"cpuCount": 14,
"cpuLoad": 0.13766043526785715,
"platform": "darwin",
"uptime": 4319506
},
{
"timestamp": 1755633383596,
"memoryTotal": 25769803776,
"memoryUsed": 25560023040,
"memoryFree": 209780736,
"memoryUsagePercent": 99.18594360351562,
"memoryEfficiency": 0.814056396484375,
"cpuCount": 14,
"cpuLoad": 0.11310686383928571,
"platform": "darwin",
"uptime": 4319536
},
{
"timestamp": 1755633413597,
"memoryTotal": 25769803776,
"memoryUsed": 25478365184,
"memoryFree": 291438592,
"memoryUsagePercent": 98.86906941731772,
"memoryEfficiency": 1.1309305826822822,
"cpuCount": 14,
"cpuLoad": 0.10989815848214286,
"platform": "darwin",
"uptime": 4319566
},
{
"timestamp": 1755633443598,
"memoryTotal": 25769803776,
"memoryUsed": 25289998336,
"memoryFree": 479805440,
"memoryUsagePercent": 98.13810984293619,
"memoryEfficiency": 1.8618901570638116,
"cpuCount": 14,
"cpuLoad": 0.10951450892857142,
"platform": "darwin",
"uptime": 4319596
},
{
"timestamp": 1755633473599,
"memoryTotal": 25769803776,
"memoryUsed": 25416122368,
"memoryFree": 353681408,
"memoryUsagePercent": 98.62753550211588,
"memoryEfficiency": 1.372464497884124,
"cpuCount": 14,
"cpuLoad": 0.13804408482142858,
"platform": "darwin",
"uptime": 4319626
},
{
"timestamp": 1755633503600,
"memoryTotal": 25769803776,
"memoryUsed": 25099206656,
"memoryFree": 670597120,
"memoryUsagePercent": 97.39774068196616,
"memoryEfficiency": 2.6022593180338447,
"cpuCount": 14,
"cpuLoad": 0.24309430803571427,
"platform": "darwin",
"uptime": 4319656
},
{
"timestamp": 1755633533602,
"memoryTotal": 25769803776,
"memoryUsed": 25252151296,
"memoryFree": 517652480,
"memoryUsagePercent": 97.99124399820963,
"memoryEfficiency": 2.008756001790374,
"cpuCount": 14,
"cpuLoad": 0.29966517857142855,
"platform": "darwin",
"uptime": 4319686
},
{
"timestamp": 1755633563604,
"memoryTotal": 25769803776,
"memoryUsed": 25273630720,
"memoryFree": 496173056,
"memoryUsagePercent": 98.07459513346353,
"memoryEfficiency": 1.9254048665364678,
"cpuCount": 14,
"cpuLoad": 0.5189383370535714,
"platform": "darwin",
"uptime": 4319716
},
{
"timestamp": 1755633593613,
"memoryTotal": 25769803776,
"memoryUsed": 24824987648,
"memoryFree": 944816128,
"memoryUsagePercent": 96.33363087972006,
"memoryEfficiency": 3.6663691202799384,
"cpuCount": 14,
"cpuLoad": 0.41158621651785715,
"platform": "darwin",
"uptime": 4319746
},
{
"timestamp": 1755633623615,
"memoryTotal": 25769803776,
"memoryUsed": 25673220096,
"memoryFree": 96583680,
"memoryUsagePercent": 99.62520599365234,
"memoryEfficiency": 0.37479400634765625,
"cpuCount": 14,
"cpuLoad": 0.38009207589285715,
"platform": "darwin",
"uptime": 4319776
},
{
"timestamp": 1755633653615,
"memoryTotal": 25769803776,
"memoryUsed": 25653559296,
"memoryFree": 116244480,
"memoryUsagePercent": 99.54891204833984,
"memoryEfficiency": 0.45108795166015625,
"cpuCount": 14,
"cpuLoad": 0.31424386160714285,
"platform": "darwin",
"uptime": 4319806
},
{
"timestamp": 1755633683616,
"memoryTotal": 25769803776,
"memoryUsed": 25560743936,
"memoryFree": 209059840,
"memoryUsagePercent": 99.18874104817709,
"memoryEfficiency": 0.8112589518229072,
"cpuCount": 14,
"cpuLoad": 0.25638253348214285,
"platform": "darwin",
"uptime": 4319836
},
{
"timestamp": 1755633713618,
"memoryTotal": 25769803776,
"memoryUsed": 25490276352,
"memoryFree": 279527424,
"memoryUsagePercent": 98.91529083251953,
"memoryEfficiency": 1.0847091674804688,
"cpuCount": 14,
"cpuLoad": 0.22593470982142858,
"platform": "darwin",
"uptime": 4319866
},
{
"timestamp": 1755633743619,
"memoryTotal": 25769803776,
"memoryUsed": 25497960448,
"memoryFree": 271843328,
"memoryUsagePercent": 98.94510904947916,
"memoryEfficiency": 1.0548909505208428,
"cpuCount": 14,
"cpuLoad": 0.21334402901785715,
"platform": "darwin",
"uptime": 4319896
} }
] ]
+3 -3
View File
@@ -1,10 +1,10 @@
[ [
{ {
"id": "cmd-hooks-1755632885292", "id": "cmd-hooks-1755633733484",
"type": "hooks", "type": "hooks",
"success": true, "success": true,
"duration": 4.192417000000006, "duration": 4.695624999999993,
"timestamp": 1755632885296, "timestamp": 1755633733488,
"metadata": {} "metadata": {}
} }
] ]
+21 -5
View File
@@ -23,20 +23,36 @@ class MinIOService {
try { try {
await fs.mkdir(this.tempDir, { recursive: true, mode: 0o755 }); await fs.mkdir(this.tempDir, { recursive: true, mode: 0o755 });
// Test write permissions // Test write permissions
const testFile = path.join(this.tempDir, '.write-test'); const testFile = path.join(this.tempDir, `.write-test-${Date.now()}`);
await fs.writeFile(testFile, 'test'); await fs.writeFile(testFile, 'test');
await fs.unlink(testFile); await fs.unlink(testFile);
logger.info(`Using temp directory: ${this.tempDir}`);
// Clean up old temp files (older than 1 hour) // Clean up old temp files (older than 1 hour)
this.cleanupTempFiles(); this.cleanupTempFiles();
} catch (error) { } catch (error) {
logger.error('Failed to create or write to temp directory:', error); logger.error(`Failed to create or write to temp directory ${this.tempDir}:`, error);
// Fallback to node's temp directory // Try alternative local temp directory
const alternativeTempDir = path.join(process.cwd(), 'temp');
try {
await fs.mkdir(alternativeTempDir, { recursive: true, mode: 0o755 });
const testFile = path.join(alternativeTempDir, `.write-test-${Date.now()}`);
await fs.writeFile(testFile, 'test');
await fs.unlink(testFile);
this.tempDir = alternativeTempDir;
logger.info(`Using alternative temp directory: ${this.tempDir}`);
} catch (altError) {
logger.error('Failed to use alternative temp directory:', altError);
// Last resort: use OS temp directory
this.tempDir = path.join(os.tmpdir(), 'minio-webui-temp'); this.tempDir = path.join(os.tmpdir(), 'minio-webui-temp');
try { try {
await fs.mkdir(this.tempDir, { recursive: true, mode: 0o755 }); await fs.mkdir(this.tempDir, { recursive: true, mode: 0o755 });
logger.info(`Using fallback temp directory: ${this.tempDir}`); logger.warn(`Using OS temp directory (may have permission issues): ${this.tempDir}`);
} catch (fallbackError) { } catch (fallbackError) {
logger.error('Failed to create fallback temp directory:', fallbackError); logger.error('Failed to create OS temp directory:', fallbackError);
// Use current directory as last resort
this.tempDir = path.join(process.cwd(), '.temp');
logger.error(`Using current directory for temp files: ${this.tempDir}`);
}
} }
} }
} }
+1
View File
@@ -15,6 +15,7 @@ services:
- "${PORT:-7510}:${PORT:-7510}" - "${PORT:-7510}:${PORT:-7510}"
volumes: volumes:
- ./logs:/app/logs - ./logs:/app/logs
- ./backend/temp:/app/temp:rw
- ~/.mc:/home/nodejs/.mc:ro - ~/.mc:/home/nodejs/.mc:ro
depends_on: depends_on:
- redis - redis
+3 -2
View File
@@ -30,10 +30,11 @@ RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 adduser -S nodejs -u 1001
# Create necessary directories with proper permissions # Create necessary directories with proper permissions
RUN mkdir -p logs /tmp/minio-webui-temp && \ RUN mkdir -p logs temp /tmp/minio-webui-temp && \
chown -R nodejs:nodejs /app && \ chown -R nodejs:nodejs /app && \
chown nodejs:nodejs /tmp/minio-webui-temp && \ chown nodejs:nodejs /tmp/minio-webui-temp && \
chmod 755 logs /tmp/minio-webui-temp chmod 755 logs temp /tmp/minio-webui-temp && \
chmod 755 /app/temp
# Switch to non-root user # Switch to non-root user
USER nodejs USER nodejs