<commit_before>FROM ubuntu:focal as base

# Warning: This file is experimental.
#
# Short-term goals:
# * Be a suitable replacement for the `edxops/edxapp` image in devstack (in progress).
# * Take advantage of Docker caching layers: aim to put commands in order of
#   increasing cache-busting frequency.
# * Related to ^, use no Ansible or Paver.
# Long-term goal:
# * Be a suitable base for production LMS and CMS images (THIS IS NOT YET THE CASE!).
#
# Install system requirements.
# We update, upgrade, and delete lists all in one layer
# in order to reduce total image size.
RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install --yes \
        # Global requirements
        build-essential \
        curl \
        # If we don't need gcc, we should remove it.
        g++ \
        gcc \
        git \
        git-core \
        language-pack-en \
        libfreetype6-dev \
        libmysqlclient-dev \
        libssl-dev \
        libxml2-dev \
        libxmlsec1-dev \
        libxslt1-dev \
        swig \
        # openedx requirements
        gettext \
        gfortran \
        graphviz \
        libffi-dev \
        libfreetype6-dev \
        libgeos-dev \
        libgraphviz-dev \
        libjpeg8-dev \
        liblapack-dev \
        libpng-dev \
        libsqlite3-dev \
        libxml2-dev \
        libxmlsec1-dev \
        libxslt1-dev \
        # lynx: Required by https://github.com/edx/edx-platform/blob/b489a4ecb122/openedx/core/lib/html_to_text.py#L16
        lynx \
        ntp \
        pkg-config \
        python3-dev \
        python3-venv && \
    rm -rf /var/lib/apt/lists/*

# Set locale.
RUN locale-gen en_US.UTF-8

# Env vars: locale
ENV LANG='en_US.UTF-8'
ENV LANGUAGE='en_US:en'
ENV LC_ALL='en_US.UTF-8'

# Env vars: configuration
ENV CONFIG_ROOT='/edx/etc'
ENV LMS_CFG="$CONFIG_ROOT/lms.yml"
ENV CMS_CFG="$CONFIG_ROOT/cms.yml"
ENV EDX_PLATFORM_SETTINGS='production'

# Env vars: path
ENV VIRTUAL_ENV='/edx/app/edxapp/venvs/edxapp'
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
ENV PATH="/edx/app/edxapp/edx-platform/node_modules/.bin:${PATH}"
ENV PATH="/edx/app/edxapp/edx-platform/bin:${PATH}"
ENV PATH="/edx/app/edxapp/nodeenv/bin:${PATH}"

# Create config directory. Create, define, and switch to working directory.
RUN mkdir -p "$CONFIG_ROOT"
WORKDIR /edx/app/edxapp/edx-platform

# Env vars: paver
# We intentionally don't use paver in this Dockerfile, but Devstack may invoke paver commands
# during provisioning. Enabling NO_PREREQ_INSTALL tells paver not to re-install Python
# requirements for every paver command, potentially saving a lot of developer time.
ENV NO_PREREQ_INSTALL='1'

# Set up a Python virtual environment.
# It is already 'activated' because $VIRTUAL_ENV/bin was put on $PATH.
RUN python3.8 -m venv "$VIRTUAL_ENV"

# Install Python requirements.
# Requires copying over requirements files, but not entire repository.
# We filter out the local ('common/*' and 'openedx/*', and '.') Python projects,
# because those require code in order to be installed. They will be installed
# later. This step can be simplified when the local projects are dissolved
# (see https://openedx.atlassian.net/browse/BOM-2579).
COPY requirements requirements
RUN  sed '/^-e \(common\/\|openedx\/\|.\)/d' requirements/edx/base.txt \
  > requirements/edx/base-minus-local.txt
RUN pip install -r requirements/pip.txt
RUN pip install -r requirements/edx/base-minus-local.txt

# Set up a Node environment and install Node requirements.
# Must be done after Python requirements, since nodeenv is installed
# via pip.
# The node environment is already 'activated' because its .../bin was put on $PATH.
RUN nodeenv /edx/app/edxapp/nodeenv --node=12.11.1 --prebuilt
RUN npm install -g npm@8.5.x
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm set progress=false && npm install

# Copy over remaining parts of repository (including all code).
COPY . .

# Install Python requirements again in order to capture local projects, which
# were skipped earlier. This should be much quicker than if were installing
# all requirements from scratch.
RUN pip install -r requirements/edx/base.txt

##################################################
# Define LMS docker-based non-dev target.
FROM base as lms-docker
ENV SERVICE_VARIANT lms
ARG LMS_CFG_OVERRIDE
RUN echo "$LMS_CFG_OVERRIDE"
ENV LMS_CFG="${LMS_CFG_OVERRIDE:-$LMS_CFG}"
RUN echo "$LMS_CFG"
ENV EDX_PLATFORM_SETTINGS='docker-production'<commit_msg>chore: update Docker Image to use node 16 (#30444)<commit_after>FROM ubuntu:focal as base

# Warning: This file is experimental.
#
# Short-term goals:
# * Be a suitable replacement for the `edxops/edxapp` image in devstack (in progress).
# * Take advantage of Docker caching layers: aim to put commands in order of
#   increasing cache-busting frequency.
# * Related to ^, use no Ansible or Paver.
# Long-term goal:
# * Be a suitable base for production LMS and CMS images (THIS IS NOT YET THE CASE!).
#
# Install system requirements.
# We update, upgrade, and delete lists all in one layer
# in order to reduce total image size.
RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install --yes \
        # Global requirements
        build-essential \
        curl \
        # If we don't need gcc, we should remove it.
        g++ \
        gcc \
        git \
        git-core \
        language-pack-en \
        libfreetype6-dev \
        libmysqlclient-dev \
        libssl-dev \
        libxml2-dev \
        libxmlsec1-dev \
        libxslt1-dev \
        swig \
        # openedx requirements
        gettext \
        gfortran \
        graphviz \
        libffi-dev \
        libfreetype6-dev \
        libgeos-dev \
        libgraphviz-dev \
        libjpeg8-dev \
        liblapack-dev \
        libpng-dev \
        libsqlite3-dev \
        libxml2-dev \
        libxmlsec1-dev \
        libxslt1-dev \
        # lynx: Required by https://github.com/edx/edx-platform/blob/b489a4ecb122/openedx/core/lib/html_to_text.py#L16
        lynx \
        ntp \
        pkg-config \
        python3-dev \
        python3-venv && \
    rm -rf /var/lib/apt/lists/*

# Set locale.
RUN locale-gen en_US.UTF-8

# Env vars: locale
ENV LANG='en_US.UTF-8'
ENV LANGUAGE='en_US:en'
ENV LC_ALL='en_US.UTF-8'

# Env vars: configuration
ENV CONFIG_ROOT='/edx/etc'
ENV LMS_CFG="$CONFIG_ROOT/lms.yml"
ENV CMS_CFG="$CONFIG_ROOT/cms.yml"
ENV EDX_PLATFORM_SETTINGS='production'

# Env vars: path
ENV VIRTUAL_ENV='/edx/app/edxapp/venvs/edxapp'
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
ENV PATH="/edx/app/edxapp/edx-platform/node_modules/.bin:${PATH}"
ENV PATH="/edx/app/edxapp/edx-platform/bin:${PATH}"
ENV PATH="/edx/app/edxapp/nodeenv/bin:${PATH}"

# Create config directory. Create, define, and switch to working directory.
RUN mkdir -p "$CONFIG_ROOT"
WORKDIR /edx/app/edxapp/edx-platform

# Env vars: paver
# We intentionally don't use paver in this Dockerfile, but Devstack may invoke paver commands
# during provisioning. Enabling NO_PREREQ_INSTALL tells paver not to re-install Python
# requirements for every paver command, potentially saving a lot of developer time.
ENV NO_PREREQ_INSTALL='1'

# Set up a Python virtual environment.
# It is already 'activated' because $VIRTUAL_ENV/bin was put on $PATH.
RUN python3.8 -m venv "$VIRTUAL_ENV"

# Install Python requirements.
# Requires copying over requirements files, but not entire repository.
# We filter out the local ('common/*' and 'openedx/*', and '.') Python projects,
# because those require code in order to be installed. They will be installed
# later. This step can be simplified when the local projects are dissolved
# (see https://openedx.atlassian.net/browse/BOM-2579).
COPY requirements requirements
RUN  sed '/^-e \(common\/\|openedx\/\|.\)/d' requirements/edx/base.txt \
  > requirements/edx/base-minus-local.txt
RUN pip install -r requirements/pip.txt
RUN pip install -r requirements/edx/base-minus-local.txt

# Set up a Node environment and install Node requirements.
# Must be done after Python requirements, since nodeenv is installed
# via pip.
# The node environment is already 'activated' because its .../bin was put on $PATH.
RUN nodeenv /edx/app/edxapp/nodeenv --node=16.14.0 --prebuilt
RUN npm install -g npm@8.5.x
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm set progress=false && npm install

# Copy over remaining parts of repository (including all code).
COPY . .

# Install Python requirements again in order to capture local projects, which
# were skipped earlier. This should be much quicker than if were installing
# all requirements from scratch.
RUN pip install -r requirements/edx/base.txt

##################################################
# Define LMS docker-based non-dev target.
FROM base as lms-docker
ENV SERVICE_VARIANT lms
ARG LMS_CFG_OVERRIDE
RUN echo "$LMS_CFG_OVERRIDE"
ENV LMS_CFG="${LMS_CFG_OVERRIDE:-$LMS_CFG}"
RUN echo "$LMS_CFG"
ENV EDX_PLATFORM_SETTINGS='docker-production'
{'fraction_non_alphanumeric': 0.11008562215056154, 'fraction_numerical': 0.00922940064494607, 'mean_word_length': 3.0752152242863615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3562631', 'n_tokens_mistral': 3005, 'n_tokens_neox': 2846, 'n_words': 909}