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

feat: introduce ansible-free docker image for edx-notes-api #1053

Merged
merged 7 commits into from
May 10, 2023
2 changes: 1 addition & 1 deletion docker-compose-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
- ${DEVSTACK_WORKSPACE}/src:/edx/src
edx_notes_api:
volumes:
- ${DEVSTACK_WORKSPACE}/edx-notes-api:/edx/app/edx_notes_api/edx_notes_api
- ${DEVSTACK_WORKSPACE}/edx-notes-api:/edx/app/notes/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Note for reviewer] I have changed paths here because notes was already deployed on prod with the native Dockerfile, so instead of adjusting paths for prod as per devstack, I have adjusted paths for devstack as of production.

- ${DEVSTACK_WORKSPACE}/src:/edx/src
registrar:
volumes:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,15 @@ services:

edx_notes_api:
# Sleep as a part of start up to give elasticsearch enough time to start up.
command: bash -c 'source /edx/app/edx_notes_api/edx_notes_api_env && while true; do python /edx/app/edx_notes_api/edx_notes_api/manage.py runserver 0.0.0.0:18120 --settings notesserver.settings.devstack; sleep 4; done'
command: bash -c 'source /edx/app/edx_notes_api_env && while true; do python /edx/app/notes/manage.py runserver 0.0.0.0:18120 --settings notesserver.settings.devstack; sleep 4; done'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.edxnotesapi"
hostname: edx_notes_api.devstack.edx
depends_on:
- devpi
- elasticsearch710
- lms
- mysql57
image: edxops/notes:${OPENEDX_RELEASE:-latest}
image: edxops/notes-dev:${OPENEDX_RELEASE:-latest}
networks:
default:
aliases:
Expand Down
28 changes: 25 additions & 3 deletions provision-notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,30 @@ set -eu -o pipefail
set -x

# Common provisioning tasks for IDAs, including requirements, migrations, oauth client creation, etc.
./provision-ida.sh edx_notes_api edx-notes 18120 edx_notes_api
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Note for reviewer] Copied the content of the common provisioning script and adjusted paths.

# ./provision-ida.sh edx_notes_api edx-notes 18120 edx_notes_api

name=edx_notes_api
port=18734
client_name=edx-notes # The name of the Oauth client stored in the edxapp DB.

docker-compose up -d $name

echo -e "${GREEN}Installing requirements for ${name}...${NC}"
docker-compose exec -T ${name} bash -e -c 'cd /edx/app/notes && make requirements' -- "$name"

echo -e "${GREEN}Running migrations for ${name}...${NC}"
docker-compose exec -T ${name} bash -e -c 'cd /edx/app/notes && make migrate' -- "$name"

echo -e "${GREEN}Creating super-user for ${name}...${NC}"
docker-compose exec -T ${name} bash -e -c 'cho "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser(\"edx\", \"edx@example.com\", \"edx\") if not User.objects.filter(username=\"edx\").exists() else None" | python /edx/app/notes/manage.py shell' -- "$name"

./provision-ida-user.sh $name $client_name $port

# Compile static assets last since they are absolutely necessary for all services. This will allow developers to get
# started if they do not care about static assets
echo -e "${GREEN}Compiling static assets for ${name}...${NC}"
docker-compose exec -T ${name} bash -e -c 'cd /edx/app/notes && make static' -- "$name"

# This will build the elasticsearch index for notes.
echo -e "${GREEN}Creating indexes for edx_notes_api...${NC}"
docker-compose exec -T edx_notes_api bash -e -c 'source /edx/app/$1/$1_env && cd /edx/app/$1/$1/ && python manage.py search_index --rebuild -f' -- edx_notes_api
echo -e "${GREEN}Creating indexes for ${name}...${NC}"
docker-compose exec -T ${name} bash -e -c 'cd /edx/app/notes/ && python manage.py search_index --rebuild -f'