Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +19 -22
Dockerfile
CHANGED
|
@@ -1,37 +1,34 @@
|
|
| 1 |
-
FROM python:3.9-
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
COPY ./pyproject.toml .
|
| 6 |
COPY ./poetry.lock .
|
| 7 |
|
| 8 |
-
|
| 9 |
-
RUN apt update
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
RUN service postgresql start
|
| 16 |
-
RUN apt-get -y install postgresql
|
| 17 |
|
| 18 |
-
|
| 19 |
-
RUN poetry export --without-hashes -f requirements.txt --output requirements.txt
|
| 20 |
-
RUN pip install -U -q pyngrok ipython psycopg2 alembic
|
| 21 |
|
| 22 |
-
|
| 23 |
-
RUN
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
FROM python:3.9-alpine
|
| 29 |
-
RUN apk add libpq
|
| 30 |
|
| 31 |
-
|
| 32 |
COPY ./ .
|
| 33 |
-
#RUN mv ./misc/etc/gunicorn.conf.py .
|
| 34 |
|
|
|
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
-
CMD ["gunicorn", "main:app", "-w", "4", "--bind", "
|
|
|
|
| 1 |
+
FROM python:3.9-slim AS builder
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
COPY ./pyproject.toml .
|
| 6 |
COPY ./poetry.lock .
|
| 7 |
|
| 8 |
+
# Install build dependencies
|
| 9 |
+
RUN apt-get update \
|
| 10 |
+
&& apt-get install -y --no-install-recommends build-essential \
|
| 11 |
+
&& pip install --upgrade pip poetry \
|
| 12 |
+
&& poetry config virtualenvs.create false \
|
| 13 |
+
&& poetry install --no-interaction --no-ansi
|
| 14 |
|
| 15 |
+
FROM python:3.9-slim
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
WORKDIR /app
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# Install runtime dependencies
|
| 20 |
+
RUN apt-get update \
|
| 21 |
+
&& apt-get install -y --no-install-recommends libpq5 \
|
| 22 |
+
&& apt-get clean \
|
| 23 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 24 |
|
| 25 |
+
# Copy the built virtual environment from the builder stage
|
| 26 |
+
COPY --from=builder /usr/local /usr/local
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
# Copy the rest of the backend files to the container
|
| 29 |
COPY ./ .
|
|
|
|
| 30 |
|
| 31 |
+
# Expose the backend port (change this if your FastAPI app uses a different port)
|
| 32 |
EXPOSE 7860
|
| 33 |
|
| 34 |
+
CMD ["gunicorn", "main:app", "-w", "4", "--bind", "0.0.0.0:7860"]
|