abadesalex commited on
Commit
0c6a58b
1 Parent(s): 1c6ac79

Adding permisions dockerfile

Browse files
Dockerfile CHANGED
@@ -1,21 +1,37 @@
1
- # Use Python 3.9 as base image
2
  FROM python:3.9
3
 
4
- # Set the environment variable for Gensim data directory
5
- ENV GENSIM_DATA_DIR=/root/gensim-data
6
 
7
- RUN mkdir -p /root/gensim-data
 
8
 
9
- WORKDIR /code
 
 
 
10
 
11
- # Copy the requirements.txt from the FastAPI folder into the working directory in the container
12
- COPY ./FastAPI/requirements.txt /code/requirements.txt
13
 
14
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
 
15
 
 
 
 
 
 
 
 
 
 
16
  COPY ./FastAPI/app /code/app
17
 
 
18
  EXPOSE 8000
19
 
 
20
  CMD ["uvicorn", "app.api:app", "--host", "0.0.0.0", "--port", "8000"]
21
-
 
 
1
  FROM python:3.9
2
 
3
+ # Set up a new user named "user" with user ID 1000
4
+ RUN useradd -m -u 1000 user
5
 
6
+ # Switch to the "user" user
7
+ USER user
8
 
9
+ # Set home to the user's home directory and Gensim data directory
10
+ ENV HOME=/home/user \
11
+ GENSIM_DATA_DIR=/home/user/gensim-data \
12
+ PATH=/home/user/.local/bin:$PATH
13
 
14
+ # Set the working directory to the user's home directory
15
+ WORKDIR $HOME/app
16
 
17
+ # Upgrade pip and install dependencies
18
+ COPY --chown=user ./FastAPI/requirements.txt /code/requirements.txt
19
+ RUN pip install --no-cache-dir --upgrade pip \
20
+ && pip install --no-cache-dir --upgrade -r /code/requirements.txt
21
 
22
+ # Install additional packages
23
+ USER root
24
+ RUN apt update && apt install -y ffmpeg
25
+ USER user
26
+
27
+ # Copy the application code and set the owner to the user
28
+ COPY --chown=user . $HOME/app
29
+
30
+ # Copy the FastAPI app separately
31
  COPY ./FastAPI/app /code/app
32
 
33
+ # Expose the port the app runs on
34
  EXPOSE 8000
35
 
36
+ # Command to run the application
37
  CMD ["uvicorn", "app.api:app", "--host", "0.0.0.0", "--port", "8000"]
 
FastAPI/app/utils/__pycache__/embedding.cpython-310.pyc CHANGED
Binary files a/FastAPI/app/utils/__pycache__/embedding.cpython-310.pyc and b/FastAPI/app/utils/__pycache__/embedding.cpython-310.pyc differ
 
FastAPI/app/utils/embedding.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import gensim.downloader as api
3
 
4
  # Ensure the environment variable is set correctly
5
- gensim_data_dir = os.getenv("GENSIM_DATA_DIR", "/root/gensim-data")
6
 
7
  # Load the GloVe model
8
  model = api.load("glove-wiki-gigaword-50")
 
2
  import gensim.downloader as api
3
 
4
  # Ensure the environment variable is set correctly
5
+ # gensim_data_dir = os.getenv("GENSIM_DATA_DIR", "/root/gensim-data")
6
 
7
  # Load the GloVe model
8
  model = api.load("glove-wiki-gigaword-50")