Skip to content

Commit

Permalink
Decentralized Devstack changes: Add and push Dockerfile; add decentra…
Browse files Browse the repository at this point in the history
…lized devstack settings (#24666)

* Add and push Dockerfile; add decentralized devstack settings

Co-Authored-By: Diana Huang <[email protected]>
Co-Authored-By: Kyle McCormick <[email protected]>

* Remove Python requirements hack

Remove the attempted optimization to the installation of Python
package dependencies.  The dependencies in edx-platform change
about three times per day, so this was of dubious value.  And
because npm is run through nodeenv, which is a Python package,
the Python dependencies installation has to happen first.

* ARCHBOM-1439: Changing workdir to /edx/app/edxapp/edx-platform (#24835)

Context: The Dockerfile tries to stay in sych with legacy stuff.
In the ansible we configure the directory structure such that things
relating to the app but not in the codebase,
such as the env file wind up in /edx/app/edxapp/.
And the codebase winds up in /edx/app/edxapp/edx-platform.

I think due to accident, the dockerfile does
/edx/app/edx-platform/edx-platform instead of /edx/app/edxapp/edx-platform.

This commit tries to have Dockerfile more reflect what is currently happening in production

* Update ports for decentralized devstack ARCHBOM-1447 (#24841)

Switch from the LMS ports we've historically used for NGINX to those used for gunicorn, and fix the Studio ports to match the ones we've historically used for its gunicorn service. Also removed some leftover bits of the requirements hack.

Co-authored-by: Adam Blackwell <[email protected]>
Co-authored-by: Diana Huang <[email protected]>
Co-authored-by: jinder1s <[email protected]>
Co-authored-by: Jeremy Bowman <[email protected]>
Co-authored-by: Manjinder Singh <[email protected]>
  • Loading branch information
6 people authored Sep 3, 2020
1 parent 1757fa3 commit b24cb48
Show file tree
Hide file tree
Showing 9 changed files with 1,799 additions and 106 deletions.
153 changes: 75 additions & 78 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

/test_root/
.git
Dockerfile

### Files private to developers

Expand All @@ -20,98 +19,96 @@ cms/envs/private.py
# end-noclean

### Python artifacts
*.pyc
**/*.pyc

### Editor and IDE artifacts
*~
*.swp
*.orig
/nbproject
.idea/
.redcar/
codekit-config.json
.pycharm_helpers/
/_mac/*
/IntelliLang.xml
/conda_packages.xml
/databaseSettings.xml
/diff.xml
/debugger.xml
/editor.xml
/ide.general.xml
/inspection/Default.xml
/other.xml
/packages.xml
/web-browsers.xml
**/*~
**/*.swp
**/*.orig
**/nbproject
**/.idea/
**/.redcar/
**/codekit-config.json
**/.pycharm_helpers/
**/_mac/*
**/IntelliLang.xml
**/conda_packages.xml
**/databaseSettings.xml
**/diff.xml
**/debugger.xml
**/editor.xml
**/ide.general.xml
**/inspection/Default.xml
**/other.xml
**/packages.xml
**/web-browsers.xml

### NFS artifacts
.nfs*
**/.nfs*

### OS X artifacts
*.DS_Store
.AppleDouble
:2e_*
:2e#
**/*.DS_Store
**/.AppleDouble
**/:2e_*
**/:2e#

### Internationalization artifacts
*.mo
*.po
*.prob
*.dup
!django.po
!django.mo
!djangojs.po
!djangojs.mo
**/*.mo
**/*.po
**/*.prob
**/*.dup
!**/django.po
!**/django.mo
!**/djangojs.po
!**/djangojs.mo
conf/locale/en/LC_MESSAGES/*.mo
conf/locale/fake*/LC_MESSAGES/*.po
conf/locale/fake*/LC_MESSAGES/*.mo
# this was a mistake in i18n_tools, now fixed.
conf/locale/messages.mo

### Testing artifacts
.testids/
.noseids
nosetests.xml
.cache/
.coverage
.coverage.*
coverage.xml
cover/
cover_html/
reports/
jscover.log
jscover.log.*
.pytest_cache/
pytest_task*.txt
.tddium*
**/.testids/
**/.noseids
**/nosetests.xml
**/.cache/
**/.coverage
**/.coverage.*
**/coverage.xml
**/cover/
**/cover_html/
**/reports/
**/jscover.log
**/jscover.log.*
**/.pytest_cache/
**/pytest_task*.txt
**/.tddium*
common/test/data/test_unicode/static/
test_root/courses/
test_root/data/test_bare.git/
test_root/export_course_repos/
test_root/paver_logs/
test_root/uploads/
django-pyfs
.tox/
**/django-pyfs
**/.tox/
common/test/db_cache/bok_choy_*.yaml
common/test/data/badges/*.png

### Installation artifacts
*.egg-info
.pip_download_cache/
.prereqs_cache
.vagrant/
node_modules
bin/
**/*.egg-info
**/.pip_download_cache/
**/.prereqs_cache
**/.vagrant/
**/node_modules
**/bin/

### Static assets pipeline artifacts
*.scssc
**/*.scssc
lms/static/css/
lms/static/certificates/css/
cms/static/css/
common/static/common/js/vendor/
common/static/common/css/vendor/
common/static/bundles
webpack-stats.json
**/webpack-stats.json

### Styling generated from templates
lms/static/sass/*.css
Expand All @@ -125,30 +122,30 @@ cms/static/themed_sass/
themes/**/css

### Logging artifacts
log/
logs
chromedriver.log
ghostdriver.log
**/log/
**/logs
**/chromedriver.log
**/ghostdriver.log

### Celery artifacts ###
celerybeat-schedule
**/celerybeat-schedule

### Unknown artifacts
database.sqlite
courseware/static/js/mathjax/*
flushdb.sh
build
**/database.sqlite
**/courseware/static/js/mathjax/*
**/flushdb.sh
**/build
/src/
\#*\#
.env/
**/.env/
openedx/core/djangoapps/django_comment_common/comment_client/python
autodeploy.properties
.ws_migrations_complete
dist
*.bak
**/autodeploy.properties
**/.ws_migrations_complete
**/dist
**/*.bak

# Visual Studio Code
.vscode
**/.vscode

# Locally generated PII reports
pii_report
**/pii_report
83 changes: 59 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM ubuntu:xenial as base

# Warning: This file is experimental.

# Install system requirements
RUN apt update && \
RUN apt-get update && \
# Global requirements
DEBIAN_FRONTEND=noninteractive apt install -y \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
build-essential \
curl \
# If we don't need gcc, we should remove it.
Expand Down Expand Up @@ -40,7 +42,7 @@ RUN apt update && \
python3-dev \
python3-pip \
python3.5 \
-qy && rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/*

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
Expand All @@ -50,42 +52,75 @@ ENV LC_ALL en_US.UTF-8
RUN ln -s /usr/bin/pip3 /usr/bin/pip
RUN ln -s /usr/bin/python3 /usr/bin/python

WORKDIR /edx/app/edx-platform/edx-platform

COPY . /edx/app/edx-platform/edx-platform
WORKDIR /edx/app/edxapp/edx-platform

ENV PATH /edx/app/edx-platform/nodeenv/bin:${PATH}
ENV PATH /edx/app/edxapp/nodeenv/bin:${PATH}
ENV PATH ./node_modules/.bin:${PATH}
ENV PATH /edx/app/edx-platform/edx-platform/bin:${PATH}
ENV CONFIG_ROOT /edx/etc/
ENV PATH /edx/app/edxapp/edx-platform/bin:${PATH}
ENV SETTINGS production
RUN mkdir -p /edx/etc/

# TODO: Install requirements before copying in code.
RUN pip install setuptools==39.0.1 pip==9.0.3
# Install Python requirements
RUN pip install pip==20.0.2
COPY setup.py setup.py
COPY common common
COPY openedx openedx
COPY lms lms
COPY cms cms
COPY requirements/edx/base.txt requirements/edx/base.txt
RUN pip install -r requirements/edx/base.txt

RUN nodeenv /edx/app/edx-platform/nodeenv --node=8.9.3 --prebuilt
# Copy just JS requirements and install them.
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN nodeenv /edx/app/edxapp/nodeenv --node=12.11.1 --prebuilt
RUN npm set progress=false && npm install

RUN npm set progress=false \
&& npm install
ENV LMS_CFG /edx/etc/lms.yml
ENV STUDIO_CFG /edx/etc/studio.yml
COPY lms/devstack.yml /edx/etc/lms.yml
COPY cms/devstack.yml /edx/etc/studio.yml

RUN mkdir -p /edx/etc/

EXPOSE 18000
# Copy over remaining code.
# We do this as late as possible so that small changes to the repo don't bust
# the requirements cache.
COPY . .

FROM base as lms
ENV SERVICE_VARIANT lms
ENV LMS_CFG /edx/etc/lms.yaml
CMD gunicorn -c /edx/app/edx-platform/edx-platform/lms/docker_lms_gunicorn.py --name lms --bind=0.0.0.0:18000 --max-requests=1000 --access-logfile - lms.wsgi:application
ENV DJANGO_SETTINGS_MODULE lms.envs.production
EXPOSE 8000
CMD gunicorn -c /edx/app/edxapp/edx-platform/lms/docker_lms_gunicorn.py --name lms --bind=0.0.0.0:8000 --max-requests=1000 --access-logfile - lms.wsgi:application

FROM lms as lms-newrelic
RUN pip install newrelic
CMD newrelic-admin run-program gunicorn -c /edx/app/edx-platform/edx-platform/lms/docker_lms_gunicorn.py --name lms --bind=0.0.0.0:8000 --max-requests=1000 --access-logfile - lms.wsgi:application
CMD newrelic-admin run-program gunicorn -c /edx/app/edxapp/edx-platform/lms/docker_lms_gunicorn.py --name lms --bind=0.0.0.0:8000 --max-requests=1000 --access-logfile - lms.wsgi:application

FROM lms as lms-devstack
# TODO: This compiles static assets.
# However, it's a bit of a hack, it's slow, and it's inefficient because makes the final Docker cache layer very large.
# We ought to be able to this higher up in the Dockerfile, and do it the same for Prod and Devstack.
RUN mkdir -p test_root/log
ENV DJANGO_SETTINGS_MODULE ""
RUN NO_PREREQ_INSTALL=1 paver update_assets lms --settings devstack_decentralized
ENV DJANGO_SETTINGS_MODULE lms.envs.devstack_decentralized

FROM base as cms
FROM base as studio
ENV SERVICE_VARIANT cms
ENV STUDIO_CFG /edx/etc/studio.yaml
CMD gunicorn -c /edx/app/edx-platform/edx-platform/cms/docker_cms_gunicorn.py --name cms --bind=0.0.0.0:8000 --max-requests=1000 --access-logfile - cms.wsgi:application
ENV DJANGO_SETTINGS_MODULE cms.envs.production
EXPOSE 8010
CMD gunicorn -c /edx/app/edxapp/edx-platform/cms/docker_cms_gunicorn.py --name cms --bind=0.0.0.0:8010 --max-requests=1000 --access-logfile - cms.wsgi:application

FROM cms as cms-newrelic
FROM studio as studio-newrelic
RUN pip install newrelic
CMD newrelic-admin run-program gunicorn -c /edx/app/edx-platform/edx-platform/cms/docker_cms_gunicorn.py --name cms --bind=0.0.0.0:8000 --max-requests=1000 --access-logfile - cms.wsgi:application
CMD newrelic-admin run-program gunicorn -c /edx/app/edxapp/edx-platform/cms/docker_cms_gunicorn.py --name cms --bind=0.0.0.0:8010 --max-requests=1000 --access-logfile - cms.wsgi:application

FROM studio as studio-devstack
# TODO: This compiles static assets.
# However, it's a bit of a hack, it's slow, and it's inefficient because makes the final Docker cache layer very large.
# We ought to be able to this higher up in the Dockerfile, and do it the same for Prod and Devstack.
RUN mkdir -p test_root/log
ENV DJANGO_SETTINGS_MODULE ""
RUN NO_PREREQ_INSTALL=1 paver update_assets cms --settings devstack_decentralized
ENV DJANGO_SETTINGS_MODULE cms.envs.devstack_decentralized
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ upgrade: ## update the pip requirements files to use the latest releases satisfy
docker_build:
docker build . -f Dockerfile --target lms -t openedx/edx-platform
docker build . -f Dockerfile --target lms-newrelic -t openedx/edx-platform:latest-newrelic
docker build . -f Dockerfile --target lms-devstack -t openedx/edx-platform:latest-devstack

docker_tag: docker_build
docker tag openedx/edx-platform openedx/edx-platform:${GITHUB_SHA}
docker tag openedx/edx-platform:latest-newrelic openedx/edx-platform:${GITHUB_SHA}-newrelic
docker tag openedx/edx-platform:latest-devstack openedx/edx-platform:${GITHUB_SHA}-devstack

docker_auth:
echo "$$DOCKERHUB_PASSWORD" | docker login -u "$$DOCKERHUB_USERNAME" --password-stdin
Expand All @@ -122,4 +124,6 @@ docker_push: docker_tag docker_auth ## push to docker hub
docker push "openedx/edx-platform:${GITHUB_SHA}"
docker push 'openedx/edx-platform:latest-newrelic'
docker push "openedx/edx-platform:${GITHUB_SHA}-newrelic"
docker push 'openedx/edx-platform:latest-devstack'
docker push "openedx/edx-platform:${GITHUB_SHA}-devstack"

Loading

0 comments on commit b24cb48

Please sign in to comment.