kayung-developer/aetheri-x-engine
0
1# =================================================================================================
2# FILE: Dockerfile (Improved with Non-Root User)
3# =================================================================================================
4
5FROM python:3.11-slim
6
7WORKDIR /app
8
9# Install supervisor and other system necessities
10RUN apt-get update && apt-get install -y --no-install-recommends \
11 supervisor \
12 build-essential \
13 && rm -rf /var/lib/apt/lists/*
14
15# Copy requirements and install Python packages
16COPY requirements.txt .
17RUN pip install --no-cache-dir -r requirements.txt
18
19# Create a non-root user and switch to it
20# This is a security best practice.
21RUN useradd -m appuser
22USER appuser
23
24# Copy application code as the new user
25COPY --chown=appuser:appuser . .
26
27# Copy supervisor config
28# Since we are no longer root, we need to place the config in a user-accessible directory
29# Or ensure the default directory is writable. For simplicity, we stick to the original path
30# but this could be changed if permissions were an issue.
31USER root
32COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
33USER appuser
34
35# Expose the port Gunicorn will run on
36EXPOSE 8000
37
38# Start Supervisor as the container's main command
39CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]