Skip to content
Snippets Groups Projects
Dockerfile 1.04 KiB
Newer Older
  • Learn to ignore specific revisions
  • #do not use an alpine-based image, it is too cumbersome to install all the necessary components to make the C/C++
    #dependencies in the requirements.txt work
    
    FROM python:3.8-slim as BUILD_IMAGE
    
    
    RUN useradd -ms /bin/bash mc
    WORKDIR /home/mc
    RUN python -m venv venv
    
    COPY mc_backend/requirements.txt requirements.txt
    
    RUN venv/bin/pip install --no-cache-dir --default-timeout=120 -r requirements.txt
    
    
    # use multi-stage image to reduce Docker image size
    FROM python:3.8-slim
    WORKDIR /home/mc
    COPY --from=BUILD_IMAGE /home/mc/venv venv
    
    RUN apt-get update
    # add C compiler for faster execution of gensim models, such as Word Embeddings
    RUN apt-get install -y build-essential
    # reinstall gensim to make it recognize the new C compiler
    RUN venv/bin/pip uninstall -y gensim
    
    COPY mc_backend/requirements.txt mc_backend/requirements.txt
    
    RUN venv/bin/pip install --no-cache-dir --default-timeout=120 -r mc_backend/requirements.txt
    # copy H5P templates for exercise generation in the backend
    COPY mc_frontend/src/assets/h5p h5p
    COPY mc_backend mc_backend
    
    WORKDIR /home/mc/mc_backend