Spaces:
Build error
Build error
Commit
·
f2db274
1
Parent(s):
2476522
TRY install on system wide
Browse files- Dockerfile +22 -17
Dockerfile
CHANGED
|
@@ -1,39 +1,44 @@
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
-
#
|
|
|
|
|
|
|
| 4 |
RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0
|
| 5 |
|
| 6 |
-
#
|
|
|
|
|
|
|
| 7 |
ENV POETRY_HOME="/usr/local/poetry"
|
| 8 |
-
|
| 9 |
RUN curl -sSL https://install.python-poetry.org | python3 - --yes
|
| 10 |
|
| 11 |
-
# Add Poetry to
|
| 12 |
-
ENV PATH="/
|
| 13 |
-
|
| 14 |
-
# Create a non-root user
|
| 15 |
-
RUN useradd -m -u 1000 user
|
| 16 |
|
| 17 |
-
#
|
|
|
|
|
|
|
| 18 |
WORKDIR /code
|
| 19 |
|
| 20 |
-
# Copy dependency files
|
| 21 |
COPY pyproject.toml poetry.lock /code/
|
| 22 |
|
| 23 |
-
# Install dependencies
|
| 24 |
RUN poetry install --no-root --no-interaction --no-ansi
|
| 25 |
|
| 26 |
-
#
|
| 27 |
COPY . /code
|
| 28 |
|
| 29 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
RUN chown -R user:user /code
|
| 31 |
|
| 32 |
-
# Switch to the non-root user
|
| 33 |
USER user
|
| 34 |
|
| 35 |
-
#
|
|
|
|
|
|
|
| 36 |
EXPOSE 7860
|
| 37 |
-
|
| 38 |
-
# Run
|
| 39 |
CMD ["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 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 |
+
# Add Poetry to PATH
|
| 15 |
+
ENV PATH="$POETRY_HOME/bin:$PATH"
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
# ---------------------------
|
| 18 |
+
# 3. Copy files & install deps
|
| 19 |
+
# ---------------------------
|
| 20 |
WORKDIR /code
|
| 21 |
|
| 22 |
+
# Copy only dependency files first for Docker caching
|
| 23 |
COPY pyproject.toml poetry.lock /code/
|
| 24 |
|
| 25 |
+
# Install dependencies
|
| 26 |
RUN poetry install --no-root --no-interaction --no-ansi
|
| 27 |
|
| 28 |
+
# Copy the rest of the project
|
| 29 |
COPY . /code
|
| 30 |
|
| 31 |
+
# ---------------------------
|
| 32 |
+
# 4. If you need a non-root user
|
| 33 |
+
# ---------------------------
|
| 34 |
+
# (Optional) Create a non-root user
|
| 35 |
+
RUN useradd -m -u 1000 user
|
| 36 |
RUN chown -R user:user /code
|
| 37 |
|
|
|
|
| 38 |
USER user
|
| 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"]
|