Files
KMH_IT_Assets/Dockerfile
T

52 lines
1.4 KiB
Docker
Raw Normal View History

# ==============================================================
# Dockerfile — Sistem Manajemen Aset IT PT. Kerinci Merangin Hidro
# Multi-stage production build (Python 3.12-slim)
# ==============================================================
FROM python:3.12-slim as base
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive
WORKDIR /app
# Install system dependencies for Pillow, ReportLab, and MySQL
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
default-libmysqlclient-dev \
pkg-config \
libjpeg-dev \
zlib1g-dev \
libfreetype6-dev \
liblcms2-dev \
libopenjp2-7-dev \
libtiff5-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Python packages
COPY requirements.txt /app/
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy project code
COPY . /app/
# Create non-root user for security
RUN useradd -m -u 1000 appuser && \
mkdir -p /app/staticfiles /app/media/bast_documents && \
chown -R appuser:appuser /app
USER appuser
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://127.0.0.1:8000/login/ || exit 1
# Default command: run gunicorn WSGI server
CMD ["gunicorn", "itam_core.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3", "--timeout", "120"]