Antoni09 commited on
Commit
f2eb662
·
verified ·
1 Parent(s): 42b3b59

Create entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +25 -0
entrypoint.sh ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ mkdir -p /data
5
+
6
+ : "${DATABASE_URL:?ERROR: DATABASE_URL is not set}"
7
+
8
+ python - <<'PY'
9
+ import os
10
+ from sqlalchemy import create_engine, text
11
+ engine = create_engine(os.environ["DATABASE_URL"], pool_pre_ping=True)
12
+ with engine.begin() as conn:
13
+ conn.execute(text("""
14
+ CREATE TABLE IF NOT EXISTS notes (
15
+ id SERIAL PRIMARY KEY,
16
+ body TEXT NOT NULL,
17
+ created_at TIMESTAMPTZ DEFAULT now()
18
+ )
19
+ """))
20
+ PY
21
+
22
+ # Jeśli masz FastAPI z plikiem app.py (app = FastAPI()):
23
+ exec uvicorn app:app --host 0.0.0.0 --port 7860
24
+ # Jeśli masz inny serwer (np. server.py), zamień powyższą linię na:
25
+ # exec python server.py