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 a1d82d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 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
13 changes: 8 additions & 5 deletions dockerfiles/program-intent-engagement.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,24 @@ ENV DJANGO_SETTINGS_MODULE program_intent_engagement.settings.production
EXPOSE 18781
RUN useradd -m --shell /bin/false app

WORKDIR /edx/app/program-intent-engagement
# Create required directories for requirements
RUN mkdir -p requirements

# cloning git repo
RUN curl -L https://github.com/edx/program-intent-engagement/archive/refs/heads/main.tar.gz | tar -xz --strip-components=1
WORKDIR /edx/app/program-intent-engagement

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 pip install -r requirements/production.txt
RUN curl -L -o requirements/production.txt https://raw.githubusercontent.com/edx/program-intent-engagement/main/requirements/production.txt
RUN pip install --no-cache-dir -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 a1d82d2

Please sign in to comment.