Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions dockerfiles/enterprise-access.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ MAINTAINER sre@edx.org

# python; ubuntu doesnt ship with python, so this is the python we will use to run the application

# python3-pip; install pip to install application requirements.txt files

# pkg-config
# mysqlclient>=2.2.0 requires this (https://github.com/PyMySQL/mysqlclient/issues/620)

Expand Down Expand Up @@ -51,24 +49,18 @@ RUN apt-get update && apt-get -qy install --no-install-recommends \
curl \
libffi-dev \
libsqlite3-dev \
python3-pip \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-venv

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

RUN pip install --upgrade pip setuptools

# Remove package lists to reduce image size
RUN rm -rf /var/lib/apt/lists/*

# Set up Python environment and install virtualenv
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
RUN pip install virtualenv

# Create a virtualenv for sanity
ENV VIRTUAL_ENV=/edx/venvs/enterprise-access
RUN virtualenv -p python${PYTHON_VERSION} $VIRTUAL_ENV
RUN python${PYTHON_VERSION} -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

WORKDIR /tmp
Expand Down Expand Up @@ -96,6 +88,8 @@ RUN mkdir -p requirements
RUN curl -L -o requirements/pip.txt https://raw.githubusercontent.com/edx/enterprise-access/main/requirements/pip.txt
RUN curl -L -o requirements/production.txt https://raw.githubusercontent.com/edx/enterprise-access/main/requirements/production.txt
# Dependencies are installed as root so they cannot be modified by the application user.
# Pin setuptools to avoid pkg_resources removal issue
RUN pip install "setuptools<82.0.0"
RUN pip install -r requirements/pip.txt
RUN pip install -r requirements/production.txt

Expand All @@ -112,6 +106,8 @@ CMD gunicorn --workers=2 --name enterprise-access -c /edx/app/enterprise-access/

FROM app AS devstack
USER root
# Pin setuptools to avoid pkg_resources removal issue
RUN pip install "setuptools<82.0.0"
RUN pip install -r requirements/dev.txt

CMD gunicorn --workers=2 --name enterprise-access -c /edx/app/enterprise-access/enterprise_access/docker_gunicorn_configuration.py --log-file - --max-requests=1000 enterprise_access.wsgi:application
16 changes: 7 additions & 9 deletions dockerfiles/enterprise-subsidy.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ MAINTAINER sre@edx.org

# python; ubuntu doesnt ship with python, so this is the python we will use to run the application

# python3-pip; install pip to install application requirements.txt files

# pkg-config
# mysqlclient>=2.2.0 requires this (https://github.com/PyMySQL/mysqlclient/issues/620)

Expand Down Expand Up @@ -51,22 +49,18 @@ RUN apt-get update && apt-get -qy install --no-install-recommends \
curl \
libffi-dev \
libsqlite3-dev \
python3-pip \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-venv

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

# delete apt package lists because we do not need them inflating our image
RUN rm -rf /var/lib/apt/lists/*

# need to use virtualenv pypi package with Python 3.12
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
RUN pip install virtualenv

# Create a virtualenv for sanity
ENV VIRTUAL_ENV=/edx/venvs/enterprise-subsidy
RUN virtualenv -p python${PYTHON_VERSION} $VIRTUAL_ENV
RUN python${PYTHON_VERSION} -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN locale-gen en_US.UTF-8
Expand All @@ -85,6 +79,8 @@ RUN mkdir -p requirements
RUN curl -L -o requirements/pip.txt https://raw.githubusercontent.com/edx/enterprise-subsidy/main/requirements/pip.txt
RUN curl -L -o requirements/production.txt https://raw.githubusercontent.com/edx/enterprise-subsidy/main/requirements/production.txt

# Pin setuptools to avoid pkg_resources removal issue
RUN pip install "setuptools<82.0.0"
RUN pip install -r requirements/pip.txt
RUN pip install -r requirements/production.txt

Expand All @@ -102,6 +98,8 @@ CMD gunicorn --workers=2 --name enterprise-subsidy -c /edx/app/enterprise-subsid

FROM app AS devstack
USER root
# Pin setuptools to avoid pkg_resources removal issue
RUN pip install "setuptools<82.0.0"
RUN pip install -r requirements/dev.txt
USER app
CMD gunicorn --workers=2 --name enterprise-subsidy -c /edx/app/enterprise-subsidy/enterprise_subsidy/docker_gunicorn_configuration.py --log-file - --max-requests=1000 enterprise_subsidy.wsgi:application