File size: 841 Bytes
e3b6ed3
 
829142c
d9d7da7
e3b6ed3
 
829142c
d9d7da7
 
 
 
 
 
 
5d52c73
 
 
829142c
d9d7da7
 
 
e3b6ed3
d9d7da7
 
0f5d34a
d9d7da7
0fcac20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 1. Start with a stable base image
FROM python:3.10.13-slim-bullseye

# 2. Install git as the root user
RUN apt-get update && apt-get install -y --no-install-recommends git && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# 3. Create a non-root user for security
RUN useradd --create-home --shell /bin/bash --uid 1000 user

# 4. Set the working directory in the new user's home
WORKDIR /home/user/app

# 5. Copy files and install dependencies
COPY ./requirements.txt .
COPY ./mine_diffs.py .
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# 6. Change ownership of the app directory to the non-root user.
# This is the critical step to grant write permissions.
RUN chown -R user:user /home/user/app

# 7. Switch to the non-root user
USER user

# 8. Run the script automatically on startup
CMD ["python", "mine_diffs.py"]