Skip to content

Commit 486b680

Browse files
committed
Create logs folder and give access to the folder after the user creation
1 parent 1073586 commit 486b680

File tree

4 files changed

+1083
-5
lines changed

4 files changed

+1083
-5
lines changed

backend/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ RUN npm ci --only=production
4848
# Copy built files from builder
4949
COPY --from=builder /app/dist ./dist
5050

51-
# Create logs directory for import logs
52-
RUN mkdir -p /app/logs/imports
53-
5451
# Create non-root user for security
5552
RUN addgroup -g 1001 -S nodejs && \
5653
adduser -S nodejs -u 1001 && \
5754
chown -R nodejs:nodejs /app
5855

56+
# Create logs directory at root (outside /app) and assign to nodejs user
57+
RUN mkdir -p /logs/imports && \
58+
chown -R nodejs:nodejs /logs
59+
5960
USER nodejs
6061

6162
# Expose port

backend/src/services/csv-import.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import ImportLog, { IImportLogEntry } from '../models/ImportLog';
88
import { discogsService, FoundAlbumInfo } from './discogs.service';
99

1010
// Ensure logs directory exists
11-
const LOGS_DIR = path.join(__dirname, '../../logs/imports');
11+
// Use absolute path /logs/imports in Docker, or fallback to relative path for local dev
12+
const LOGS_DIR = process.env.NODE_ENV === 'production'
13+
? '/logs/imports'
14+
: path.join(__dirname, '../../logs/imports');
1215
if (!fs.existsSync(LOGS_DIR)) {
1316
fs.mkdirSync(LOGS_DIR, { recursive: true });
1417
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ services:
3939
mongodb:
4040
condition: service_healthy
4141
volumes:
42-
- import_logs:/app/logs
42+
- import_logs:/logs
4343
networks:
4444
- musivault-network
4545
healthcheck:

0 commit comments

Comments
 (0)