From 067b68076b1d97888ac7fe25cbad4aa149e8c6ce Mon Sep 17 00:00:00 2001 From: Muhammad Farhan Date: Sun, 27 Oct 2024 23:48:18 +0500 Subject: [PATCH 1/2] chore: Remove Dockerfile setup --- .dockerignore | 1 - .github/workflows/push-docker-images.yml | 52 ------------ Dockerfile | 100 ----------------------- 3 files changed, 153 deletions(-) delete mode 100644 .dockerignore delete mode 100644 .github/workflows/push-docker-images.yml delete mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 94143827..00000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -Dockerfile diff --git a/.github/workflows/push-docker-images.yml b/.github/workflows/push-docker-images.yml deleted file mode 100644 index efad3827..00000000 --- a/.github/workflows/push-docker-images.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Build and Push Docker Images - -on: - push: - branches: - - master - tags: - - open-release/* -jobs: - push: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - # Use the release name as the image tag if we're building an open release tag. - # Examples: if we're building 'open-release/maple.1', tag the image as 'maple.1'. - # Otherwise, we must be building from a push to master, so use 'latest'. - - name: Get tag name - id: get-tag-name - uses: actions/github-script@v5 - with: - script: | - const releasePrefix = 'refs/tags/open-release/'; - const tagName = context.ref.split(releasePrefix)[1] || 'latest'; - console.log('Will use tag: ' + tagName); - return tagName; - result-encoding: string - - - name: Build and push Dev Docker image - uses: docker/build-push-action@v1 - with: - push: true - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - target: dev - repository: edxops/analytics-api-dev - tags: ${{ steps.get-tag-name.outputs.result }},${{ github.sha }} - - # This part is commented out for now as edxops/insights is the older image built using Ansible. - # For smooth transition we want to keep that image intact too. Apart from this, the current priority is to get - # the devstack off of Ansible based Images. - # - name: Build and push prod Docker image - # uses: docker/build-push-action@v1 - # with: - # push: true - # username: ${{ secrets.DOCKERHUB_USERNAME }} - # password: ${{ secrets.DOCKERHUB_PASSWORD }} - # target: prod - # repository: edxops/insights - # tags: ${{ steps.get-tag-name.outputs.result }},${{ github.sha }} diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 8728e588..00000000 --- a/Dockerfile +++ /dev/null @@ -1,100 +0,0 @@ -FROM ubuntu:focal as base - -# System requirements. - -# ENV variables for Python 3.11 support -ARG PYTHON_VERSION=3.11 -ENV TZ=UTC -ENV TERM=xterm-256color -ENV DEBIAN_FRONTEND=noninteractive - -# software-properties-common is needed to setup Python 3.11 env -RUN apt-get update && \ - apt-get install -y software-properties-common && \ - apt-add-repository -y ppa:deadsnakes/ppa - -# pkg-config; mysqlclient>=2.2.0 requires pkg-config (https://github.com/PyMySQL/mysqlclient/issues/620) - -RUN apt-get update && \ - apt-get install -qy \ - build-essential \ - curl \ - vim \ - language-pack-en \ - build-essential \ - python${PYTHON_VERSION} \ - python${PYTHON_VERSION}-dev \ - python${PYTHON_VERSION}-distutils \ - libmysqlclient-dev \ - pkg-config \ - libssl-dev && \ - rm -rf /var/lib/apt/lists/* - -RUN update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 -RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 - -# need to use virtualenv pypi package with Python 3.11 -RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} -RUN pip install virtualenv - -# 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 - -ARG COMMON_APP_DIR="/edx/app" -ARG ANALYTICS_API_SERVICE_NAME="analytics_api" -ENV ANALYTICS_API_HOME "${COMMON_APP_DIR}/${ANALYTICS_API_SERVICE_NAME}" -ARG ANALYTICS_API_APP_DIR="${COMMON_APP_DIR}/${ANALYTICS_API_SERVICE_NAME}" -ARG ANALYTICS_API_VENV_DIR="${COMMON_APP_DIR}/${ANALYTICS_API_SERVICE_NAME}/venvs/${ANALYTICS_API_SERVICE_NAME}" -ARG ANALYTICS_API_CODE_DIR="${ANALYTICS_API_APP_DIR}/${ANALYTICS_API_SERVICE_NAME}" - -ENV ANALYTICS_API_CODE_DIR="${ANALYTICS_API_CODE_DIR}" -ENV PATH "${ANALYTICS_API_VENV_DIR}/bin:$PATH" -ENV COMMON_CFG_DIR "/edx/etc" -ENV ANALYTICS_API_CFG "/edx/etc/${ANALYTICS_API_SERVICE_NAME}.yml" - -# Working directory will be root of repo. -WORKDIR ${ANALYTICS_API_CODE_DIR} - -RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${ANALYTICS_API_VENV_DIR} - -# Expose canonical Analytics port -EXPOSE 19001 - -FROM base as prod - -ENV DJANGO_SETTINGS_MODULE "analyticsdataserver.settings.production" - -COPY requirements/production.txt ${ANALYTICS_API_CODE_DIR}/requirements/production.txt - -RUN pip install -r ${ANALYTICS_API_CODE_DIR}/requirements/production.txt - -# Copy over rest of code. -# We do this AFTER requirements so that the requirements cache isn't busted -# every time any bit of code is changed. - -COPY . . - -# exec /edx/app/analytics_api/venvs/analytics_api/bin/gunicorn -c /edx/app/analytics_api/analytics_api_gunicorn.py analyticsdataserver.wsgi:application - -CMD ["gunicorn" , "-b", "0.0.0.0:8100", "--pythonpath", "/edx/app/analytics_api/analytics_api","analyticsdataserver.wsgi:application"] - -FROM base as dev - -ENV DJANGO_SETTINGS_MODULE "analyticsdataserver.settings.devstack" - -COPY requirements/dev.txt ${ANALYTICS_API_CODE_DIR}/requirements/dev.txt - -RUN pip install -r ${ANALYTICS_API_CODE_DIR}/requirements/dev.txt - -# Copy over rest of code. -# We do this AFTER requirements so that the requirements cache isn't busted -# every time any bit of code is changed. -COPY . . - -# Devstack related step for backwards compatibility -RUN touch /edx/app/${ANALYTICS_API_SERVICE_NAME}/${ANALYTICS_API_SERVICE_NAME}_env - -CMD while true; do python ./manage.py runserver 0.0.0.0:8110; sleep 2; done From 2aa424d5bd7389065235d0a9bbb35c535741524b Mon Sep 17 00:00:00 2001 From: Muhammad Farhan Date: Mon, 28 Oct 2024 17:40:04 +0500 Subject: [PATCH 2/2] fix: use pre-built image instead of building from Dockerfile --- .github/docker-compose-ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/docker-compose-ci.yml b/.github/docker-compose-ci.yml index f630d06c..21d29508 100644 --- a/.github/docker-compose-ci.yml +++ b/.github/docker-compose-ci.yml @@ -3,11 +3,7 @@ version: "2" services: analytics_api: - # Use this image once the Python version upgrade is complete - # image: edxops/analytics-api-dev:latest - build: - context: ../ - dockerfile: Dockerfile + image: edxops/analytics-api-dev:latest container_name: analytics_api_testing volumes: - ..:/edx/app/analytics_api/analytics_api