Spaces:
Paused
Paused
Andrew Smith
commited on
Commit
·
90c17df
1
Parent(s):
75ef96c
Change build process
Browse files- Dockerfile +24 -18
Dockerfile
CHANGED
@@ -1,27 +1,33 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
RUN useradd -m -u 1000 user
|
9 |
|
10 |
-
|
11 |
-
USER user
|
12 |
|
13 |
-
|
14 |
-
ENV HOME=/home/user \
|
15 |
-
PATH=/home/user/.local/bin:$PATH
|
16 |
|
17 |
-
#
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
|
23 |
-
|
24 |
|
25 |
-
|
|
|
|
|
26 |
|
27 |
-
CMD ["
|
|
|
1 |
+
# The builder image, used to build the virtual environment
|
2 |
+
FROM python:3.11-buster as builder
|
3 |
|
4 |
+
RUN pip install poetry==1.4.2
|
5 |
+
|
6 |
+
ENV POETRY_NO_INTERACTION=1 \
|
7 |
+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
|
8 |
+
POETRY_VIRTUALENVS_CREATE=1 \
|
9 |
+
POETRY_CACHE_DIR=/tmp/poetry_cache
|
10 |
|
11 |
+
WORKDIR /app
|
|
|
12 |
|
13 |
+
COPY pyproject.toml poetry.lock ./
|
|
|
14 |
|
15 |
+
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-root
|
|
|
|
|
16 |
|
17 |
+
# The runtime image, used to just run the code provided its virtual environment
|
18 |
+
FROM python:3.11-slim-buster as runtime
|
19 |
+
|
20 |
+
# Get secret DB_URL and output it to /test at buildtime
|
21 |
+
RUN --mount=type=secret,id=DB_URL,mode=0444,required=true \
|
22 |
+
cat /run/secrets/DB_URL > /test
|
23 |
|
24 |
+
ENV VIRTUAL_ENV=/app/.venv \
|
25 |
+
PATH="/app/.venv/bin:$PATH"
|
26 |
|
27 |
+
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
28 |
|
29 |
+
COPY image_search ./image_search
|
30 |
+
COPY static ./static
|
31 |
+
COPY images ./images
|
32 |
|
33 |
+
CMD ["uvicorn", "image_search.main:app", "--host", "0.0.0.0", "--port", "7860"]
|