forked from qdrant/demo-food-discovery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (35 loc) · 1.36 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Dockerfile is based on the following tutorial:
# https://www.erraticbits.ca/post/2021/fastapi/
# Build step #1: build the React front end
FROM node:20-bookworm-slim as build-step
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY frontend/package.json ./
RUN npm install
COPY ./frontend/ ./
RUN npm run build
FROM python:3.11-slim-bookworm
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Install poetry for packages management
RUN python -m pip install poetry
RUN poetry config virtualenvs.create false
# Use /app as the working directory
WORKDIR /app
RUN mkdir -p /app/models_cache && chmod 777 /app/models_cache
# Copy poetry files & install the dependencies
COPY backend/pyproject.toml /app
COPY --from=build-step /app/build /app/build
RUN poetry install --no-interaction --no-ansi --no-root --without dev
RUN python -c 'from sentence_transformers import SentenceTransformer; SentenceTransformer("clip-ViT-B-32", cache_folder="./models_cache")'
# Finally copy the application source code and install root
COPY backend /app
ARG USER_ID=1000
RUN if [[ "$USER_ID" != "0" ]]; then (groupadd --gid $USER_ID demo \
&& useradd --uid $USER_ID --gid $USER_ID -m demo \
&& chown -R $USER_ID:$USER_ID /app); fi
EXPOSE 8001
USER $USER_ID:$USER_ID
# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8001"]