Files
TimeTracker/Dockerfile
Dries Peeters 8a378b7078 feat(clients,license,db): add client management, enhanced DB init, and tests
- Clients: add model, routes, and templates
  - app/models/client.py
  - app/routes/clients.py
  - templates/clients/{create,edit,list,view}.html
  - docs/CLIENT_MANAGEMENT_README.md
- Database: add enhanced init/verify scripts, migrations, and docs
  - docker/{init-database-enhanced.py,start-enhanced.py,verify-database.py}
  - docs/ENHANCED_DATABASE_STARTUP.md
  - migrations/{add_analytics_column.sql,add_analytics_setting.py,migrate_to_client_model.py}
- Scripts: add version manager and docker network test helpers
  - scripts/version-manager.{bat,ps1,py,sh}
  - scripts/test-docker-network.{bat,sh}
  - docs/VERSION_MANAGEMENT.md
- UI: tweak base stylesheet
  - app/static/base.css
- Tests: add client system test
  - test_client_system.py
2025-09-01 11:34:45 +02:00

76 lines
2.0 KiB
Docker

FROM python:3.11-slim-bullseye
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV FLASK_APP=app
ENV FLASK_ENV=production
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
tzdata \
# Network tools for debugging
iproute2 \
net-tools \
iputils-ping \
dnsutils \
# WeasyPrint dependencies (Debian Bullseye package names)
libgdk-pixbuf2.0-0 \
libpango-1.0-0 \
libcairo2 \
libpangocairo-1.0-0 \
libffi-dev \
shared-mime-info \
# Additional fonts and rendering support
fonts-liberation \
fonts-dejavu-core \
&& 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 project
COPY . .
# Create data and logs directories with proper permissions
RUN mkdir -p /data /app/logs && chmod 755 /data && chmod 755 /app/logs
# Create upload directories with proper permissions
RUN mkdir -p /app/app/static/uploads/logos /app/static/uploads/logos && \
chmod -R 755 /app/app/static/uploads && \
chmod -R 755 /app/static/uploads
# Copy the startup script and ensure it's executable
COPY docker/start-fixed.py /app/start.py
# Make startup scripts executable
RUN chmod +x /app/start.py /app/docker/init-database.py /app/docker/init-database-sql.py /app/docker/init-database-enhanced.py /app/docker/verify-database.py /app/docker/test-db.py /app/docker/test-routing.py
# Create non-root user
RUN useradd -m -u 1000 timetracker && \
chown -R timetracker:timetracker /app /data /app/logs /app/app/static/uploads /app/static/uploads
# Verify startup script exists and is accessible
RUN ls -la /app/start.py && \
head -1 /app/start.py
USER timetracker
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8080/_health || exit 1
# Run the application
CMD ["python", "/app/start.py"]