Skip to content

Commit

Permalink
feat: add enterprise-access to devstack
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsobanjaved committed Nov 20, 2024
1 parent 3c79ad3 commit 3769273
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 2 deletions.
6 changes: 6 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ if should_check ecommerce; then
"curl --fail -L http://localhost:18130/health/"
fi

if should_check enterprise_access; then
echo "Checking enterprise-access health:"
run_check enterprise_access_heartbeat enterprise-access \
"curl --fail -L http://localhost:18130/health/"
fi

if should_check discovery; then
echo "Checking discovery health:"
run_check discovery_heartbeat discovery \
Expand Down
7 changes: 7 additions & 0 deletions docker-compose-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ services:
- ecommerce_node_modules:/edx/app/ecommerce/ecommerce/node_modules
- ecommerce_tox:/edx/app/ecommerce/ecommerce/.tox
- ${DEVSTACK_WORKSPACE}/src:/edx/src
enterprise-access:
volumes:
- ${DEVSTACK_WORKSPACE}/enterprise-access:/edx/app/enterprise-access/
- ${DEVSTACK_WORKSPACE}/src:/edx/src
enterprise-access-worker:
volumes:
- ${DEVSTACK_WORKSPACE}/enterprise-access:/edx/app/enterprise-access/
forum:
volumes:
- ${DEVSTACK_WORKSPACE}/cs_comments_service:/edx/app/forum/cs_comments_service
Expand Down
63 changes: 63 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,69 @@ services:
ELASTICSEARCH_URL: "http://edx.devstack.elasticsearch710:9200"
ELASTICSEARCH_DSL: "http://edx.devstack.elasticsearch710:9200"

enterprise-access:
image: edxops/enterprise-access-dev
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.enterprise-access"
hostname: enterprise-access.devstack.edx
command: bash -c 'while true; do python /edx/app/enterprise-access/manage.py runserver 0.0.0.0:18270; sleep 2; done'
ports:
- "18270:18270"
depends_on:
- mysql80
- memcached
- enterprise-access-worker
networks:
default:
aliases:
- edx.devstack.enterprise-access
stdin_open: true
tty: true
environment:
CELERY_ALWAYS_EAGER: 'false'
CELERY_BROKER_TRANSPORT: redis
CELERY_BROKER_HOSTNAME: edx.devstack.redis:6379
CELERY_BROKER_VHOST: 0
CELERY_BROKER_PASSWORD: password
DJANGO_SETTINGS_MODULE: enterprise_access.settings.devstack
DJANGO_WATCHMAN_TIMEOUT: 30
ENABLE_DJANGO_TOOLBAR: 1
DB_HOST: edx.devstack.mysql80
DB_NAME: enterprise_access
DB_PORT: 3306
DB_USER: enterprise_access001
DB_PASSWORD: password

enterprise-access-worker:
image: edxops/enterprise-access-dev
command: bash -c 'cd /edx/app/enterprise-access/ && celery -A enterprise_access worker -l DEBUG'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.enterprise-access-worker"
hostname: enterprise-access-worker.devstack.edx
depends_on:
- mysql80
- memcached
environment:
CELERY_ALWAYS_EAGER: 'false'
CELERY_BROKER_TRANSPORT: redis
CELERY_BROKER_HOSTNAME: edx.devstack.redis:6379
CELERY_BROKER_VHOST: 0
CELERY_BROKER_PASSWORD: password
DJANGO_SETTINGS_MODULE: enterprise_access.settings.devstack
COLUMNS: 80
DB_HOST: edx.devstack.mysql80
DB_NAME: enterprise_access
DB_PORT: 3306
DB_USER: enterprise_access001
DB_PASSWORD: password
networks:
default:
aliases:
- edx.devstack.enterprise-access-worker
ports:
- "18271:18271"
restart: always
stdin_open: true
tty: true

forum:
command: bash -c 'source /edx/app/forum/ruby_env && source /edx/app/forum/devstack_forum_env && cd /edx/app/forum/cs_comments_service && bundle install && while true; do ./bin/unicorn -c config/unicorn_tcp.rb -I .; sleep 2; done'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.forum"
Expand Down
3 changes: 3 additions & 0 deletions docs/service_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Instead of a service name or list, you can also run commands like ``make dev.pro
+------------------------------------+-------------------------------------+----------------+--------------+
| `frontend-app-ora-grading`_ | http://localhost:1993 | MFE (React.js) | Extra |
+------------------------------------+-------------------------------------+----------------+--------------+
| `enterprise-access`_ | http://localhost:18270 | Python/Django | Extra |
+------------------------------------+-------------------------------------+----------------+--------------+

Some common service combinations include:

Expand Down Expand Up @@ -95,3 +97,4 @@ Some common service combinations include:
.. _frontend-app-ora-grading: https://github.com/edx/frontend-app-ora-grading
.. _insights: https://github.com/edx/edx-analytics-dashboard
.. _analyticsapi: https://github.com/edx/edx-analytics-data-api
.. _enterprise-access: https://github.com/openedx/enterprise-access
4 changes: 2 additions & 2 deletions options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ credentials+discovery+ecommerce+edx_notes_api+forum+frontend-app-authn+frontend-
# Separated by plus signs.
# Separated by plus signs. Listed in alphabetical order for clarity.
EDX_SERVICES ?= \
analyticsapi+credentials+cms+cms-worker+cms_watcher+discovery+ecommerce+edx_notes_api+forum+frontend-app-account+frontend-app-learner-dashboard+frontend-app-learner-record+frontend-app-profile+frontend-app-authn+frontend-app-course-authoring+frontend-app-gradebook+frontend-app-ora-grading+frontend-app-learning+frontend-app-library-authoring+frontend-app-payment+frontend-app-program-console+frontend-app-publisher+insights+lms+lms-worker+lms_watcher+registrar+registrar-worker+xqueue+xqueue_consumer
analyticsapi+credentials+cms+cms-worker+cms_watcher+discovery+ecommerce+edx_notes_api+enterprise-access+forum+frontend-app-account+frontend-app-learner-dashboard+frontend-app-learner-record+frontend-app-profile+frontend-app-authn+frontend-app-course-authoring+frontend-app-gradebook+frontend-app-ora-grading+frontend-app-learning+frontend-app-library-authoring+frontend-app-payment+frontend-app-program-console+frontend-app-publisher+insights+lms+lms-worker+lms_watcher+registrar+registrar-worker+xqueue+xqueue_consumer

# Services with database migrations.
# Should be a subset of $(EDX_SERVICES).
Expand All @@ -76,7 +76,7 @@ analyticsapi+credentials+cms+cms-worker+cms_watcher+discovery+ecommerce+edx_note
# Note: This list should contain _all_ db-backed services, even if not
# configured to run; the list will be filtered later against $(DEFAULT_SERVICES).
DB_SERVICES ?= \
credentials+cms+discovery+ecommerce+lms+registrar
credentials+cms+discovery+ecommerce+enterprise-access+lms+registrar

# Services with static assets to be built.
# Should be a subset of $(EDX_SERVICES).
Expand Down
28 changes: 28 additions & 0 deletions provision-enterprise-access.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set -euf -o pipefail

. scripts/colors.sh

name="enterprise-access"
port="18270"

docker-compose up -d $name

# Run migrations
echo -e "${GREEN}Running migrations for ${name}...${NC}"
docker compose exec -T ${name} bash -e -c "cd /edx/app/enterprise-access/ && make migrate" -- "$name"
# docker compose exec -T ${name} bash -e -c 'source /edx/app/credentials/credentials_env && cd /edx/app/credentials/credentials && make migrate' -- "$name"

# Create superuser
echo -e "${GREEN}Creating super-user for ${name}...${NC}"
docker compose exec -T ${name} bash -e -c "echo 'from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser(\"edx\", \"[email protected]\", \"edx\") if not User.objects.filter(username=\"edx\").exists() else None' | python /edx/app/enterprise-access/manage.py shell" -- "$name"

./provision-ida-user.sh ${name} ${name} ${port}

# Create system wide enterprise role assignment
# TODO: this is a pretty complex oneline, we should probably eventually convert this to a management command.
echo -e "${GREEN}Creating system wide enterprise user role assignment for ${name}...${NC}"
docker compose exec -T lms bash -e -c "source /edx/app/edxapp/edxapp_env && echo 'from django.contrib.auth import get_user_model; from enterprise.models import SystemWideEnterpriseUserRoleAssignment, SystemWideEnterpriseRole; User = get_user_model(); worker_user = User.objects.get(username=\"${name}_worker\"); operator_role = SystemWideEnterpriseRole.objects.get(name=\"enterprise_openedx_operator\"); assignment = SystemWideEnterpriseUserRoleAssignment.objects.get_or_create(user=worker_user, role=operator_role, applies_to_all_contexts=True);' | /edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py lms shell" -- lms

# Restart enterprise.catalog app and worker containers
# docker-compose restart app
make dev.restart-devserver.enterprise-access
4 changes: 4 additions & 0 deletions provision-mysql80.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ CREATE DATABASE IF NOT EXISTS ecommerce;
CREATE USER IF NOT EXISTS 'ecomm001'@'%' IDENTIFIED BY 'password';
GRANT ALL ON ecommerce.* TO 'ecomm001'@'%';

CREATE DATABASE IF NOT EXISTS enterprise_access;
CREATE USER IF NOT EXISTS 'enterprise_access001'@'%' IDENTIFIED BY 'password';
GRANT ALL ON enterprise_access.* TO 'enterprise_access001'@'%';

CREATE DATABASE IF NOT EXISTS notes;
CREATE USER IF NOT EXISTS 'notes001'@'%' IDENTIFIED BY 'password';
GRANT ALL ON notes.* TO 'notes001'@'%';
Expand Down
1 change: 1 addition & 0 deletions provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ xqueue \
coursegraph \
insights \
analyticsapi \
enterprise-access \
"

# What should we provision?
Expand Down
3 changes: 3 additions & 0 deletions provision.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ GRANT ALL ON discovery.* TO 'discov001'@'%' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS ecommerce;
GRANT ALL ON ecommerce.* TO 'ecomm001'@'%' IDENTIFIED BY 'password';

CREATE DATABASE IF NOT EXISTS enterprise_access;
GRANT ALL ON enterprise_access.* TO 'enterprise_access001'@'%' IDENTIFIED BY 'password';

CREATE DATABASE IF NOT EXISTS notes;
GRANT ALL ON notes.* TO 'notes001'@'%' IDENTIFIED BY 'password';

Expand Down
2 changes: 2 additions & 0 deletions repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ repos=(
"https://github.com/openedx/frontend-app-publisher.git"
"https://github.com/edx/edx-analytics-dashboard.git"
"https://github.com/edx/edx-analytics-data-api.git"
"https://github.com/openedx/enterprise-access.git"
)

non_release_repos=(
Expand Down Expand Up @@ -66,6 +67,7 @@ ssh_repos=(
"[email protected]:openedx/frontend-app-publisher.git"
"[email protected]:edx/edx-analytics-dashboard.git"
"[email protected]:edx/edx-analytics-data-api.git"
"[email protected]:openedx/enterprise-access.git"
)

non_release_ssh_repos=(
Expand Down

0 comments on commit 3769273

Please sign in to comment.