mirror of
https://github.com/sstent/foodplanner.git
synced 2026-04-04 12:03:53 +00:00
added alembic database migrations, json import/export
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -28,8 +28,6 @@ FROM python:3.11-slim
|
|||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Create a non-root user
|
|
||||||
#RUN groupadd -r appuser && useradd -r -g appuser appuser
|
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -40,19 +38,12 @@ COPY --from=builder /app/venv /app/venv
|
|||||||
# Activate the virtual environment
|
# Activate the virtual environment
|
||||||
ENV PATH="/app/venv/bin:$PATH"
|
ENV PATH="/app/venv/bin:$PATH"
|
||||||
|
|
||||||
# Create data directory and set permissions
|
# Create data directory
|
||||||
#RUN mkdir -p /app/data && \
|
RUN mkdir -p /app/data
|
||||||
# chown -R appuser:appuser /app/data
|
|
||||||
|
|
||||||
# Copy application code
|
# Copy application code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Ensure appuser owns all files
|
|
||||||
#RUN chown -R appuser:appuser /app
|
|
||||||
|
|
||||||
# Switch to non-root user
|
|
||||||
#USER appuser
|
|
||||||
|
|
||||||
# Set working directory to /app for the application
|
# Set working directory to /app for the application
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -60,10 +51,6 @@ WORKDIR /app
|
|||||||
ENV DATABASE_PATH=/app/data
|
ENV DATABASE_PATH=/app/data
|
||||||
ENV DATABASE_URL=sqlite:////app/data/meal_planner.db
|
ENV DATABASE_URL=sqlite:////app/data/meal_planner.db
|
||||||
|
|
||||||
# Verify directory ownership (for debugging)
|
|
||||||
RUN ls -ld /app/data && \
|
|
||||||
touch /app/data/test_write.txt && \
|
|
||||||
echo "Write test successful" > /app/data/test_write.txt
|
|
||||||
|
|
||||||
# Expose port (as defined in main.py)
|
# Expose port (as defined in main.py)
|
||||||
EXPOSE 8999
|
EXPOSE 8999
|
||||||
|
|||||||
3
main.py
3
main.py
@@ -31,7 +31,8 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(
|
|||||||
|
|
||||||
# Database setup - Use SQLite for easier setup
|
# Database setup - Use SQLite for easier setup
|
||||||
# Use environment variables if set, otherwise use defaults
|
# Use environment variables if set, otherwise use defaults
|
||||||
DATABASE_PATH = os.getenv('DATABASE_PATH', '/app/data')
|
# Use current directory for database
|
||||||
|
DATABASE_PATH = os.getenv('DATABASE_PATH', '.')
|
||||||
DATABASE_URL = os.getenv('DATABASE_URL', f'sqlite:///{DATABASE_PATH}/meal_planner.db')
|
DATABASE_URL = os.getenv('DATABASE_URL', f'sqlite:///{DATABASE_PATH}/meal_planner.db')
|
||||||
|
|
||||||
logging.info(f"Database URL: {DATABASE_URL}")
|
logging.info(f"Database URL: {DATABASE_URL}")
|
||||||
|
|||||||
Reference in New Issue
Block a user