Shivam098 commited on
Commit
dc1cb06
1 Parent(s): 06d5d04

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -14
Dockerfile CHANGED
@@ -1,29 +1,38 @@
1
- # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # you will also find guides on how best to write your Dockerfile
3
-
4
  FROM python:3.9
5
 
6
- WORKDIR /code
7
- # Copy the JSON file into the container
8
- COPY ./fruitful_patterns.json /code/fruitful_patterns.json
9
-
10
- # Set permissions for the JSON file
11
- RUN chmod 644 /code/fruitful_patterns.json
12
- # Copy requirements file and install dependencies
13
- COPY ./requirements.txt /code/requirements.txt
14
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
15
  RUN useradd -m -u 1000 user
 
 
16
  USER user
 
 
17
  ENV HOME=/home/user \
18
  PATH=/home/user/.local/bin:$PATH
19
 
 
20
  WORKDIR $HOME/app
21
 
22
- COPY --chown=user . $HOME/app
 
 
 
 
 
 
 
 
 
 
23
  # Download spaCy model
24
  RUN python -m spacy download en_core_web_md
25
 
 
 
 
26
  # Copy the rest of the code
27
- COPY . .
28
 
 
29
  CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]
 
1
+ # Base Image
 
 
2
  FROM python:3.9
3
 
4
+ # Create a user
 
 
 
 
 
 
 
 
5
  RUN useradd -m -u 1000 user
6
+
7
+ # Switch to user
8
  USER user
9
+
10
+ # Set environment variables
11
  ENV HOME=/home/user \
12
  PATH=/home/user/.local/bin:$PATH
13
 
14
+ # Set working directory
15
  WORKDIR $HOME/app
16
 
17
+ # Switch back to root to install dependencies
18
+ USER root
19
+
20
+ # Copy requirements and install dependencies
21
+ COPY ./requirements.txt /code/requirements.txt
22
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
23
+
24
+ # Copy the JSON file and set permissions
25
+ COPY --chown=user ./fruitful_patterns.json $HOME/app/fruitful_patterns.json
26
+ RUN chmod 644 $HOME/app/fruitful_patterns.json
27
+
28
  # Download spaCy model
29
  RUN python -m spacy download en_core_web_md
30
 
31
+ # Switch to user
32
+ USER user
33
+
34
  # Copy the rest of the code
35
+ COPY --chown=user . $HOME/app
36
 
37
+ # Set CMD
38
  CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]