This commit is contained in:
@@ -40,7 +40,7 @@ ENV API_KEY=""
|
|||||||
# Create a non-root user and switch to it
|
# Create a non-root user and switch to it
|
||||||
RUN useradd -m puppeteer && chown -R puppeteer:puppeteer /app
|
RUN useradd -m puppeteer && chown -R puppeteer:puppeteer /app
|
||||||
# Create the database directory and set permissions
|
# Create the database directory and set permissions
|
||||||
RUN mkdir -p /db && chown -R puppeteer:puppeteer /db
|
RUN mkdir -p /db && chown -R puppeteer:puppeteer /db && chmod 777 /db
|
||||||
|
|
||||||
USER puppeteer
|
USER puppeteer
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ CUSTOM_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.3
|
|||||||
|
|
||||||
# Initialize SQLite database
|
# Initialize SQLite database
|
||||||
def init_db():
|
def init_db():
|
||||||
|
global DB_PATH
|
||||||
db_path = '/db/cache.db'
|
db_path = '/db/cache.db'
|
||||||
db_dir = os.path.dirname(db_path)
|
db_dir = os.path.dirname(db_path)
|
||||||
|
|
||||||
@@ -51,6 +52,8 @@ def init_db():
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
print(f"Database initialized at {db_path}")
|
print(f"Database initialized at {db_path}")
|
||||||
|
# Update the global DB_PATH
|
||||||
|
DB_PATH = db_path
|
||||||
except sqlite3.OperationalError as e:
|
except sqlite3.OperationalError as e:
|
||||||
print(f"Error initializing database: {e}")
|
print(f"Error initializing database: {e}")
|
||||||
# Fallback to using a local database file if the mounted volume has permission issues
|
# Fallback to using a local database file if the mounted volume has permission issues
|
||||||
@@ -70,10 +73,8 @@ def init_db():
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
print(f"Local database initialized at {db_path}")
|
print(f"Local database initialized at {db_path}")
|
||||||
|
# Update the global DB_PATH
|
||||||
# Update the global DB_PATH
|
DB_PATH = db_path
|
||||||
global DB_PATH
|
|
||||||
DB_PATH = db_path
|
|
||||||
|
|
||||||
# Define the database path
|
# Define the database path
|
||||||
DB_PATH = '/db/cache.db'
|
DB_PATH = '/db/cache.db'
|
||||||
|
|||||||
Reference in New Issue
Block a user