Skip to content

Commit

Permalink
Update dockerfile to use multi stage builds
Browse files Browse the repository at this point in the history
  • Loading branch information
sansmoraxz committed Aug 10, 2023
1 parent 444d096 commit fdda8a8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
19 changes: 15 additions & 4 deletions executors/ClipEncoder/Dockerfile.gpu
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ ARG UBUNTU_VERSION=20.04
ARG CUDA_VERSION=11.3.1
ARG CUDNN_VERSION=8

FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
RUN apt-get update && apt-get install --no-install-recommends -y gcc libc6-dev git

FROM python:3.10-slim-buster as base
WORKDIR /workdir
# create virtual environment
RUN python -m venv venv
RUN . venv/bin/activate

# install dependencies
COPY requirements.txt requirements.txt
COPY pyproject.toml pyproject.toml
RUN pip install --default-timeout=1000 --compile .
COPY . .

FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
RUN apt-get update && apt-get install --no-install-recommends -y gcc libc6-dev git

WORKDIR /workdir

COPY . /workdir/
# copy from base
COPY --from=base /workdir/pyproject.toml pyproject.toml
COPY --from=base /workdir/requirements.txt requirements.txt
COPY --from=base /workdir/venv venv

ENTRYPOINT ["jina", "executor", "--uses", "config.yml"]
19 changes: 15 additions & 4 deletions executors/MilvusIndexer/Dockerfile.gpu
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ ARG UBUNTU_VERSION=20.04
ARG CUDA_VERSION=11.3.1
ARG CUDNN_VERSION=8

FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
RUN apt-get update && apt-get install --no-install-recommends -y gcc libc6-dev git

FROM python:3.10-slim-buster as base
WORKDIR /workdir
# create virtual environment
RUN python -m venv venv
RUN . venv/bin/activate

# install dependencies
COPY requirements.txt requirements.txt
COPY pyproject.toml pyproject.toml
RUN pip install --default-timeout=1000 --compile .
COPY . .

FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
RUN apt-get update && apt-get install --no-install-recommends -y gcc libc6-dev git

WORKDIR /workdir

COPY . /workdir/
# copy from base
COPY --from=base /workdir/pyproject.toml pyproject.toml
COPY --from=base /workdir/requirements.txt requirements.txt
COPY --from=base /workdir/venv venv

ENTRYPOINT ["jina", "executor", "--uses", "config.yml"]

0 comments on commit fdda8a8

Please sign in to comment.