MekkCyber commited on
Commit
4905514
·
1 Parent(s): 957fac4
Files changed (2) hide show
  1. Dockerfile +13 -13
  2. app.py +1 -1
Dockerfile CHANGED
@@ -12,32 +12,32 @@ RUN apt-get update && \
12
  rm -rf /var/lib/apt/lists/*
13
 
14
  # Create a non-root user (do this as root)
15
- RUN useradd -ms /bin/bash myuser
16
 
17
  # Set the working directory as root before switching users
18
- WORKDIR /home/myuser/app
19
 
20
  # Copy files and change permissions as root
21
- COPY requirements.txt /home/myuser/app/requirements.txt
22
- COPY setup.sh /home/myuser/app/setup.sh
23
- RUN chmod +x /home/myuser/app/setup.sh
24
 
25
  # Install Python dependencies as root
26
- RUN pip install --no-cache-dir -r /home/myuser/app/requirements.txt
27
 
28
  # Run setup.sh as root (if it needs elevated privileges)
29
- RUN /home/myuser/app/setup.sh
30
 
31
- # Change ownership of the directory to myuser
32
- RUN chown -R myuser:myuser /home/myuser/app
33
 
34
  # Switch to the non-root user
35
- USER myuser
36
 
37
 
38
- RUN ls /home/myuser/app
39
- # Copy the rest of the application code to the container (as myuser)
40
- COPY . /home/myuser/app
41
 
42
  # Expose the necessary port
43
  EXPOSE 7860
 
12
  rm -rf /var/lib/apt/lists/*
13
 
14
  # Create a non-root user (do this as root)
15
+ RUN useradd -ms /bin/bash user
16
 
17
  # Set the working directory as root before switching users
18
+ WORKDIR /home/user/app
19
 
20
  # Copy files and change permissions as root
21
+ COPY requirements.txt /home/user/app/requirements.txt
22
+ COPY setup.sh /home/user/app/setup.sh
23
+ RUN chmod +x /home/user/app/setup.sh
24
 
25
  # Install Python dependencies as root
26
+ RUN pip install --no-cache-dir -r /home/user/app/requirements.txt
27
 
28
  # Run setup.sh as root (if it needs elevated privileges)
29
+ RUN /home/user/app/setup.sh
30
 
31
+ # Change ownership of the directory to user
32
+ RUN chown -R user:user /home/user/app
33
 
34
  # Switch to the non-root user
35
+ USER user
36
 
37
 
38
+ RUN ls /home/user/app
39
+ # Copy the rest of the application code to the container (as user)
40
+ COPY . /home/user/app
41
 
42
  # Expose the necessary port
43
  EXPOSE 7860
app.py CHANGED
@@ -9,7 +9,7 @@ import logging
9
  logging.basicConfig(level=logging.INFO)
10
 
11
  # Path to the cloned repository
12
- BITNET_REPO_PATH = "/home/myuser/app/BitNet"
13
  SETUP_SCRIPT = os.path.join(BITNET_REPO_PATH, "setup_env.py")
14
  INFERENCE_SCRIPT = os.path.join(BITNET_REPO_PATH, "run_inference.py")
15
 
 
9
  logging.basicConfig(level=logging.INFO)
10
 
11
  # Path to the cloned repository
12
+ BITNET_REPO_PATH = "/home/user/app/BitNet"
13
  SETUP_SCRIPT = os.path.join(BITNET_REPO_PATH, "setup_env.py")
14
  INFERENCE_SCRIPT = os.path.join(BITNET_REPO_PATH, "run_inference.py")
15