From 299ba0bdfbd57f2c9cfb5121c15fe0bfea35e990 Mon Sep 17 00:00:00 2001 From: Bilal Qamar <59555732+BilalQamar95@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:00:04 +0500 Subject: [PATCH] perf: updated Dockerfile to optimize requirements installation and dependency caching --- .../workflows/push-program-intent-engagement-image.yaml | 6 +++++- dockerfiles/program-intent-engagement.Dockerfile | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push-program-intent-engagement-image.yaml b/.github/workflows/push-program-intent-engagement-image.yaml index f3dceae..5294be7 100644 --- a/.github/workflows/push-program-intent-engagement-image.yaml +++ b/.github/workflows/push-program-intent-engagement-image.yaml @@ -9,6 +9,11 @@ on: schedule: - cron: "0 4 * * 1-5" # UTC Time +# Added for testing purposes. Will remove once the PR is finalised + pull_request: + branches: + - '**' + jobs: build-and-push-image: runs-on: ubuntu-latest @@ -43,7 +48,6 @@ jobs: push: true target: app tags: edxops/program-intent-engagement-dev:${{ steps.get-tag-name.outputs.result }} - platforms: linux/amd64,linux/arm64 - name: Send failure notification if: failure() diff --git a/dockerfiles/program-intent-engagement.Dockerfile b/dockerfiles/program-intent-engagement.Dockerfile index efb0815..3f232fb 100644 --- a/dockerfiles/program-intent-engagement.Dockerfile +++ b/dockerfiles/program-intent-engagement.Dockerfile @@ -77,19 +77,22 @@ RUN useradd -m --shell /bin/false app WORKDIR /edx/app/program-intent-engagement -# cloning git repo -RUN curl -L https://github.com/edx/program-intent-engagement/archive/refs/heads/main.tar.gz | tar -xz --strip-components=1 +# Create required directories for requirements +RUN mkdir -p requirements ARG INTENT_MANAGEMENT_VENV_DIR="/edx/app/venvs/program-intent-management" RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${INTENT_MANAGEMENT_VENV_DIR} # Dependencies are installed as root so they cannot be modified by the application user. +RUN curl -L -o requirements/production.txt https://raw.githubusercontent.com/edx/program-intent-engagement/main/requirements/production.txt RUN pip install -r requirements/production.txt RUN mkdir -p /edx/var/log +# Clone the repository +RUN curl -L https://github.com/edx/program-intent-engagement/archive/refs/heads/main.tar.gz | tar -xz --strip-components=1 + # Code is owned by root so it cannot be modified by the application user. -# So we copy it before changing users. USER app # Gunicorn 19 does not log to stdout or stderr by default. Once we are past gunicorn 19, the logging to STDOUT need not be specified.