nope
Build and Push Docker Images / build-and-push (push) Successful in 18s

This commit is contained in:
2025-04-30 21:01:06 +02:00
parent ae8044977a
commit c3fd4b3121
2 changed files with 46 additions and 21 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ ENV API_KEY=""
# Create a non-root user and switch to it
RUN useradd -m puppeteer && chown -R puppeteer:puppeteer /app
# Create the database directory and set permissions
RUN mkdir -p /db && chown -R puppeteer:puppeteer /db && chmod 777 /db
RUN mkdir -p /db && chmod 777 /db && chown -R puppeteer:puppeteer /app
USER puppeteer
+29 -4
View File
@@ -23,16 +23,37 @@ CUSTOM_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.3
# Initialize SQLite database
def init_db():
global DB_PATH
# Try to use the mounted volume first
db_path = '/db/cache.db'
db_dir = os.path.dirname(db_path)
# Ensure the directory exists
if not os.path.exists(db_dir):
# Check if directory exists and is writable
dir_writable = False
if os.path.exists(db_dir):
try:
test_file = os.path.join(db_dir, '.write_test')
with open(test_file, 'w') as f:
f.write('test')
os.remove(test_file)
dir_writable = True
except (IOError, PermissionError):
print(f"Directory {db_dir} exists but is not writable")
dir_writable = False
# If directory doesn't exist or isn't writable, try to create it
if not os.path.exists(db_dir) or not dir_writable:
try:
os.makedirs(db_dir, exist_ok=True)
# Test if we can write to the directory
test_file = os.path.join(db_dir, '.write_test')
with open(test_file, 'w') as f:
f.write('test')
os.remove(test_file)
print(f"Created directory: {db_dir}")
dir_writable = True
except Exception as e:
print(f"Warning: Could not create directory {db_dir}: {e}")
print(f"Warning: Could not create or write to directory {db_dir}: {e}")
# Fallback to using a local database file
db_path = 'cache.db'
print(f"Using local database file: {db_path}")
@@ -55,10 +76,11 @@ def init_db():
# Update the global DB_PATH
DB_PATH = db_path
except sqlite3.OperationalError as e:
print(f"Error initializing database: {e}")
print(f"Error initializing database at {db_path}: {e}")
# Fallback to using a local database file if the mounted volume has permission issues
db_path = 'cache.db'
print(f"Falling back to local database file: {db_path}")
try:
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute('''
@@ -75,6 +97,9 @@ def init_db():
print(f"Local database initialized at {db_path}")
# Update the global DB_PATH
DB_PATH = db_path
except sqlite3.OperationalError as e2:
print(f"Error initializing local database: {e2}")
raise
# Define the database path
DB_PATH = '/db/cache.db'