File size: 1,434 Bytes
45da00e
 
 
 
 
 
 
bff402f
45da00e
 
 
 
 
 
 
 
 
 
 
722c97a
 
 
45da00e
 
722c97a
 
 
 
 
45da00e
 
 
bff402f
722c97a
 
45da00e
 
 
 
722c97a
45da00e
554d105
45da00e
 
 
 
 
 
 
 
 
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
# Stage 1: Build React App
FROM node:14 as build-stage

WORKDIR /app

RUN apt-get update && apt-get install -y git

RUN --mount=type=secret,id=git_user_pass,mode=0444,required=true \
    git clone https://$(cat /run/secrets/git_user_pass)@github.com/dejanmilivojevic/crowd-count-frontend.git .

RUN npm install

RUN npm run build

# Stage 2: Production Container
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime

RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    curl \
    gnupg \
    && apt-get purge --autoremove -y \
    && rm -rf /var/lib/apt/lists/*

# Install git-lfs
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
    apt-get install -y git-lfs && \
    git lfs install

WORKDIR /app

# Clone the backend repository
RUN --mount=type=secret,id=git_user_pass,mode=0444,required=true \
    git clone https://$(cat /run/secrets/git_user_pass)@github.com/dejanmilivojevic/crowd-count-backend.git . && \
    git lfs pull

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

COPY --chown=user ./cache_model.py .
RUN python cache_model.py
RUN chmod -R 777 /app/checkpoints/

# Copy the built React app from the first stage
COPY --from=build-stage /app/build/ ./web/

# Expose the port that FastAPI will be served on
EXPOSE 7860

# Run the FastAPI server
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]