File size: 1,679 Bytes
65315f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
baa15a5
 
 
 
65315f1
baa15a5
65315f1
 
baa15a5
65315f1
 
baa15a5
65315f1
 
baa15a5
65315f1
 
 
baa15a5
65315f1
baa15a5
 
65315f1
baa15a5
 
 
65315f1
 
baa15a5
65315f1
baa15a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# # Use the official PYTHON 3.9 IMAGE
# FROM python:3.9

# # Set the working directory in the container
# WORKDIR /code 

# # Copy the current directory contents into the container at /code
# COPY requirements.txt /code/requirements.txt

# # Install any needed packages specified in requirements.txt
# RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# # Copy the current directory contents into the container at /code
# COPY . /code

# # set up new user 
# RUN useradd user

# # Change to the new user
# USER user

# # set home to the user's home directory
# ENV HOME=/home/user \
#     PATH=/home/user/.local/bin:$PATH

# # Set the working directory in the container
# WORKDIR $HOME/user

# # Copy the current directory contents into the container at $HOME/app setting the owner to user
# COPY --chown=user:user . $HOME/app

# # Start the fastapi on port 8000
# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]



# Use the official PYTHON 3.9 IMAGE
FROM python:3.9

# Set the working directory in the container
WORKDIR /app 

# Copy the requirements file into the container
COPY requirements.txt /app/requirements.txt

# Install the dependencies
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt

# Copy the current directory contents into the container
COPY . /app

# Set up a non-root user
RUN useradd -m user && \
    chown -R user:user /app

# Switch to the non-root user
USER user

# Set environment variables
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Expose the application on port 7860
EXPOSE 7860

# Start the FastAPI application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]