From 34e9d60eb25d920dd1cb33bc8f339693bf3bd6a2 Mon Sep 17 00:00:00 2001 From: Hunia Fatima Date: Fri, 4 Oct 2024 16:58:07 +0500 Subject: [PATCH 1/2] perf: optimised to handle dependecies cache --- dockerfiles/registrar.Dockerfile | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/dockerfiles/registrar.Dockerfile b/dockerfiles/registrar.Dockerfile index 0ff55fe..5e71860 100644 --- a/dockerfiles/registrar.Dockerfile +++ b/dockerfiles/registrar.Dockerfile @@ -61,10 +61,6 @@ 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 @@ -77,7 +73,13 @@ EXPOSE 18735 FROM app as dev -RUN pip install --no-cache-dir -r requirements/devstack.txt +# fetching the requirement file that is needed +RUN curl -L -o devstack.txt https://raw.githubusercontent.com/edx/registrar/master/requirements/devstack.txt + +RUN pip install --no-cache-dir -r ${REGISTRAR_CODE_DIR}/devstack.txt + +# 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 +87,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 +# fetching the requirement file that is needed +RUN curl -L -o production.txt https://raw.githubusercontent.com/edx/registrar/master/requirements/production.txt + +RUN pip install --no-cache-dir -r ${REGISTRAR_CODE_DIR}/production.txt + +# 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 From 4b9b6136c5d15d3380c722923874028c7aa3f8ca Mon Sep 17 00:00:00 2001 From: Hunia Fatima Date: Mon, 7 Oct 2024 18:09:28 +0500 Subject: [PATCH 2/2] fix: incorporated review request --- dockerfiles/registrar.Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dockerfiles/registrar.Dockerfile b/dockerfiles/registrar.Dockerfile index 5e71860..1581234 100644 --- a/dockerfiles/registrar.Dockerfile +++ b/dockerfiles/registrar.Dockerfile @@ -61,6 +61,8 @@ ENV REGISTRAR_CODE_DIR ${REGISTRAR_CODE_DIR} # Working directory will be root of repo. WORKDIR ${REGISTRAR_CODE_DIR} +RUN mkdir -p requirements + RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${REGISTRAR_VENV_DIR} RUN pip install --upgrade pip setuptools @@ -74,9 +76,9 @@ EXPOSE 18735 FROM app as dev # fetching the requirement file that is needed -RUN curl -L -o devstack.txt https://raw.githubusercontent.com/edx/registrar/master/requirements/devstack.txt +RUN curl -L -o requirements/devstack.txt https://raw.githubusercontent.com/edx/registrar/master/requirements/devstack.txt -RUN pip install --no-cache-dir -r ${REGISTRAR_CODE_DIR}/devstack.txt +RUN pip install --no-cache-dir -r ${REGISTRAR_CODE_DIR}/requirements/devstack.txt # 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 @@ -88,9 +90,9 @@ CMD while true; do python ./manage.py runserver 0.0.0.0:18734; sleep 2; done FROM app as prod # fetching the requirement file that is needed -RUN curl -L -o production.txt https://raw.githubusercontent.com/edx/registrar/master/requirements/production.txt +RUN curl -L -o requirements/production.txt https://raw.githubusercontent.com/edx/registrar/master/requirements/production.txt -RUN pip install --no-cache-dir -r ${REGISTRAR_CODE_DIR}/production.txt +RUN pip install --no-cache-dir -r ${REGISTRAR_CODE_DIR}/requirements/production.txt # 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