Skip to content

Commit

Permalink
feat: introduce ansible-free docker image for edx-notes-api (openedx-…
Browse files Browse the repository at this point in the history
…unsupported#1053)

* feat: introduce annsible-free docker image for edx-notes-apo

* fix: update image name as per the pushing script

* fix: remove extra commented lines

* fix: remove env activation command
  • Loading branch information
iamsobanjaved authored and XLAR-8 committed Jul 26, 2023
1 parent 609d3c0 commit 007a443
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
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/
- ${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 @@ -386,15 +386,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 '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: openedx/edx-notes-api-dev:${OPENEDX_RELEASE:-latest}
networks:
default:
aliases:
Expand Down
27 changes: 23 additions & 4 deletions provision-notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,28 @@ set -eu -o pipefail
. scripts/colors.sh
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
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'

0 comments on commit 007a443

Please sign in to comment.