docker build updates to improve security

This commit is contained in:
2026-03-11 17:42:51 +00:00
parent ea3eb899e7
commit c605e00e95
3 changed files with 55 additions and 1 deletions
+14
View File
@@ -1,9 +1,23 @@
# Dockerfile for Reddit Test Posts Bot
FROM python:3.11-slim
# Create a non-root user for running the bot
RUN groupadd -g ${GROUP_ID:-1000} botgroup && \
useradd -u ${USER_ID:-1000} -g botgroup -m botuser
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY bot.py .
COPY config.py .
# Create DB directory with proper permissions
RUN mkdir -p /app/DB && chown -R botuser:botgroup /app
ENV PYTHONUNBUFFERED=1
# Switch to non-root user
USER botuser
CMD ["python", "bot.py"]