From b4bf8aeaa40e00dbbcc8cb29a928a8cb56388629 Mon Sep 17 00:00:00 2001 From: Bilal Qamar <59555732+BilalQamar95@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:53:57 +0500 Subject: [PATCH 1/4] chore: removed Dockerfile --- Dockerfile | 130 ----------------------------------------------------- 1 file changed, 130 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index fcaba8aa..00000000 --- a/Dockerfile +++ /dev/null @@ -1,130 +0,0 @@ -FROM ubuntu:focal as app -MAINTAINER devops@edx.org - - -# Packages installed: -# git; Used to pull in particular requirements from github rather than pypi, -# and to check the sha of the code checkout. - -# language-pack-en locales; ubuntu locale support so that system utilities have a consistent -# language and time zone. - -# python; ubuntu doesnt ship with python, so this is the python we will use to run the application - -# python3-pip; install pip to install application requirements.txt files - -# libssl-dev; # mysqlclient wont install without this. - -# pkg-config -# mysqlclient>=2.2.0 requires this (https://github.com/PyMySQL/mysqlclient/issues/620) - -# libmysqlclient-dev; to install header files needed to use native C implementation for -# MySQL-python for performance gains. - -# wget to download a watchman binary archive - -# unzip to unzip a watchman binary archive - -# If you add a package here please include a comment above describing what it is used for - -# ENV variables for Python 3.12 support -ARG PYTHON_VERSION=3.12 -ENV TZ=UTC -ENV TERM=xterm-256color -ENV DEBIAN_FRONTEND=noninteractive - -# software-properties-common is needed to setup Python 3.12 env -RUN apt-get update && \ - apt-get install -y software-properties-common && \ - apt-add-repository -y ppa:deadsnakes/ppa - -RUN apt-get update && apt-get -qy install --no-install-recommends \ - language-pack-en \ - locales \ - pkg-config \ - libmysqlclient-dev \ - libssl-dev \ - build-essential \ - git \ - wget \ - unzip \ - curl \ - libffi-dev \ - libsqlite3-dev \ - python3-pip \ - python${PYTHON_VERSION} \ - python${PYTHON_VERSION}-dev \ - python${PYTHON_VERSION}-distutils - -# need to use virtualenv pypi package with Python 3.12 -RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} -RUN pip install virtualenv - -ENV VIRTUAL_ENV=/edx/app/license-manager/venvs/license-manager -RUN virtualenv -p python${PYTHON_VERSION} $VIRTUAL_ENV -ENV PATH="$VIRTUAL_ENV/bin:$PATH" - -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 license_manager.settings.production - -EXPOSE 18170 -EXPOSE 18171 -RUN useradd -m --shell /bin/false app - -# Install watchman -RUN wget https://github.com/facebook/watchman/releases/download/v2023.11.20.00/watchman-v2023.11.20.00-linux.zip -RUN unzip watchman-v2023.11.20.00-linux.zip -RUN mkdir -p /usr/local/{bin,lib} /usr/local/var/run/watchman -RUN cp watchman-v2023.11.20.00-linux/bin/* /usr/local/bin -RUN cp watchman-v2023.11.20.00-linux/lib/* /usr/local/lib -RUN chmod 755 /usr/local/bin/watchman -RUN chmod 2777 /usr/local/var/run/watchman - -# Now install license-manager -WORKDIR /edx/app/license_manager - -# Copy the requirements explicitly even though we copy everything below -# this prevents the image cache from busting unless the dependencies have changed. -COPY requirements/production.txt /edx/app/license_manager/requirements/production.txt -COPY requirements/pip.txt /edx/app/license_manager/requirements/pip.txt - -# Dependencies are installed as root so they cannot be modified by the application user. -RUN pip install -r requirements/pip.txt -RUN pip install -r requirements/production.txt - -RUN mkdir -p /edx/var/log - -# 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 license_manager -c /edx/app/license_manager/license_manager/docker_gunicorn_configuration.py --log-file - --max-requests=1000 license_manager.wsgi:application - -# This line is after the requirements so that changes to the code will not -# bust the image cache -COPY . /edx/app/license_manager - -FROM app as newrelic -RUN pip install newrelic -CMD newrelic-admin run-program gunicorn --workers=2 --name license_manager -c /edx/app/license_manager/license_manager/docker_gunicorn_configuration.py --log-file - --max-requests=1000 license_manager.wsgi:application - - -FROM app as devstack -USER root -RUN pip install -r /edx/app/license_manager/requirements/dev.txt -USER app -CMD gunicorn --reload --workers=2 --name license_manager -c /edx/app/license_manager/license_manager/docker_gunicorn_configuration.py --log-file - --max-requests=1000 license_manager.wsgi:application - - -FROM app as legacy_devapp -# Dev ports -EXPOSE 18170 -EXPOSE 18171 -USER root -RUN pip install -r /edx/app/license_manager/requirements/dev.txt -USER app -CMD gunicorn --reload --workers=2 --name license_manager -c /edx/app/license_manager/license_manager/docker_gunicorn_configuration.py --log-file - --max-requests=1000 license_manager.wsgi:application From dcbb234eafe667698388f3184b95050098c31932 Mon Sep 17 00:00:00 2001 From: Bilal Qamar <59555732+BilalQamar95@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:54:16 +0500 Subject: [PATCH 2/4] refactor: updated Docker configuration files --- .github/docker-compose-github.yml | 5 +--- Makefile | 41 ------------------------------- docker-compose.yml | 15 +++-------- provision-license-manager.sh | 2 +- 4 files changed, 5 insertions(+), 58 deletions(-) diff --git a/.github/docker-compose-github.yml b/.github/docker-compose-github.yml index bbe0f26b..c882cb1a 100644 --- a/.github/docker-compose-github.yml +++ b/.github/docker-compose-github.yml @@ -11,10 +11,7 @@ services: - license_manager_mysql:/var/lib/mysql app: - image: openedx/license-manager - build: - context: .. - dockerfile: Dockerfile + image: edxops/license-manager container_name: license-manager.app volumes: - ..:/edx/app/license_manager diff --git a/Makefile b/Makefile index 62fd3ebd..b57209ee 100644 --- a/Makefile +++ b/Makefile @@ -148,12 +148,6 @@ pull_translations: ## pull translations from Transifex push_translations: ## push source translation files (.po) from Transifex tx push -s -open-devstack: ## open a shell on the server started by start-devstack - docker exec -it license-manager /edx/app/license_manager/devstack.sh open - -pkg-devstack: ## build the license-manager image from the latest configuration and code - docker build -t license-manager:latest -f docker/build/license_manager/Dockerfile git://github.com/openedx/configuration - detect_changed_source_translations: ## check if translation files are up-to-date cd license_manager && i18n_tool changed @@ -167,16 +161,6 @@ dev.provision: dev.up: dev.up.redis # Starts all of the services, will bring up the devstack-defined redis container if not running. docker-compose up -d -dev.up.build: - docker-compose up -d --build - -dev.up.build-no-cache: - docker-compose build --no-cache - docker-compose up -d - -dev.up.redis: - docker-compose -f $(DEVSTACK_WORKSPACE)/devstack/docker-compose.yml up -d redis - dev.down: # Kills containers and all of their data that isn't in volumes docker-compose down @@ -221,28 +205,3 @@ dev.restore: dev.static: docker-compose exec -u 0 app python3 manage.py collectstatic --noinput - -docker_build: - docker build . -f Dockerfile --target app -t openedx/license-manager - docker build . -f Dockerfile --target devstack -t openedx/license-manager:latest-devstack - - docker build . -f Dockerfile --target app -t openedx/license-manager.worker - docker build . -f Dockerfile --target devstack -t openedx/license-manager.worker:latest-devstack - - docker build . -f Dockerfile --target newrelic -t openedx/license-manager:latest-newrelic - -docker_tag: docker_build - docker tag openedx/license-manager openedx/license-manager:$$GITHUB_SHA - docker tag openedx/license-manager:latest-devstack openedx/license-manager:$$GITHUB_SHA-devstack - docker tag openedx/license-manager:latest-newrelic openedx/license-manager:$$GITHUB_SHA-newrelic - -docker_auth: - echo "$$DOCKERHUB_PASSWORD" | docker login -u "$$DOCKERHUB_USERNAME" --password-stdin - -docker_push: docker_tag docker_auth ## push to docker hub - docker push 'openedx/license-manager:latest' - docker push "openedx/license-manager:$$GITHUB_SHA" - docker push 'openedx/license-manager:latest-devstack' - docker push "openedx/license-manager:$$GITHUB_SHA-devstack" - docker push 'openedx/license-manager:latest-newrelic' - docker push "openedx/license-manager:$$GITHUB_SHA-newrelic" diff --git a/docker-compose.yml b/docker-compose.yml index 892e5b00..ded5b343 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,10 +12,7 @@ services: - license_manager_mysql8:/var/lib/mysql app: - image: openedx/license-manager - build: - context: . - dockerfile: Dockerfile + image: edxops/license-manager container_name: license-manager.app volumes: - .:/edx/app/license_manager/ @@ -47,10 +44,7 @@ services: container_name: license-manager.memcache worker: - image: openedx/license-manager.worker - build: - context: . - dockerfile: Dockerfile + image: edxops/license-manager.worker command: bash -c 'cd /edx/app/license_manager/license_manager && celery -A license_manager worker -Q license_manager.default -l DEBUG' container_name: license-manager.worker depends_on: @@ -76,10 +70,7 @@ services: - ../src:/edx/src:cached bulk_enrollment_worker: - image: openedx/license-manager.worker - build: - context: . - dockerfile: Dockerfile + image: edxops/license-manager.worker command: bash -c 'cd /edx/app/license_manager/license_manager && celery -A license_manager worker -Q license_manager.bulk_enrollment -l DEBUG' container_name: license-manager.bulk_enrollment_worker depends_on: diff --git a/provision-license-manager.sh b/provision-license-manager.sh index 3f7bfdc7..b94268c2 100755 --- a/provision-license-manager.sh +++ b/provision-license-manager.sh @@ -1,7 +1,7 @@ name="license_manager" port="18170" -docker-compose up -d --build +docker-compose up -d # Install requirements # Can be skipped right now because we're using the --build flag on docker-compose. This will need to be changed once we move to devstack. From f4d87d61265b307aebd073a5a93df0e058d95d3b Mon Sep 17 00:00:00 2001 From: Bilal Qamar <59555732+BilalQamar95@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:16:13 +0500 Subject: [PATCH 3/4] chore: update Docker image in docker-compose files --- .github/docker-compose-github.yml | 2 +- docker-compose.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/docker-compose-github.yml b/.github/docker-compose-github.yml index c882cb1a..04893b74 100644 --- a/.github/docker-compose-github.yml +++ b/.github/docker-compose-github.yml @@ -11,7 +11,7 @@ services: - license_manager_mysql:/var/lib/mysql app: - image: edxops/license-manager + image: edxops/license-manager-dev container_name: license-manager.app volumes: - ..:/edx/app/license_manager diff --git a/docker-compose.yml b/docker-compose.yml index ded5b343..2017da18 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: - license_manager_mysql8:/var/lib/mysql app: - image: edxops/license-manager + image: edxops/license-manager-dev container_name: license-manager.app volumes: - .:/edx/app/license_manager/ @@ -44,7 +44,7 @@ services: container_name: license-manager.memcache worker: - image: edxops/license-manager.worker + image: edxops/license-manager-dev.worker command: bash -c 'cd /edx/app/license_manager/license_manager && celery -A license_manager worker -Q license_manager.default -l DEBUG' container_name: license-manager.worker depends_on: @@ -70,7 +70,7 @@ services: - ../src:/edx/src:cached bulk_enrollment_worker: - image: edxops/license-manager.worker + image: edxops/license-manager-dev.worker command: bash -c 'cd /edx/app/license_manager/license_manager && celery -A license_manager worker -Q license_manager.bulk_enrollment -l DEBUG' container_name: license-manager.bulk_enrollment_worker depends_on: From df04182a75585139e8f650f9de0b79be84418528 Mon Sep 17 00:00:00 2001 From: Bilal Qamar <59555732+BilalQamar95@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:32:55 +0500 Subject: [PATCH 4/4] chore: removed worker tags --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2017da18..c198aa97 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: container_name: license-manager.memcache worker: - image: edxops/license-manager-dev.worker + image: edxops/license-manager-dev command: bash -c 'cd /edx/app/license_manager/license_manager && celery -A license_manager worker -Q license_manager.default -l DEBUG' container_name: license-manager.worker depends_on: @@ -70,7 +70,7 @@ services: - ../src:/edx/src:cached bulk_enrollment_worker: - image: edxops/license-manager-dev.worker + image: edxops/license-manager-dev command: bash -c 'cd /edx/app/license_manager/license_manager && celery -A license_manager worker -Q license_manager.bulk_enrollment -l DEBUG' container_name: license-manager.bulk_enrollment_worker depends_on: