Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +16 -15
Dockerfile
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
-
#
|
2 |
-
# you will also find guides on how best to write your Dockerfile.
|
3 |
-
|
4 |
FROM nvidia/cuda:12.6.3-cudnn-devel-ubuntu22.04
|
5 |
|
|
|
6 |
ARG DEBIAN_FRONTEND=noninteractive
|
7 |
-
|
8 |
ENV PYTHONUNBUFFERED=1
|
9 |
|
|
|
10 |
RUN apt-get update && apt-get install --no-install-recommends -y \
|
11 |
build-essential \
|
12 |
python3.9 \
|
@@ -14,27 +13,29 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
|
14 |
git \
|
15 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
16 |
|
|
|
17 |
WORKDIR /code
|
18 |
|
|
|
19 |
COPY ./requirements.txt /code/requirements.txt
|
|
|
20 |
|
21 |
-
# Set up a new
|
22 |
RUN useradd -m -u 1000 user
|
23 |
-
# Switch to the "user" user
|
24 |
USER user
|
25 |
-
|
|
|
26 |
ENV HOME=/home/user \
|
27 |
-
|
28 |
PYTHONPATH=$HOME/app \
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
RUN pip3 install --no-cache-dir --upgrade -r /code/requirements.txt
|
33 |
|
34 |
-
# Set the working directory
|
35 |
WORKDIR $HOME/app
|
36 |
|
37 |
-
# Copy
|
38 |
COPY --chown=user . $HOME/app
|
39 |
|
40 |
-
|
|
|
|
1 |
+
# Base image with CUDA and development tools
|
|
|
|
|
2 |
FROM nvidia/cuda:12.6.3-cudnn-devel-ubuntu22.04
|
3 |
|
4 |
+
# Environment settings
|
5 |
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
6 |
ENV PYTHONUNBUFFERED=1
|
7 |
|
8 |
+
# Install required dependencies
|
9 |
RUN apt-get update && apt-get install --no-install-recommends -y \
|
10 |
build-essential \
|
11 |
python3.9 \
|
|
|
13 |
git \
|
14 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
15 |
|
16 |
+
# Set up the working directory
|
17 |
WORKDIR /code
|
18 |
|
19 |
+
# Copy requirements and install dependencies
|
20 |
COPY ./requirements.txt /code/requirements.txt
|
21 |
+
RUN pip3 install --no-cache-dir --upgrade -r /code/requirements.txt
|
22 |
|
23 |
+
# Set up a new non-root user
|
24 |
RUN useradd -m -u 1000 user
|
|
|
25 |
USER user
|
26 |
+
|
27 |
+
# Set environment variables for the user
|
28 |
ENV HOME=/home/user \
|
29 |
+
PATH=/home/user/.local/bin:$PATH \
|
30 |
PYTHONPATH=$HOME/app \
|
31 |
+
PYTHONUNBUFFERED=1 \
|
32 |
+
SYSTEM=spaces
|
|
|
|
|
33 |
|
34 |
+
# Set the working directory for the application
|
35 |
WORKDIR $HOME/app
|
36 |
|
37 |
+
# Copy files and set ownership
|
38 |
COPY --chown=user . $HOME/app
|
39 |
|
40 |
+
# Enable auto-reload using polling to ensure changes are detected
|
41 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--reload", "--reload-use-polling"]
|