From fd8887e6fcab05b68b1e0c6bc036b4cc625d1448 Mon Sep 17 00:00:00 2001 From: Hunia Fatima Date: Fri, 4 Oct 2024 16:58:07 +0500 Subject: [PATCH] perf: optimised to handle dependecies cache --- dockerfiles/registrar.Dockerfile | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/dockerfiles/registrar.Dockerfile b/dockerfiles/registrar.Dockerfile index 0ff55fe..ba27954 100644 --- a/dockerfiles/registrar.Dockerfile +++ b/dockerfiles/registrar.Dockerfile @@ -61,23 +61,28 @@ ENV REGISTRAR_CODE_DIR ${REGISTRAR_CODE_DIR} # Working directory will be root of repo. WORKDIR ${REGISTRAR_CODE_DIR} -# cloning git repo -RUN curl -L https://github.com/edx/registrar/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1 - - RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${REGISTRAR_VENV_DIR} RUN pip install --upgrade pip setuptools ENV REGISTRAR_CFG="${COMMON_CFG_DIR}/registrar.yml" +# extracting requirements folder initially +RUN curl -L https://github.com/edx/registrar/archive/refs/heads/master/requirements.tar.gz | tar -xz --strip-components=1 + # Expose ports. EXPOSE 18734 EXPOSE 18735 FROM app as dev -RUN pip install --no-cache-dir -r requirements/devstack.txt +RUN pip install --no-cache-dir -r ${REGISTRAR_CODE_DIR}/requirements/devstack.txt + +# removing extra requirements folder +RUN rm -rf requirements + +# cloning the repository after requirements installation +RUN curl -L https://github.com/edx/registrar/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1 ENV DJANGO_SETTINGS_MODULE registrar.settings.devstack @@ -85,7 +90,13 @@ CMD while true; do python ./manage.py runserver 0.0.0.0:18734; sleep 2; done FROM app as prod -RUN pip install --no-cache-dir -r ${REGISTRAR_CODE_DIR}/requirements/production.txt +RUN pip install --no-cache-dir -r ${REGISTRAR_CODE_DIR}/requirements/production.txt + +# removing extra requirements folder +RUN rm -rf requirements + +# cloning the repository after requirements installation +RUN curl -L https://github.com/edx/registrar/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1 ENV DJANGO_SETTINGS_MODULE registrar.settings.production