diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..00cf84d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM python:3.12-slim + +# Prevent Python from writing .pyc files and buffer stdout/stderr for clean logging +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + +WORKDIR /app + +# Install dependencies first to leverage Docker layer caching +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy application source code +COPY matrix_keycloak_bot.py . + +# Security best practice: run as a non-root user +RUN useradd -m -u 10001 botuser && \ + chown -R botuser:botuser /app + +USER botuser + +CMD ["python", "matrix_keycloak_bot.py"] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4c56539 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +matrix-nio>=0.24.0 +python-keycloak>=4.0.0