Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
fix(docker): reduce the size of built image
  • Loading branch information
hanhxiao committed Sep 23, 2019
1 parent 1e3517e commit 45a078d9df976c4173e362d32f9f36d5d7fce472
Showing with 12 additions and 9 deletions.
  1. +2 −1 Dockerfiles/alpine.Dockerfile
  2. +2 −1 Dockerfiles/buster.Dockerfile
  3. +3 −3 Dockerfiles/full.Dockerfile
  4. +2 −1 Dockerfiles/ubuntu18.Dockerfile
  5. +3 −3 gnes/indexer/chunk/faiss.py
@@ -11,7 +11,8 @@ LABEL maintainer="team@gnes.ai" \

WORKDIR /gnes/

ADD . ./
ADD setup.py MANIFEST.in requirements.txt README.md ./
ADD gnes ./gnes/

RUN apk add --no-cache \
--virtual=.build-dependencies \
@@ -16,7 +16,8 @@ RUN apt-get update && apt-get install --no-install-recommends -y \

WORKDIR /gnes/

ADD . ./
ADD setup.py MANIFEST.in requirements.txt README.md ./
ADD gnes ./gnes/

RUN ln -s locale.h /usr/include/xlocale.h && \
pip install . --no-cache-dir --compile && \
@@ -19,11 +19,11 @@ RUN pip --no-cache-dir install -r requirements_tmp.txt

FROM dependency as base

ADD . ./

ADD setup.py MANIFEST.in requirements.txt README.md ./
ADD gnes ./gnes/

RUN pip --no-cache-dir install .[all] \
&& rm -rf /tmp/*
&& rm -rf /tmp/* && rm -rf /gnes

WORKDIR /

@@ -24,7 +24,8 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
ln -s /usr/bin/python3 python && \
apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/*

ADD . ./
ADD setup.py MANIFEST.in requirements.txt README.md ./
ADD gnes ./gnes/

RUN pip3 install . --no-cache-dir --compile && \
rm -rf /tmp/* && rm -rf /gnes
@@ -47,16 +47,16 @@ def post_init(self):
@BCI.update_helper_indexer
def add(self, keys: List[Tuple[int, Any]], vectors: np.ndarray, weights: List[float], *args, **kwargs):
if len(vectors) != len(keys):
raise ValueError("vectors length should be equal to doc_ids")
raise ValueError('vectors length should be equal to doc_ids')

if vectors.dtype != np.float32:
raise ValueError("vectors should be ndarray of float32")
raise ValueError('vectors should be ndarray of float32')

self._faiss_index.add(vectors)

def query(self, keys: np.ndarray, top_k: int, *args, **kwargs) -> List[List[Tuple]]:
if keys.dtype != np.float32:
raise ValueError("vectors should be ndarray of float32")
raise ValueError('vectors should be ndarray of float32')

score, ids = self._faiss_index.search(keys, top_k)
ret = []

0 comments on commit 45a078d

Please sign in to comment.