Upload Dockerfile
Browse files- Dockerfile +30 -0
Dockerfile
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use Python 3.10.12 as the base image
|
2 |
+
FROM python:3.9.13
|
3 |
+
|
4 |
+
# Set the working directory to /code
|
5 |
+
WORKDIR /code
|
6 |
+
|
7 |
+
# Copy the requirements file into the container at /code/requirements.txt
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
# Upgrade pip and install the dependencies
|
11 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
12 |
+
|
13 |
+
# Create a non-root user with UID 1000
|
14 |
+
RUN useradd -m -u 1000 user
|
15 |
+
|
16 |
+
# Switch to the non-root user
|
17 |
+
USER user
|
18 |
+
|
19 |
+
# Set environment variables for the user
|
20 |
+
ENV HOME=/home/user \
|
21 |
+
PATH=/home/user/.local/bin:$PATH
|
22 |
+
|
23 |
+
# Set the working directory for the application
|
24 |
+
WORKDIR $HOME/app
|
25 |
+
|
26 |
+
# Copy the local code into the container at /home/user/app
|
27 |
+
COPY --chown=user . $HOME/app
|
28 |
+
|
29 |
+
# Specify the command to run on container start
|
30 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|