- Create MapRoute database records for all GPX files for map visualization - Populate route statistics (distance, elevation, coordinates) from GPX parsing - Update GPX file statistics to mirror MapRoute data for post detail pages - Enable /community/api/routes endpoint to return proper route data for map iframe - Fix post detail page GPX statistics display This resolves the issue where the community map showed '2 routes discovered' but routes weren't actually rendering on the Leaflet.js map visualization. Changes: - Dockerfile: Updated init script paths and added migrate-db call - app/__init__.py: Added admin user auto-creation with error handling - app/routes/community.py: Added debug logging and API route for map data - docker-compose.yml: Simplified to use .env for environment variables - run.py: Added comprehensive database schema migration command
50 lines
1.5 KiB
Docker
50 lines
1.5 KiB
Docker
|
|
FROM python:3.11-slim
|
|
|
|
# Set working directory for the app
|
|
WORKDIR /opt/moto_site
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
gcc \
|
|
postgresql-client \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements and install Python dependencies
|
|
COPY requirements.txt ./
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy all application code to /opt/moto_site
|
|
COPY . .
|
|
|
|
# Create uploads directory
|
|
RUN mkdir -p uploads/images uploads/gpx
|
|
|
|
# Set FLASK_APP so Flask CLI commands are available
|
|
ENV FLASK_APP=run.py
|
|
|
|
# Create a script to conditionally initialize database
|
|
RUN echo '#!/bin/sh\n\
|
|
if [ ! -f /opt/moto_site/data/moto_adventure.db ]; then\n\
|
|
echo "Database not found, initializing..."\n\
|
|
flask --app run.py init-db\n\
|
|
flask --app run.py migrate-db\n\
|
|
echo "Database initialized successfully"\n\
|
|
else\n\
|
|
echo "Database exists, running migrations..."\n\
|
|
flask --app run.py migrate-db\n\
|
|
fi' > /opt/moto_site/init_db_if_needed.sh && chmod +x /opt/moto_site/init_db_if_needed.sh
|
|
|
|
# Create non-root user and set permissions
|
|
RUN adduser --disabled-password --gecos '' appuser && \
|
|
chown -R appuser:appuser /opt/moto_site && \
|
|
mkdir -p /data && \
|
|
chown -R appuser:appuser /data
|
|
USER appuser
|
|
|
|
# Expose port
|
|
EXPOSE 5000
|
|
|
|
# Run the application with Gunicorn, looking for run:app in /opt/moto_site
|
|
ENTRYPOINT ["/bin/sh", "-c", "/opt/moto_site/init_db_if_needed.sh && exec gunicorn --bind 0.0.0.0:5000 run:app"]
|