SharathReddy commited on
Commit
e3b6ed3
·
verified ·
1 Parent(s): 88c7ca5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -12
Dockerfile CHANGED
@@ -1,18 +1,27 @@
1
- # 1. Start with a basic Python image
2
- FROM python:3.10-slim
3
 
4
- # 2. Set the working directory inside the container
5
- WORKDIR /code
 
6
 
7
- # 3. Install git, which the GitPython library needs to run
8
- RUN apt-get update && apt-get install -y git
 
9
 
10
- # 4. Copy and install Python dependencies
11
- COPY ./requirements.txt /code/requirements.txt
12
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
13
 
14
- # 5. Copy your data mining script into the container
15
- COPY ./mine_diffs.py /code/mine_diffs.py
 
16
 
17
- # 6. Set the command to automatically run the script on startup
 
 
 
 
 
 
18
  CMD ["python", "mine_diffs.py"]
 
1
+ # 1. Start with a stable base image
2
+ FROM python:3.10.13-slim-bullseye
3
 
4
+ # 2. Set environment variables
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+ ENV PYTHONUNBUFFERED=1
7
 
8
+ # 3. Install git as the root user
9
+ RUN apt-get update && apt-get install -y --no-install-recommends git && \
10
+ apt-get clean && rm -rf /var/lib/apt/lists/*
11
 
12
+ # 4. Create a non-root user and the application directory
13
+ RUN useradd -m -u 1000 user
14
+ WORKDIR /home/user/app
15
 
16
+ # 5. Copy files and set ownership for the non-root user
17
+ COPY --chown=user:user ./requirements.txt ./requirements.txt
18
+ COPY --chown=user:user ./mine_diffs.py ./mine_diffs.py
19
 
20
+ # 6. Switch to the non-root user
21
+ USER user
22
+
23
+ # 7. Install Python dependencies as the non-root user
24
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
25
+
26
+ # 8. Set the command to automatically run the script
27
  CMD ["python", "mine_diffs.py"]