Spaces:
Build error
Build error
Commit
·
525b80a
1
Parent(s):
f2db274
TRY install on system wide
Browse files- Dockerfile +18 -26
Dockerfile
CHANGED
@@ -1,44 +1,36 @@
|
|
1 |
FROM python:3.10
|
2 |
|
3 |
-
# ---------------------------
|
4 |
# 1. System dependencies
|
5 |
-
# ---------------------------
|
6 |
RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0
|
7 |
|
8 |
-
#
|
9 |
-
# 2. Set up Poetry in /usr/local
|
10 |
-
# ---------------------------
|
11 |
ENV POETRY_HOME="/usr/local/poetry"
|
12 |
RUN curl -sSL https://install.python-poetry.org | python3 - --yes
|
13 |
|
14 |
-
#
|
15 |
ENV PATH="$POETRY_HOME/bin:$PATH"
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
-
# ---------------------------
|
20 |
-
WORKDIR /code
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
|
25 |
-
#
|
26 |
-
|
|
|
27 |
|
28 |
-
# Copy the
|
29 |
-
COPY . /code
|
30 |
|
31 |
-
#
|
32 |
-
|
33 |
-
# ---------------------------
|
34 |
-
# (Optional) Create a non-root user
|
35 |
-
RUN useradd -m -u 1000 user
|
36 |
-
RUN chown -R user:user /code
|
37 |
|
38 |
-
|
|
|
39 |
|
40 |
-
#
|
41 |
-
# 5. Expose & run
|
42 |
-
# ---------------------------
|
43 |
EXPOSE 7860
|
|
|
|
|
44 |
CMD ["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
FROM python:3.10
|
2 |
|
|
|
3 |
# 1. System dependencies
|
|
|
4 |
RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0
|
5 |
|
6 |
+
# 2. Install Poetry into /usr/local/poetry
|
|
|
|
|
7 |
ENV POETRY_HOME="/usr/local/poetry"
|
8 |
RUN curl -sSL https://install.python-poetry.org | python3 - --yes
|
9 |
|
10 |
+
# Put Poetry on PATH
|
11 |
ENV PATH="$POETRY_HOME/bin:$PATH"
|
12 |
|
13 |
+
# 3. Create a non-root user
|
14 |
+
RUN useradd -m -u 1000 user
|
|
|
|
|
15 |
|
16 |
+
# 4. Create /code folder and set ownership
|
17 |
+
RUN mkdir /code && chown user:user /code
|
18 |
|
19 |
+
# 5. Switch to that user BEFORE installing dependencies
|
20 |
+
WORKDIR /code
|
21 |
+
USER user
|
22 |
|
23 |
+
# 6. Copy only the dependency files first
|
24 |
+
COPY --chown=user:user pyproject.toml poetry.lock /code/
|
25 |
|
26 |
+
# 7. Install dependencies as the non-root user
|
27 |
+
RUN poetry install --no-root --no-interaction --no-ansi
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
# 8. Copy the rest of your source code
|
30 |
+
COPY --chown=user:user . /code
|
31 |
|
32 |
+
# 9. Expose your port
|
|
|
|
|
33 |
EXPOSE 7860
|
34 |
+
|
35 |
+
# 10. Launch your app with Poetry
|
36 |
CMD ["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|