36 lines
779 B
Docker
36 lines
779 B
Docker
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install curl for health checks
|
|
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application
|
|
COPY app.py .
|
|
|
|
# Create data directory for status.json
|
|
RUN mkdir -p /data && chmod 777 /data
|
|
|
|
# Non-root user
|
|
RUN useradd -m -u 1000 apiuser && \
|
|
chown -R apiuser:apiuser /app /data
|
|
|
|
USER apiuser
|
|
|
|
# Health checks
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
CMD curl -f http://localhost:5000/health || exit 1
|
|
|
|
EXPOSE 5000
|
|
|
|
ENV FLASK_ENV=production \
|
|
API_HOST=0.0.0.0 \
|
|
API_PORT=5000 \
|
|
STATUS_FILE=/data/status.json
|
|
|
|
CMD ["python", "app.py"]
|