KN123 commited on
Commit
fb80f11
1 Parent(s): 0cb4281

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -30
Dockerfile CHANGED
@@ -1,41 +1,30 @@
1
- # FROM python:3.9
2
- # WORKDIR /code
3
- # COPY ./requirements.txt /code/requirements.txt
4
- # RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
5
- # RUN useradd user
6
- # USER user
7
- # ENV HOME = /home/user \
8
- # PATH=/home/user/.local/bin:$PATH
9
 
10
- # WORKDIR $HOME/app
11
- # COPY --chown==user . $HOME/app
12
 
13
- # CMD [ "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860" ]
 
 
14
 
15
- # Use the official Python image from Docker Hub
16
- FROM python:3.9
17
 
18
  # Set environment variables
19
- ENV PYTHONDONTWRITEBYTECODE 1
20
- ENV PYTHONUNBUFFERED 1
21
-
22
- # Set the working directory in the container
23
- WORKDIR /app
24
 
25
- # Install system dependencies
26
- RUN apt-get update \
27
- && apt-get install -y --no-install-recommends gcc libgomp1 \
28
- && rm -rf /var/lib/apt/lists/*
29
 
30
- # Install Python dependencies
31
- COPY requirements.txt .
32
- RUN pip install --no-cache-dir -r requirements.txt
33
 
34
- # Copy the FastAPI application code into the container
35
- COPY app.py /app/
36
 
37
- # Expose the port that FastAPI will run on
38
- EXPOSE 8000
39
 
40
  # Command to run the FastAPI application using uvicorn
41
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ FROM python:3.9
 
 
 
 
 
 
 
2
 
3
+ # Set working directory
4
+ WORKDIR /code
5
 
6
+ # Copy requirements file and install dependencies
7
+ COPY ./requirements.txt /code/requirements.txt
8
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
9
 
10
+ # Create a non-root user
11
+ RUN useradd user
12
 
13
  # Set environment variables
14
+ ENV HOME=/home/user \
15
+ PATH=/home/user/.local/bin:$PATH
 
 
 
16
 
17
+ # Switch to the non-root user
18
+ USER user
 
 
19
 
20
+ # Set working directory for the application
21
+ WORKDIR $HOME/app
 
22
 
23
+ # Copy application code into the container
24
+ COPY --chown=user . $HOME/app
25
 
26
+ # Expose port
27
+ EXPOSE 7860
28
 
29
  # Command to run the FastAPI application using uvicorn
30
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]