Fix database directory and add entrypoint script
This commit is contained in:
18
Dockerfile
18
Dockerfile
@@ -6,7 +6,7 @@ ENV PYTHONDONTWRITEBYTECODE=1
|
|||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
ENV FLASK_APP=app.py
|
ENV FLASK_APP=app.py
|
||||||
ENV FLASK_ENV=production
|
ENV FLASK_ENV=production
|
||||||
ENV DATABASE_DIR=/app/data
|
ENV DATABASE_DIR=/opt/apps/audiobook-studio-pro-v3
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -29,23 +29,19 @@ RUN pip install --no-cache-dir --upgrade pip \
|
|||||||
# Copy application code
|
# Copy application code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Create the default database directory inside the container
|
# Create the database directory with full permissions
|
||||||
# This will be used if no volume is mounted
|
|
||||||
RUN mkdir -p /app/data && chmod 777 /app/data
|
|
||||||
|
|
||||||
# Also create the external mount point directory
|
|
||||||
RUN mkdir -p /opt/apps/audiobook-studio-pro-v3 && chmod 777 /opt/apps/audiobook-studio-pro-v3
|
RUN mkdir -p /opt/apps/audiobook-studio-pro-v3 && chmod 777 /opt/apps/audiobook-studio-pro-v3
|
||||||
|
|
||||||
|
# Copy and setup entrypoint script
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 5009
|
EXPOSE 5009
|
||||||
|
|
||||||
# Health check - with longer start period to allow DB initialization
|
# Health check
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
||||||
CMD curl -f http://localhost:5009/health || exit 1
|
CMD curl -f http://localhost:5009/health || exit 1
|
||||||
|
|
||||||
# Use entrypoint script to ensure directory exists
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
|
||||||
RUN chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
CMD ["gunicorn", "--bind", "0.0.0.0:5009", "--workers", "2", "--threads", "4", "--timeout", "300", "--access-logfile", "-", "--error-logfile", "-", "app:app"]
|
CMD ["gunicorn", "--bind", "0.0.0.0:5009", "--workers", "2", "--threads", "4", "--timeout", "300", "--access-logfile", "-", "--error-logfile", "-", "app:app"]
|
||||||
|
|||||||
34
entrypoint.sh
Normal file
34
entrypoint.sh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "🚀 Starting Audiobook Studio Pro V3..."
|
||||||
|
|
||||||
|
# Database directory - fixed location
|
||||||
|
DB_DIR="/opt/apps/audiobook-studio-pro-v3"
|
||||||
|
|
||||||
|
echo "📁 Database directory: $DB_DIR"
|
||||||
|
|
||||||
|
# Create directory if it doesn't exist
|
||||||
|
mkdir -p "$DB_DIR"
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
chmod 755 "$DB_DIR" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Test if we can create a file
|
||||||
|
TEST_FILE="$DB_DIR/.write_test"
|
||||||
|
if touch "$TEST_FILE" 2>/dev/null; then
|
||||||
|
rm -f "$TEST_FILE"
|
||||||
|
echo "✅ Database directory is writable"
|
||||||
|
else
|
||||||
|
echo "❌ ERROR: Cannot write to $DB_DIR"
|
||||||
|
echo "Please ensure the volume is mounted correctly"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "📍 Database will be stored at: $DB_DIR/audio_editor.db"
|
||||||
|
|
||||||
|
# Export for the application
|
||||||
|
export DATABASE_DIR="$DB_DIR"
|
||||||
|
|
||||||
|
# Execute the main command
|
||||||
|
exec "$@"
|
||||||
Reference in New Issue
Block a user