mirror of
https://github.com/sstent/foodplanner.git
synced 2026-03-13 08:45:24 +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 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create a non-root user
|
||||
#RUN groupadd -r appuser && useradd -r -g appuser appuser
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
@@ -40,19 +38,12 @@ COPY --from=builder /app/venv /app/venv
|
||||
# Activate the virtual environment
|
||||
ENV PATH="/app/venv/bin:$PATH"
|
||||
|
||||
# Create data directory and set permissions
|
||||
#RUN mkdir -p /app/data && \
|
||||
# chown -R appuser:appuser /app/data
|
||||
# Create data directory
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
# Copy application code
|
||||
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
|
||||
WORKDIR /app
|
||||
|
||||
@@ -60,10 +51,6 @@ WORKDIR /app
|
||||
ENV DATABASE_PATH=/app/data
|
||||
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 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
|
||||
# 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')
|
||||
|
||||
logging.info(f"Database URL: {DATABASE_URL}")
|
||||
|
||||
Reference in New Issue
Block a user