Skip to content

Commit

Permalink
perf: updated Dockerfile to optimize requirements installation and de…
Browse files Browse the repository at this point in the history
…pendency caching
  • Loading branch information
BilalQamar95 committed Oct 17, 2024
1 parent 4fc2070 commit 299ba0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/push-program-intent-engagement-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 6 additions & 3 deletions dockerfiles/program-intent-engagement.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 299ba0b

Please sign in to comment.