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 16, 2024
1 parent a375c39 commit dbb60bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/push-enterprise-subsidy-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
12 changes: 9 additions & 3 deletions dockerfiles/enterprise-subsidy.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RUN apt-get update && apt-get -qy install --no-install-recommends \
python3-pip \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-distutils
python${PYTHON_VERSION}-distutils

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

Expand All @@ -65,8 +65,7 @@ RUN rm -rf /var/lib/apt/lists/*
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
RUN pip install virtualenv

# cloning git repo
RUN curl -L https://github.com/openedx/enterprise-subsidy/archive/refs/heads/main.tar.gz | tar -xz --strip-components=1
RUN mkdir -p requirements

# Create a virtualenv for sanity
ENV VIRTUAL_ENV=/edx/venvs/enterprise-subsidy
Expand All @@ -83,11 +82,18 @@ EXPOSE 18280
RUN useradd -m --shell /bin/false app

# Dependencies are installed as root so they cannot be modified by the application user.

RUN curl -L -o requirements/pip.txt https://raw.githubusercontent.com/openedx/enterprise-subsidy/main/requirements/pip.txt
RUN curl -L -o requirements/production.txt https://raw.githubusercontent.com/openedx/enterprise-subsidy/main/requirements/production.txt

RUN pip install -r requirements/pip.txt
RUN pip install -r requirements/production.txt

RUN mkdir -p /edx/var/log

# cloning git repo
RUN curl -L https://github.com/openedx/enterprise-subsidy/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
Expand Down

0 comments on commit dbb60bd

Please sign in to comment.