mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-07 03:59:48 -06:00
- Remove redundant documentation files (DATABASE_INIT_FIX_*.md, TIMEZONE_FIX_README.md) - Delete unused Docker files (Dockerfile.test, Dockerfile.combined, docker-compose.yml) - Remove obsolete deployment scripts (deploy.sh) and unused files (index.html, _config.yml) - Clean up logs directory (remove 2MB timetracker.log, keep .gitkeep) - Remove .pytest_cache directory - Consolidate Docker setup to two main container types: * Simple container (recommended for production) * Public container (for development/testing) - Enhance timezone support in admin settings: * Add 100+ timezone options organized by region * Implement real-time timezone preview with current time display * Add timezone offset calculation and display * Remove search functionality for cleaner interface * Update timezone utility functions for database-driven configuration - Update documentation: * Revise README.md to reflect current project state * Add comprehensive timezone features documentation * Update Docker deployment instructions * Create PROJECT_STRUCTURE.md for project overview * Remove references to deleted files - Improve project structure: * Streamlined file organization * Better maintainability and focus * Preserved all essential functionality * Cleaner deployment options
66 lines
2.2 KiB
Docker
66 lines
2.2 KiB
Docker
FROM python:3.11-slim
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
postgresql \
|
|
postgresql-contrib \
|
|
curl \
|
|
tzdata \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set work directory
|
|
WORKDIR /app
|
|
|
|
# Set default timezone
|
|
ENV TZ=Europe/Rome
|
|
|
|
# Install Python dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /data /app/logs /var/lib/postgresql/data /var/run/postgresql
|
|
|
|
# Make startup scripts executable
|
|
RUN chmod +x /app/docker/init-database.py /app/docker/test-db.py
|
|
|
|
# Create startup script directly in Dockerfile
|
|
RUN echo '#!/bin/bash' > /app/start.sh && \
|
|
echo 'set -e' >> /app/start.sh && \
|
|
echo 'cd /app' >> /app/start.sh && \
|
|
echo 'export FLASK_APP=app' >> /app/start.sh && \
|
|
echo 'export DATABASE_URL=postgresql+psycopg2://timetracker@localhost:5432/timetracker' >> /app/start.sh && \
|
|
echo 'echo "=== Starting TimeTracker ==="' >> /app/start.sh && \
|
|
echo 'echo "Testing startup script..."' >> /app/start.sh && \
|
|
echo 'ls -la /app/docker/' >> /app/start.sh && \
|
|
echo 'echo "Starting database initialization..."' >> /app/start.sh && \
|
|
echo 'python /app/docker/init-database-sql.py' >> /app/start.sh && \
|
|
echo 'echo "Starting application..."' >> /app/start.sh && \
|
|
echo 'exec gunicorn --bind 0.0.0.0:8080 --worker-class eventlet --workers 1 --timeout 120 "app:create_app()"' >> /app/start.sh
|
|
|
|
# Make startup scripts executable
|
|
RUN chmod +x /app/start.sh /app/docker/init-database.py /app/docker/test-db.py
|
|
|
|
# Create timetracker user and ensure postgres user exists
|
|
RUN useradd -m -u 1000 timetracker && \
|
|
chown -R timetracker:timetracker /app /data /app/logs && \
|
|
chown -R postgres:postgres /var/lib/postgresql/data /var/run/postgresql && \
|
|
chmod +x /app/start.sh
|
|
|
|
# Verify startup script exists and is accessible
|
|
RUN ls -la /app/start.sh && \
|
|
head -1 /app/start.sh
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
CMD curl -f http://localhost:8080/_health || exit 1
|
|
|
|
# Start the application
|
|
CMD ["/app/start.sh"]
|