Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

WIP: Implement decentralized devstack #341

Closed
Closed
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
126 changes: 126 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# .dockerignore for registrar.
# There's a lot here, please try to keep it organized.

### Files that are not needed in the docker file

/test_root/
.git*
.github*

### 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

### NFS artifacts
**/.nfs*

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

### Internationalization artifacts
**/*.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

### 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*
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/
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/

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

### Styling generated from templates
themes/**/css

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

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

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

# Visual Studio Code
**/.vscode

# Locally generated PII reports
**/pii_report
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
COMPOSE_PATH_SEPARATOR=:
COMPOSE_FILE=docker-compose.yml
# TODO: Make sure this doesn't break existing local development
COMPOSE_PROJECT_NAME=decentralized-registrar-devstack
22 changes: 22 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Push Docker Images

on:
push:
branches:
- master
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build and Push docker image
env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run : make docker_push
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FROM ubuntu:xenial as app

# System requirements.
RUN apt-get update && apt-get upgrade -qy
RUN apt-get install -qy \
git-core \
language-pack-en \
python3.5 \
python3-pip \
python3.5-dev \
libmysqlclient-dev \
libssl-dev
RUN pip3 install --upgrade pip setuptools
RUN rm -rf /var/lib/apt/lists/*

# Python is Python3.
RUN ln -s /usr/bin/pip3 /usr/bin/pip
RUN ln -s /usr/bin/python3 /usr/bin/python

# Use UTF-8.
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV DJANGO_SETTINGS_MODULE registrar.settings.production

RUN mkdir -p /edx/app/registrar

# Expose ports.
EXPOSE 18734
EXPOSE 18735

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

# Working directory will be root of repo.
WORKDIR /edx/app/registrar

# Copy just Python requirements & install them.
COPY requirements/ /edx/app/registrar/requirements/
COPY Makefile /edx/app/registrar/
RUN make production-requirements

# Code is owned by root so it cannot be modified by the application user.
# So we copy it before changing users.
USER app

# Gunicorn 19 does not log to stdout or stderr by default. Once we are past gunicorn 19, the logging to STDOUT need not be specified.
CMD ["gunicorn", "--workers=2", "--name", "registrar", "-c", "/edx/app/registrar/registrar/docker_gunicorn_configuration.py", "--log-file", "-", "--max-requests=1000", "registrar.wsgi:application"]

# After the requirements so changes to the code will not bust the image cache
COPY . /edx/app/registrar

FROM app as newrelic
RUN pip3 install newrelic
CMD ["newrelic-admin", "run-program", "gunicorn", "--workers=2", "--name", "registrar", "-c", "/edx/app/registrar/registrar/docker_gunicorn_configuration.py", "--log-file", "-", "--max-requests=1000", "registrar.wsgi:application"]
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ TOX=''
fake_translations pull_translations push_translations \
detect_changed_source_translations validate_translations api_generated \
validate_api_committed
#TODO: Add docker.build docker.push docker.build.push

define BROWSER_PYSCRIPT
import os, webbrowser, sys
Expand Down Expand Up @@ -153,3 +154,66 @@ api_generated: ## generates an expanded verison of api.yaml for consuming tools

validate_api_committed: ## check to make sure any api.yaml changes have been committed to the expanded document
$(TOX)bash -c "diff .api-generated.yaml <(python scripts/yaml_merge.py api.yaml -)"


# Docker commands below

dev.build:
docker build . --tag openedx/registrar

dev.push: dev.build
docker push openedx/registrar

dev.build.push: dev.build dev.push # TODO

dev.provision:
bash ./provision-catalog.sh

dev.init: dev.up dev.migrate

dev.makemigrations:
docker exec -it registrar.app bash -c 'cd /edx/app/registrar && python3 manage.py makemigrations'

dev.migrate: # Migrates databases. Application and DB server must be up for this to work.
docker exec -it registrar.app bash -c 'cd /edx/app/registrar && make migrate'

dev.up: # Starts all containers
docker-compose up -d

dev.up.build:
docker-compose up -d --build

dev.down: # Kills containers and all of their data that isn't in volumes
docker-compose downing

dev.destroy: dev.down #Kills containers and destroys volumes. If you get an error after running this, also run: docker volume rm portal-designer_designer_mysql
docker volume rm registrar_mysql

dev.stop: # Stops containers so they can be restarted
docker-compose stop

%-shell: ## Run a shell, as root, on the specified service container
docker-compose exec -u 0 $* env TERM=$(TERM) bash

%-logs: ## View the logs of the specified service container
docker-compose logs -f --tail=500 $*

attach:
docker attach registrar.app

docker_build:
docker build . --target app -t "openedx/registrar:latest"
docker build . --target newrelic -t "openedx/registrar:latest-newrelic"

travis_docker_auth:
echo "$$DOCKER_PASSWORD" | docker login -u "$$DOCKER_USERNAME" --password-stdin

travis_docker_tag: docker_build
docker build . --target app -t "openedx/registrar:$$TRAVIS_COMMIT"
docker build . --target newrelic -t "openedx/registrar:$$TRAVIS_COMMIT-newrelic"

travis_docker_push: travis_docker_tag travis_docker_auth ## push to docker hub
docker push "openedx/registrar:latest"
docker push "openedx/registrar:$$TRAVIS_COMMIT"
docker push "openedx/registrar:latest-newrelic"
docker push "openedx/registrar:$$TRAVIS_COMMIT-newrelic"
Loading