FROM python:3.8-slim-buster # Install necessary packages RUN apt update -y && apt install awscli -y # Create a non-root user to avoid running as root RUN useradd -m appuser # Set working directory WORKDIR /app # Ensure the /app/logs directory exists and set the correct permissions RUN mkdir -p /app/logs && chmod -R 777 /app/logs # Copy the local files into the container's working directory COPY . /app # Change ownership of the application and logs directory to the non-root user RUN chown -R appuser:appuser /app /app/logs # Install Python dependencies RUN pip install -r requirements.txt # Switch to the non-root user USER appuser # Command to run your application CMD ["python3", "app.py"]