update
This commit is contained in:
parent
12eaeb4351
commit
4bf58513bc
4 changed files with 38 additions and 6 deletions
|
|
@ -18,6 +18,10 @@ COPY --from=builder /usr/local/bin /usr/local/bin
|
||||||
# Copy application code
|
# Copy application code
|
||||||
COPY app ./app
|
COPY app ./app
|
||||||
|
|
||||||
|
# Copy startup script
|
||||||
|
COPY start.sh /app/start.sh
|
||||||
|
RUN chmod +x /app/start.sh
|
||||||
|
|
||||||
# Create data directory for SQLite and other persistent data
|
# Create data directory for SQLite and other persistent data
|
||||||
RUN mkdir -p /app/data
|
RUN mkdir -p /app/data
|
||||||
|
|
||||||
|
|
@ -31,5 +35,5 @@ HEALTHCHECK --interval=10s --timeout=5s --start-period=40s --retries=3 \
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Run with production settings
|
# Run with startup script
|
||||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers", "--forwarded-allow-ips", "*"]
|
CMD ["/app/start.sh"]
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,15 @@ import os
|
||||||
|
|
||||||
from sqlmodel import Session, SQLModel, create_engine # type: ignore
|
from sqlmodel import Session, SQLModel, create_engine # type: ignore
|
||||||
|
|
||||||
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./notes.db")
|
# Get database URL from environment, with proper fallback
|
||||||
|
DATABASE_URL = os.getenv("DATABASE_URL")
|
||||||
|
|
||||||
|
# If DATABASE_URL is not set or empty, use default SQLite
|
||||||
|
if not DATABASE_URL or DATABASE_URL.strip() == "":
|
||||||
|
DATABASE_URL = "sqlite:////app/data/notes.db"
|
||||||
|
print(f"WARNING: DATABASE_URL not set, using default: {DATABASE_URL}")
|
||||||
|
else:
|
||||||
|
print(f"Using DATABASE_URL: {DATABASE_URL}")
|
||||||
|
|
||||||
# Only use check_same_thread for SQLite
|
# Only use check_same_thread for SQLite
|
||||||
connect_args = {"check_same_thread": False} if DATABASE_URL.startswith("sqlite") else {}
|
connect_args = {"check_same_thread": False} if DATABASE_URL.startswith("sqlite") else {}
|
||||||
|
|
|
||||||
21
backend/start.sh
Normal file
21
backend/start.sh
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "========================================="
|
||||||
|
echo "Starting FastNotes API..."
|
||||||
|
echo "========================================="
|
||||||
|
echo "DATABASE_URL: ${DATABASE_URL:-'not set'}"
|
||||||
|
echo "CORS_ORIGINS: ${CORS_ORIGINS:-'not set'}"
|
||||||
|
echo "SECRET_KEY: ${SECRET_KEY:+'***set***'}"
|
||||||
|
echo "Working directory: $(pwd)"
|
||||||
|
echo "Contents of /app:"
|
||||||
|
ls -la /app
|
||||||
|
echo "========================================="
|
||||||
|
|
||||||
|
# Create data directory if it doesn't exist
|
||||||
|
mkdir -p /app/data
|
||||||
|
echo "Created/verified /app/data directory"
|
||||||
|
|
||||||
|
# Start uvicorn
|
||||||
|
echo "Starting uvicorn..."
|
||||||
|
exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --proxy-headers --forwarded-allow-ips "*"
|
||||||
|
|
@ -4,7 +4,7 @@ services:
|
||||||
context: ./backend
|
context: ./backend
|
||||||
container_name: fastnotes-api
|
container_name: fastnotes-api
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL=${DATABASE_URL:-sqlite:///./data/notes.db}
|
- DATABASE_URL=${DATABASE_URL:-sqlite:////app/data/notes.db}
|
||||||
- SECRET_KEY=${SECRET_KEY:-change-this-in-production}
|
- SECRET_KEY=${SECRET_KEY:-change-this-in-production}
|
||||||
- CORS_ORIGINS=${CORS_ORIGINS:-*}
|
- CORS_ORIGINS=${CORS_ORIGINS:-*}
|
||||||
# Internal only - accessed via nginx proxy
|
# Internal only - accessed via nginx proxy
|
||||||
|
|
@ -36,8 +36,7 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
api:
|
- api
|
||||||
condition: service_healthy
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue