mirror of
				https://github.com/kyantech/Palmr.git
				synced 2025-11-03 21:43:20 +00:00 
			
		
		
		
	feat: enhance Docker setup for local filesystem storage
Update Dockerfile and docker-compose.yaml to support local filesystem storage for uploads and temporary files. Add necessary directories and permissions in the Dockerfile, and configure volumes in docker-compose for persistent storage. Modify .dockerignore to exclude runtime-generated storage directories, ensuring a cleaner build environment.
This commit is contained in:
		@@ -60,6 +60,12 @@ jspm_packages/
 | 
			
		||||
Dockerfile*
 | 
			
		||||
docker-compose*
 | 
			
		||||
 | 
			
		||||
# Storage directories (created at runtime)
 | 
			
		||||
uploads/
 | 
			
		||||
temp-chunks/
 | 
			
		||||
apps/server/uploads/
 | 
			
		||||
apps/server/temp-chunks/
 | 
			
		||||
 | 
			
		||||
# OS generated files
 | 
			
		||||
.DS_Store
 | 
			
		||||
.DS_Store?
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -77,7 +77,9 @@ RUN addgroup --system --gid 1001 nodejs
 | 
			
		||||
RUN adduser --system --uid 1001 palmr
 | 
			
		||||
 | 
			
		||||
# Create application directories and set permissions
 | 
			
		||||
RUN mkdir -p /app/server /app/web /home/palmr/.npm /home/palmr/.cache
 | 
			
		||||
# Include storage directories for filesystem mode
 | 
			
		||||
RUN mkdir -p /app/server /app/web /home/palmr/.npm /home/palmr/.cache \
 | 
			
		||||
  /app/server/uploads /app/server/temp-chunks /app/server/uploads/logo
 | 
			
		||||
RUN chown -R palmr:nodejs /app /home/palmr
 | 
			
		||||
 | 
			
		||||
# === Copy Server Files ===
 | 
			
		||||
@@ -89,6 +91,9 @@ COPY --from=server-builder --chown=palmr:nodejs /app/server/node_modules ./node_
 | 
			
		||||
COPY --from=server-builder --chown=palmr:nodejs /app/server/prisma ./prisma
 | 
			
		||||
COPY --from=server-builder --chown=palmr:nodejs /app/server/package.json ./
 | 
			
		||||
 | 
			
		||||
# Ensure storage directories have correct permissions
 | 
			
		||||
RUN chown -R palmr:nodejs /app/server/uploads /app/server/temp-chunks
 | 
			
		||||
 | 
			
		||||
# === Copy Web Files ===
 | 
			
		||||
WORKDIR /app/web
 | 
			
		||||
 | 
			
		||||
@@ -124,7 +129,7 @@ autostart=true
 | 
			
		||||
autorestart=true
 | 
			
		||||
stderr_logfile=/var/log/supervisor/server.err.log
 | 
			
		||||
stdout_logfile=/var/log/supervisor/server.out.log
 | 
			
		||||
environment=PORT=3333,HOME="/home/palmr"
 | 
			
		||||
environment=PORT=3333,HOME="/home/palmr",ENABLE_S3="false",ENCRYPTION_KEY="default-key-change-in-production"
 | 
			
		||||
 | 
			
		||||
[program:web]
 | 
			
		||||
command=node server.js
 | 
			
		||||
@@ -142,6 +147,11 @@ COPY <<EOF /app/start.sh
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
echo "Starting Palmr Application..."
 | 
			
		||||
echo "Storage Mode: \${ENABLE_S3:-false}"
 | 
			
		||||
 | 
			
		||||
# Ensure storage directories exist with correct permissions
 | 
			
		||||
mkdir -p /app/server/uploads /app/server/temp-chunks /app/server/uploads/logo
 | 
			
		||||
chown -R palmr:nodejs /app/server/uploads /app/server/temp-chunks
 | 
			
		||||
 | 
			
		||||
# Start supervisor
 | 
			
		||||
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
 | 
			
		||||
@@ -149,6 +159,9 @@ EOF
 | 
			
		||||
 | 
			
		||||
RUN chmod +x /app/start.sh
 | 
			
		||||
 | 
			
		||||
# Create volume mount points for persistent storage (filesystem mode)
 | 
			
		||||
VOLUME ["/app/server/uploads", "/app/server/temp-chunks"]
 | 
			
		||||
 | 
			
		||||
# Expose ports
 | 
			
		||||
EXPOSE 3333 5487
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,19 +5,31 @@ services:
 | 
			
		||||
    depends_on:
 | 
			
		||||
      postgres:
 | 
			
		||||
        condition: "service_healthy"
 | 
			
		||||
      minio:
 | 
			
		||||
        condition: "service_healthy"
 | 
			
		||||
    environment:
 | 
			
		||||
      # Storage Configuration
 | 
			
		||||
      - ENABLE_S3=${ENABLE_S3:-false} # Set to 'false' to use local filesystem storage instead of S3/MinIO or true to use S3/MinIO
 | 
			
		||||
      - ENCRYPTION_KEY=${ENCRYPTION_KEY:-change-this-key-in-production-min-32-chars} # Required for filesystem encryption (min 32 chars)
 | 
			
		||||
      
 | 
			
		||||
      # Server environment variables
 | 
			
		||||
      - PORT=${API_INTERNAL_PORT:-3333} # Port for the backend service
 | 
			
		||||
      - DATABASE_URL=postgresql://postgres:${POSTGRESQL_PASSWORD:-postgresRootPassword}@postgres:5432/palmr_db?schema=public # Database URL with configurable password through POSTGRESQL_PASSWORD env var
 | 
			
		||||
      - MINIO_ENDPOINT=${MINIO_ENDPOINT:-minio} # This can change if your MinIO is at a different address
 | 
			
		||||
      - MINIO_PORT=${MINIO_INTERNAL_API_PORT:-6421} # Default MinIO port (Change if yours is not the default)
 | 
			
		||||
      - MINIO_USE_SSL=false # MinIO uses SSL by default, but you can change it to true if needed
 | 
			
		||||
      - MINIO_ROOT_USER=${MINIO_ROOT_USER:-minio_root_user} # MinIO credentials can be configured through MINIO_ROOT_USER env vars
 | 
			
		||||
      - MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-minioRootPassword} # MinIO credentials can be configured through MINIO_ROOT_PASSWORD env vars
 | 
			
		||||
      - MINIO_REGION=sa-east-1 # MinIO region - This is needed for MinIO to work properly
 | 
			
		||||
      - MINIO_BUCKET_NAME=files # MinIO bucket name - This is needed for MinIO to work properly, dont change it if you don't know what you are doing
 | 
			
		||||
      
 | 
			
		||||
      # S3/MinIO Configuration (only used when ENABLE_S3=true)
 | 
			
		||||
      # - S3_ENDPOINT=localhost
 | 
			
		||||
      # - S3_PORT=9000
 | 
			
		||||
      # - S3_USE_SSL=false
 | 
			
		||||
      # - S3_ACCESS_KEY=K0l63C4OVEMwhmudABZF
 | 
			
		||||
      # - S3_SECRET_KEY=9xMHpE9QgAye17abq7Lf6qzkCtDMEZeIjMNXt1x7
 | 
			
		||||
      # - S3_REGION=us-east-1
 | 
			
		||||
      # - S3_BUCKET_NAME=palmr-files
 | 
			
		||||
      # - S3_FORCE_PATH_STYLE=true
 | 
			
		||||
 | 
			
		||||
      # Timeout Configuration
 | 
			
		||||
      # - KEEP_ALIVE_TIMEOUT=72000000    # 20 hours in milliseconds
 | 
			
		||||
      # - REQUEST_TIMEOUT=0              # Disabled (0)
 | 
			
		||||
      # - TOKEN_EXPIRATION=3600000       # 1 hour in milliseconds
 | 
			
		||||
      
 | 
			
		||||
      # Application Configuration
 | 
			
		||||
      - FRONTEND_URL=${APP_URL:-http://${SERVER_IP:-localhost}:${APP_EXTERNAL_PORT:-5487}} # Frontend URL - Make sure to use the correct frontend URL, depends on where the frontend is running, its prepared for localhost, but you can change it to your frontend URL if needed
 | 
			
		||||
      - SERVER_IP=${SERVER_IP:-localhost} # Server IP - Make sure to use the correct server IP if you running on a cloud provider or a virtual machine. This prepared for localhost, but you can change it to your server IP if needed
 | 
			
		||||
      - MAX_FILESIZE=${MAX_FILESIZE:-1073741824} # Max Filesize for upload - Declared in Bytes. Default is 1GiB
 | 
			
		||||
@@ -29,6 +41,10 @@ services:
 | 
			
		||||
    ports:
 | 
			
		||||
      - "${API_EXTERNAL_PORT:-3333}:3333"  # Server port
 | 
			
		||||
      - "${APP_EXTERNAL_PORT:-5487}:5487"  # Web port
 | 
			
		||||
    volumes:
 | 
			
		||||
      # Persistent storage for filesystem mode (only used when ENABLE_S3=false)
 | 
			
		||||
      - palmr_uploads:/app/server/uploads
 | 
			
		||||
      - palmr_temp_chunks:/app/server/temp-chunks
 | 
			
		||||
    restart: unless-stopped
 | 
			
		||||
    healthcheck:
 | 
			
		||||
      test: ["CMD", "wget", "--no-verbose", "http://palmr:${API_INTERNAL_PORT:-3333}/health", "&&", "wget", "--no-verbose", "http://palmr:${APP_INTERNAL_PORT:-5487}"]
 | 
			
		||||
@@ -37,42 +53,7 @@ services:
 | 
			
		||||
      retries: 3
 | 
			
		||||
      start_period: 60s
 | 
			
		||||
 | 
			
		||||
  minio:
 | 
			
		||||
    image: minio/minio:RELEASE.2025-03-12T18-04-18Z # Use only version RELEASE.2025-03-12T18-04-18Z to avoid compatibility issues with the backend
 | 
			
		||||
    container_name: minio
 | 
			
		||||
    environment:
 | 
			
		||||
      # MinIO credentials - same as above, configurable through environment variables
 | 
			
		||||
      - MINIO_ROOT_USER=${MINIO_ROOT_USER:-minio_root_user}
 | 
			
		||||
      - MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-minioRootPassword}
 | 
			
		||||
      - MINIO_SITE_REGION=sa-east-1
 | 
			
		||||
    command: server /data --address ":${MINIO_INTERNAL_API_PORT:-6421}" --console-address ":${MINIO_INTERNAL_CONSOLE_PORT:-6422}"
 | 
			
		||||
    volumes:
 | 
			
		||||
      - minio_data:/data
 | 
			
		||||
    ports:
 | 
			
		||||
      - "${MINIO_EXTERNAL_API_PORT:-6421}:${MINIO_INTERNAL_API_PORT:-6421}"
 | 
			
		||||
      - "${MINIO_EXTERNAL_CONSOLE_PORT:-6422}:${MINIO_INTERNAL_CONSOLE_PORT:-6422}"
 | 
			
		||||
    restart: unless-stopped
 | 
			
		||||
    healthcheck:
 | 
			
		||||
      test: ["CMD", "curl", "-f", "http://localhost:${MINIO_INTERNAL_API_PORT:-6421}/minio/health/ready"]
 | 
			
		||||
      interval: 10s
 | 
			
		||||
      timeout: 5s
 | 
			
		||||
      retries: 5
 | 
			
		||||
 | 
			
		||||
  minio-init:
 | 
			
		||||
    image: minio/mc:RELEASE.2025-03-12T17-29-24Z # Use only version RELEASE.2025-03-12T17-29-24Z to avoid compatibility issues with the backend and MinIO
 | 
			
		||||
    container_name: minio-init
 | 
			
		||||
    depends_on:
 | 
			
		||||
      minio:
 | 
			
		||||
        condition: "service_healthy"
 | 
			
		||||
    restart: "no"
 | 
			
		||||
    # The entrypoint script will create a bucket called "files" and set it to be publicly readable using the MinIO client (mc).
 | 
			
		||||
    entrypoint: >
 | 
			
		||||
      sh -c "
 | 
			
		||||
        sleep 5 &&
 | 
			
		||||
        mc alias set myminio http://minio:${MINIO_INTERNAL_API_PORT:-6421} ${MINIO_ROOT_USER:-minio_root_user} ${MINIO_ROOT_PASSWORD:-minioRootPassword} &&
 | 
			
		||||
        mc mb myminio/files --ignore-existing &&
 | 
			
		||||
        mc anonymous set download myminio/files
 | 
			
		||||
      "
 | 
			
		||||
 | 
			
		||||
  postgres:
 | 
			
		||||
    image: bitnami/postgresql:17.2.0 # You can use any postgres version you prefer, but remember that some versions might not be compatible
 | 
			
		||||
@@ -95,5 +76,7 @@ services:
 | 
			
		||||
      retries: 5
 | 
			
		||||
 | 
			
		||||
volumes:
 | 
			
		||||
  minio_data:
 | 
			
		||||
  postgres_data: 
 | 
			
		||||
  postgres_data:
 | 
			
		||||
  # Volumes for filesystem storage mode
 | 
			
		||||
  palmr_uploads:
 | 
			
		||||
  palmr_temp_chunks: 
 | 
			
		||||
		Reference in New Issue
	
	Block a user