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 5ee7c3b commit 1dd8b4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/push-enterprise-catalog-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
9 changes: 7 additions & 2 deletions dockerfiles/enterprise-catalog.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
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-catalog/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1
RUN mkdir -p requirements

ENV VIRTUAL_ENV=/venv
RUN virtualenv -p python$PYTHON_VERSION $VIRTUAL_ENV
Expand All @@ -71,8 +70,13 @@ EXPOSE 8161

RUN useradd -m --shell /bin/false app


RUN curl -L -o requirements/production.txt https://raw.githubusercontent.com/openedx/enterprise-catalog/master/requirements/production.txt
RUN pip install -r requirements/production.txt

# Cloning the repository
RUN curl -L https://github.com/openedx/enterprise-catalog/archive/refs/heads/master.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 All @@ -99,6 +103,7 @@ FROM app as legacy_devapp
EXPOSE 18160
EXPOSE 18161
USER root
RUN curl -L -o requirements/dev.txt https://raw.githubusercontent.com/openedx/enterprise-catalog/master/requirements/dev.txt
RUN pip install -r requirements/dev.txt
USER app
CMD ["gunicorn", "--reload", "--workers=2", "--name", "enterprise_catalog", "-b", ":18160", "-c", "/edx/app/enterprise_catalog/enterprise_catalog/enterprise_catalog/docker_gunicorn_configuration.py", "--log-file", "-", "--max-requests=1000", "enterprise_catalog.wsgi:application"]

0 comments on commit 1dd8b4e

Please sign in to comment.