dockerized läuft

This commit is contained in:
br committed 2026-08-03 13:38:11 +02:00
1 parent a8c95e9df5
commit 1c789aa8d5
10 files changed
+735 -286

No files matched your search

+50 -25
View File
@@ -2,52 +2,77 @@
# Formeleon - Multi-tenant Form Generator
# Author: Björn Runden <br@runden.net>
# File: Dockerfile
# Description: Docker container configuration for Formeleon application.
# Description: Multi-stage Docker build for development and production.
# =============================================================================
# Use official Python runtime as parent image
# Use official Python 3.13 runtime as parent image
FROM python:3.13-slim
# =============================================================================
# Builder Stage: Install dependencies in a virtual environment
# =============================================================================
FROM python:3.13-slim as builder
# Set environment variables
# Set environment variables for builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
FLASK_ENV=production \
FLASK_APP=app.py
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Set working directory
WORKDIR /app
# Install system dependencies (einschließlich curl für Healthcheck)
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements file first to leverage Docker cache
COPY requirements.txt .
WORKDIR /app
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Create and activate virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# =============================================================================
# Final Stage: Lean runtime image
# =============================================================================
FROM python:3.13-slim
# Set environment variables for runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
FLASK_APP=app.py \
PATH="/opt/venv/bin:$PATH"
# Install required runtime system dependencies (curl for healthcheck)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the virtual environment from builder stage
COPY --from=builder /opt/venv /opt/venv
# Copy entrypoint script and ensure it's executable
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Copy application code
COPY . .
# Create uploads directory
# Create necessary runtime directories
RUN mkdir -p /tmp/formeleon_uploads && \
mkdir -p /app/data && \
mkdir -p /app/logs && \
touch /tmp/formeleon_uploads/.gitkeep
# Expose port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:5000/api/v1/status || exit 1
CMD curl -f http://127.0.0.1:5000/ || exit 1
# Run the application with gthread workers for high concurrency
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "--threads", "2", "--worker-class", "gthread", "app:app"]
# For development (uncomment and use docker-compose)
# CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"]
ENTRYPOINT ["/entrypoint.sh"]
CMD ["server"]