count / Dockerfile
dexym's picture
Fix torch cache path try 3
554d105
Raw History Blame Contribute Delete
1.43 kB
# 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"]