FROM ubuntu:16.04 ############ common to lms & cms # Install system requirements RUN apt update && \ # Global requirements apt install -y language-pack-en git python-virtualenv build-essential software-properties-common curl git-core libxml2-dev libxslt1-dev python-pip libmysqlclient-dev python-apt python-dev libxmlsec1-dev libfreetype6-dev swig gcc g++ \ # openedx requirements gettext gfortran graphviz graphviz-dev libffi-dev libfreetype6-dev libgeos-dev libjpeg8-dev liblapack-dev libpng12-dev libsqlite3-dev libxml2-dev libxmlsec1-dev libxslt1-dev nodejs npm ntp pkg-config \ # Our requirements mysql-client \ # Install symlink so that we have access to 'node' binary without virtualenv. # This replaces the "nodeenv" install. nodejs-legacy \ && rm -rf /var/lib/apt/lists/* # Dockerize will be useful to wait for mysql DB availability ARG DOCKERIZE_VERSION=v0.6.1 RUN curl -L -o /tmp/dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ && tar -C /usr/local/bin -xzvf /tmp/dockerize.tar.gz \ && rm /tmp/dockerize.tar.gz ## Checkout edx-platform code ARG EDX_PLATFORM_REPOSITORY=https://github.com/edx/edx-platform.git ARG EDX_PLATFORM_VERSION=open-release/hawthorn.2 RUN mkdir -p /openedx/edx-platform && \ git clone $EDX_PLATFORM_REPOSITORY --branch $EDX_PLATFORM_VERSION --depth 1 /openedx/edx-platform WORKDIR /openedx/edx-platform # Download extra locales to /openedx/locale RUN cd /tmp \ && curl -L -o openedx-i18n.tar.gz https://github.com/regisb/openedx-i18n/archive/hawthorn.tar.gz \ && tar xzf /tmp/openedx-i18n.tar.gz \ && mv openedx-i18n-hawthorn/edx-platform/locale/ /openedx/locale/ \ && rm -rf openedx-i18n* # Install python requirements (clone source repos in a separate dir, otherwise # they will be overwritten when we mount edx-platform) ENV NO_PYTHON_UNINSTALL 1 RUN pip install --src ../venv/src -r requirements/edx/base.txt RUN pip install --src ../venv/src -r requirements/edx/development.txt # Install patched version of ora2 RUN pip uninstall -y ora2 && \ pip install --src ../venv/src git+https://github.com/regisb/edx-ora2.git@open-release/hawthorn.2#egg=ora2==2.1.17 # Install nodejs requirements RUN npm set progress=false \ && npm install ENV PATH ./node_modules/.bin:${PATH} # Install private requirements: this is useful for installing custom xblocks. # In particular, to install xblocks from a private repository, clone the # repositories to ./requirements on the host and add `-e ./myxblock/` to # ./requirements/private.txt. COPY ./requirements/ /openedx/requirements RUN touch /openedx/requirements/private.txt \ && pip install -r /openedx/requirements/private.txt # Link configuration files to common /openedx/config folder, which should later # be mounted as a volume. Note that this image will not be functional until # config files have been mounted inside the container RUN mkdir -p /openedx/env/universal/lms /openedx/env/universal/cms \ && ln -s /openedx/env/universal/lms/ /openedx/edx-platform/lms/envs/universal \ && ln -s /openedx/env/universal/cms/ /openedx/edx-platform/cms/envs/universal \ && ln -s /openedx/env/lms.env.json /openedx/ \ && ln -s /openedx/env/cms.env.json /openedx/ \ && ln -s /openedx/env/lms.auth.json /openedx/ \ && ln -s /openedx/env/cms.auth.json /openedx/ COPY settings/lms/*.py /openedx/env/universal/lms/ COPY settings/cms/*.py /openedx/env/universal/cms/ # Copy scripts COPY ./bin /openedx/bin ENV PATH /openedx/bin:${PATH} # Collect production assets. By default, only assets from the default theme # will be processed. This makes the docker image lighter and faster to build. # Only the custom themes added to /openedx/themes will be compiled. # Here, we don't run "paver update_assets" which is slow, compiles all themes # and requires a complex settings file. Instead, we decompose the commands # and run each one individually to collect the production static assets to # /openedx/staticfiles. RUN openedx-assets xmodule \ && openedx-assets npm \ && openedx-assets webpack --env=prod \ && openedx-assets common COPY ./themes/ /openedx/themes/ RUN openedx-assets themes \ && openedx-assets collect --settings=universal.assets # service variant is "lms" or "cms" ENV SERVICE_VARIANT lms ENV SETTINGS universal.production # Entrypoint will fix permissions of all files and run commands as openedx ENTRYPOINT ["docker-entrypoint.sh"] # Run server EXPOSE 8000 CMD gunicorn --name ${SERVICE_VARIANT} --bind=0.0.0.0:8000 --max-requests=1000 ${SERVICE_VARIANT}.wsgi:application