Miakat
commited on
Update Dockerfile
Browse files- Dockerfile +16 -7
Dockerfile
CHANGED
@@ -2,21 +2,30 @@
|
|
2 |
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
3 |
# you will also find guides on how best to write your Dockerfile
|
4 |
|
|
|
5 |
FROM python:3.9
|
6 |
|
7 |
-
#
|
8 |
-
# Learn more about the Dev Mode at https://huggingface.co/dev-mode-explorers
|
9 |
RUN useradd -m -u 1000 user
|
|
|
|
|
10 |
WORKDIR /app
|
11 |
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
|
|
16 |
|
|
|
17 |
USER user
|
18 |
|
|
|
19 |
ENV HOME=/home/user \
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
-
|
|
|
|
2 |
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
3 |
# you will also find guides on how best to write your Dockerfile
|
4 |
|
5 |
+
# Base image
|
6 |
FROM python:3.9
|
7 |
|
8 |
+
# Add a non-root user for better security
|
|
|
9 |
RUN useradd -m -u 1000 user
|
10 |
+
|
11 |
+
# Set working directory for the application
|
12 |
WORKDIR /app
|
13 |
|
14 |
+
# Copy requirements file
|
15 |
+
COPY ./requirements.txt /app/requirements.txt
|
16 |
|
17 |
+
# Install dependencies from requirements.txt
|
18 |
+
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
19 |
|
20 |
+
# Switch to the non-root user
|
21 |
USER user
|
22 |
|
23 |
+
# Set environment variables
|
24 |
ENV HOME=/home/user \
|
25 |
+
PATH=/home/user/.local/bin:$PATH
|
26 |
+
|
27 |
+
# Copy application code to the container
|
28 |
+
COPY --chown=user . /app
|
29 |
|
30 |
+
# Command to run the application
|
31 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|