Configurable upload path. (#191)
* Add necessary migrations for project model. * Add a few tests for project model new columns. * make upload location into a configurable * fix uploadDir path * use config in app.js * Change upload env var naming * Add upload env var to Docker files --------- Co-authored-by: antanst <> Co-authored-by: vhsdream <punk.sand7393@fastmail.com>
This commit is contained in:
parent
1e11ab5fa4
commit
4051824e7a
6 changed files with 15 additions and 6 deletions
|
|
@ -70,7 +70,7 @@ COPY --from=builder --chown=app:app /app/node_modules ./node_modules
|
|||
COPY --from=builder --chown=app:app /app/package.json /app/
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p /app/backend/db /app/backend/certs
|
||||
RUN mkdir -p /app/backend/db /app/backend/certs /app/backend/uploads
|
||||
|
||||
# Cleanup
|
||||
RUN apk del --no-cache .runtime-deps sqlite openssl curl && \
|
||||
|
|
@ -79,6 +79,7 @@ RUN apk del --no-cache .runtime-deps sqlite openssl curl && \
|
|||
rm -rf /root/.npm /tmp/* /var/tmp/* /var/cache/apk/*
|
||||
|
||||
VOLUME ["/app/backend/db"]
|
||||
VOLUME ["/app/backend/uploads"]
|
||||
|
||||
EXPOSE 3002
|
||||
|
||||
|
|
@ -91,7 +92,8 @@ ENV NODE_ENV=production \
|
|||
TUDUDI_USER_EMAIL="" \
|
||||
TUDUDI_USER_PASSWORD="" \
|
||||
DISABLE_TELEGRAM=false \
|
||||
DISABLE_SCHEDULER=false
|
||||
DISABLE_SCHEDULER=false \
|
||||
TUDUDI_UPLOAD_PATH="/app/backend/uploads"
|
||||
|
||||
HEALTHCHECK --interval=60s --timeout=3s --start-period=10s --retries=2 \
|
||||
CMD curl -sf http://localhost:3002/api/health || exit 1
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ if (config.production) {
|
|||
}
|
||||
|
||||
// Serve uploaded files
|
||||
app.use('/api/uploads', express.static(path.join(__dirname, 'uploads')));
|
||||
app.use('/api/uploads', express.static(config.uploadPath));
|
||||
|
||||
// Authentication middleware
|
||||
const { requireAuth } = require('./middleware/auth');
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ const config = {
|
|||
|
||||
sslEnabled:
|
||||
production && process.env.TUDUDI_INTERNAL_SSL_ENABLED === 'true',
|
||||
|
||||
uploadPath:
|
||||
process.env.TUDUDI_UPLOAD_PATH || path.join(projectRootPath, 'uploads'),
|
||||
};
|
||||
|
||||
console.log(`Using database file '${config.dbFile}'`);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
const express = require('express');
|
||||
const multer = require('multer');
|
||||
const path = require('path');
|
||||
const { getConfig } = require('../config/config');
|
||||
const config = getConfig();
|
||||
const fs = require('fs');
|
||||
const { Project, Task, Tag, Area, Note, sequelize } = require('../models');
|
||||
const { Op } = require('sequelize');
|
||||
|
|
@ -21,7 +23,7 @@ const formatDate = (date) => {
|
|||
// Configure multer for file uploads
|
||||
const storage = multer.diskStorage({
|
||||
destination: function (req, file, cb) {
|
||||
const uploadDir = path.join(__dirname, '../uploads/projects');
|
||||
const uploadDir = path.join(config.uploadPath, 'projects');
|
||||
if (!fs.existsSync(uploadDir)) {
|
||||
fs.mkdirSync(uploadDir, { recursive: true });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ services:
|
|||
- TUDUDI_SESSION_SECRET=changeme-please-use-openssl
|
||||
- TUDUDI_INTERNAL_SSL_ENABLED=false
|
||||
- TUDUDI_ALLOWED_ORIGINS=http://localhost:3002
|
||||
- TUDUDI_UPLOAD_PATH="/app/backend/uploads"
|
||||
# Runtime UID/GID configuration - set these to match your host user/group
|
||||
- PUID=1001
|
||||
- PGID=1001
|
||||
volumes:
|
||||
- ./tududi_db:/app/backend/db
|
||||
#- ./uploads:/app/backend/uploads
|
||||
ports:
|
||||
- "3002:3002"
|
||||
restart: unless-stopped
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ else
|
|||
fi
|
||||
|
||||
echo "Setting ownership of application directories to $TARGET_USER:$TARGET_GROUP"
|
||||
mkdir -p /app/backend/db /app/backend/certs
|
||||
mkdir -p /app/backend/db /app/backend/certs /app/backend/uploads
|
||||
chown -R "$TARGET_USER":"$TARGET_GROUP" /app/backend /app/scripts
|
||||
chmod 770 /app/backend/db /app/backend/certs
|
||||
chmod 770 /app/backend/db /app/backend/certs /app/backend/uploads
|
||||
set_db_file_permissions
|
||||
|
||||
# Drop privileges and execute the original start script
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue