deepumanju commited on
Commit
0aa8937
1 Parent(s): f7739aa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -32
Dockerfile CHANGED
@@ -1,32 +1,39 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.9-slim
3
-
4
- # Define environment variables
5
- ENV HOME=/home/user \
6
- PATH=/home/user/.local/bin:$PATH \
7
- HF_HOME=/home/user/hf_home
8
-
9
- # Set the working directory in the container
10
- WORKDIR $HOME/main
11
-
12
- # Create the user, home directory, and HF_HOME directory
13
- RUN useradd -m user && mkdir -p $HOME/main $HF_HOME && chown -R user:user $HOME
14
-
15
- # Copy the current directory contents into the container
16
- COPY --chown=user:user . $HOME/main
17
-
18
- # Install FastAPI, Uvicorn, Transformers, and PyTorch
19
- RUN pip install --no-cache-dir \
20
- fastapi \
21
- uvicorn \
22
- transformers \
23
- torch --extra-index-url https://download.pytorch.org/whl/cpu
24
-
25
- # Switch to the non-root user
26
- USER user
27
-
28
- # Expose the port that FastAPI will run on
29
- EXPOSE 8000
30
-
31
- # Run the application
32
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.9-slim
3
+
4
+ # Define environment variables
5
+ ENV HOME=/home/user \
6
+ PATH=/home/user/.local/bin:$PATH \
7
+ HF_HOME=/home/user/hf_home
8
+
9
+ # Set the working directory in the container
10
+ WORKDIR $HOME/main
11
+
12
+ # Create the user, home directory, and HF_HOME directory
13
+ RUN useradd -m user && mkdir -p $HOME/main $HF_HOME && chown -R user:user $HOME
14
+
15
+ # Copy the current directory contents into the container
16
+ COPY --chown=user:user . $HOME/main
17
+
18
+ # Install FastAPI, Uvicorn, Transformers, and PyTorch
19
+ RUN pip install --no-cache-dir \
20
+ fastapi \
21
+ uvicorn \
22
+ transformers \
23
+ torch --extra-index-url https://download.pytorch.org/whl/cpu
24
+
25
+ # Switch to the non-root user
26
+ USER user
27
+
28
+ # Expose the port that FastAPI will run on
29
+ EXPOSE 8000
30
+
31
+ # Run the application
32
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
33
+
34
+ HEALTHCHECK --interval=30s --timeout=30s --retries=3 \
35
+ CMD curl --fail http://localhost:8000/ || exit 1
36
+
37
+
38
+
39
+