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

fix: backport changes to olive #603

Open
wants to merge 20 commits into
base: open-release/olive.master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4b975be
chore: Updating Python Requirements
edx-requirements-bot Oct 10, 2022
c6b55e0
Merge pull request #587 from openedx/jenkins/upgrade-python-requireme…
MichaelRoytman Oct 14, 2022
a4c0ff3
chore: Updating Python Requirements
edx-requirements-bot Oct 24, 2022
11d7849
Merge pull request #589 from openedx/jenkins/upgrade-python-requireme…
ashultz0 Oct 24, 2022
48ed5b5
chore: upgrade edx-enterprise-data to 4.6.4
muhammad-ammar Oct 26, 2022
cf0bb9d
Merge pull request #590 from openedx/ammar/upgrade-edx-enterprise-dat…
muhammad-ammar Nov 14, 2022
49790b7
chore: Updating Python Requirements
edx-requirements-bot Nov 10, 2022
376d671
Merge pull request #591 from openedx/jenkins/upgrade-python-requireme…
MichaelRoytman Nov 14, 2022
41b3caf
chore: Updating Python Requirements
edx-requirements-bot Nov 24, 2022
d25ac1b
feat: Native Dockerfile (#580)
aht007 Dec 1, 2022
e6804d3
Merge pull request #594 from openedx/jenkins/upgrade-python-requireme…
varshamenon4 Dec 8, 2022
29c8664
chore: Updating Python Requirements
edx-requirements-bot Dec 10, 2022
a963334
fix: add tox constraint to avoid known plugin issue for tox>=4.0.0
alangsto Dec 12, 2022
82b0427
Merge pull request #596 from openedx/jenkins/upgrade-python-requireme…
alangsto Dec 12, 2022
38546f9
chore: Updating Python Requirements
edx-requirements-bot Jan 10, 2023
0a5021b
Merge pull request #598 from openedx/jenkins/upgrade-python-requireme…
MichaelRoytman Jan 12, 2023
0a0dd10
chore: Updating Python Requirements
edx-requirements-bot Jan 24, 2023
dbf5a2c
Merge pull request #599 from openedx/jenkins/upgrade-python-requireme…
MichaelRoytman Jan 27, 2023
5d18e70
fix: backport changes to olive
zubairshakoorarbisoft Feb 10, 2023
ff26165
Merge branch 'open-release/olive.master' into zshkoor/backport-workfl…
zubairshakoorarbisoft Feb 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dockerfile
2 changes: 1 addition & 1 deletion .github/docker-compose-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "2"
services:

analytics_api:
image: edxops/analytics_api:latest
image: edxops/analytics-api-dev:latest
container_name: analytics_api_testing
volumes:
- ..:/edx/app/analytics_api/analytics_api
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
targets: [ 'quality','main.test','docs' ]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: setup python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/docker-publish.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/push-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Push Docker Images

on:
push:
branches:
- master
- 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 branch.
# Examples: if we're building 'open-release/maple.master', tag the image as 'maple.master'.
# 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 branchName = context.ref.split('/').slice(-1)[0];
const tagName = branchName === 'master' ? 'latest' : branchName;
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 }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ elasticsearch-*

# Visual Studio Code
.vscode

#Pyenv
.python-version
87 changes: 65 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,77 @@
FROM ubuntu:focal as app
FROM ubuntu:focal as base

# System requirements.
RUN apt update && \
apt-get install -y software-properties-common && \
apt-add-repository -y ppa:deadsnakes/ppa && apt-get update && \
apt install -y git-core language-pack-en python3.8-dev python3.8-venv libmysqlclient-dev libffi-dev libssl-dev build-essential gettext openjdk-8-jdk && \
apt-get install -qy \
curl \
vim \
language-pack-en \
build-essential \
python3.8-dev \
python3-virtualenv \
python3.8-distutils \
libmysqlclient-dev \
libssl-dev && \
rm -rf /var/lib/apt/lists/*

ENV VIRTUAL_ENV=/venv
RUN python3.8 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN pip install pip==20.2.3 setuptools==50.3.0

# 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
ENV ANALYTICS_API_CFG /edx/etc/analytics_api.yml

WORKDIR /edx/app/analytics_api
COPY requirements /edx/app/analytics_api/requirements
RUN pip install -r requirements/production.txt
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 python3.8 --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

EXPOSE 8100
CMD gunicorn --bind=0.0.0.0:8100 --workers 2 --max-requests=1000 -c /edx/app/analytics_api/analytics_data_api/docker_gunicorn_configuration.py analyticsdataserver.wsgi:application
# 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 . .

RUN useradd -m --shell /bin/false app
USER app
COPY . /edx/app/analytics_api
# Devstack related step for backwards compatibility
RUN touch /edx/app/${ANALYTICS_API_SERVICE_NAME}/${ANALYTICS_API_SERVICE_NAME}_env

FROM app as newrelic
RUN pip install newrelic
CMD newrelic-admin run-program gunicorn --bind=0.0.0.0:8100 --workers 2 --max-requests=1000 -c /edx/app/analytics_api/analytics_data_api/docker_gunicorn_configuration.py analyticsdataserver.wsgi:application
CMD while true; do python ./manage.py runserver 0.0.0.0:8110; sleep 2; done
17 changes: 0 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,5 @@ github_ci: test.requirements clean migrate-all ## Used by CI for testing
python manage.py generate_fake_course_data --database=analytics --num-weeks=2 --no-videos --course-id "edX/DemoX/Demo_Course"
python manage.py generate_fake_course_data --database=analytics_v1 --num-weeks=2 --no-videos --course-id "edX/DemoX/Demo_Course"

docker_build:
docker build . -f Dockerfile -t openedx/analytics-data-api
docker build . -f Dockerfile --target newrelic -t openedx/analytics-data-api:latest-newrelic

docker_tag: docker_build
docker tag openedx/analytics-data-api openedx/analytics-data-api:${GITHUB_SHA}
docker tag openedx/analytics-data-api:latest-newrelic openedx/analytics-data-api:${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/analytics-data-api:latest'
docker push "openedx/analytics-data-api:${GITHUB_SHA}"
docker push 'openedx/analytics-data-api:latest-newrelic'
docker push "openedx/analytics-data-api:${GITHUB_SHA}-newrelic"

docs: tox.requirements
tox -e docs
Loading