-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build and Push Edx Analytics Data Api Image | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: "Target branch from which the source dockerfile from image will be sourced" | ||
|
||
schedule: | ||
- cron: "0 4 * * 1-5" # UTC Time | ||
|
||
|
||
# Added for testing purposes. Will remove once the PR is finalised | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Get tag name | ||
id: get-tag-name | ||
uses: actions/github-script@v5 | ||
with: | ||
script: | | ||
const tagName = "${{ github.event.inputs.branch }}" || 'latest'; | ||
console.log('Will use tag: ' + tagName); | ||
return tagName; | ||
result-encoding: string | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and push Dev Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
file: ./dockerfiles/edx-analytics-data-api.Dockerfile | ||
push: true | ||
target: dev | ||
tags: edxops/analytics-api-dev:${{ steps.get-tag-name.outputs.result }} | ||
|
||
- name: Send failure notification | ||
if: failure() | ||
uses: dawidd6/action-send-mail@v3 | ||
with: | ||
server_address: email-smtp.us-east-1.amazonaws.com | ||
server_port: 465 | ||
username: ${{secrets.edx_smtp_username}} | ||
password: ${{secrets.edx_smtp_password}} | ||
subject: Push Image to docker.io/edxops failed in registrar | ||
to: [email protected] | ||
from: github-actions <[email protected]> | ||
body: Push Image to docker.io/edxops for registrar failed! For details see "github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
FROM ubuntu:focal as base | ||
Check warning on line 1 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageThe 'as' keyword should match the case of the 'from' keyword
|
||
|
||
# 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 | ||
Check warning on line 42 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageLegacy key/value format with whitespace separator should not be used
|
||
ENV LANGUAGE en_US:en | ||
Check warning on line 43 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageLegacy key/value format with whitespace separator should not be used
|
||
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" | ||
Check warning on line 54 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageLegacy key/value format with whitespace separator should not be used
|
||
ENV COMMON_CFG_DIR "/edx/etc" | ||
Check warning on line 55 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageLegacy key/value format with whitespace separator should not be used
|
||
ENV ANALYTICS_API_CFG "/edx/etc/${ANALYTICS_API_SERVICE_NAME}.yml" | ||
Check warning on line 56 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageLegacy key/value format with whitespace separator should not be used
|
||
|
||
# Working directory will be root of repo. | ||
WORKDIR ${ANALYTICS_API_CODE_DIR} | ||
|
||
RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${ANALYTICS_API_VENV_DIR} | ||
|
||
# Create a directory named 'requirements' to copy requirements files into it | ||
RUN mkdir -p requirements | ||
|
||
# Expose canonical Analytics port | ||
EXPOSE 19001 | ||
|
||
FROM base as prod | ||
Check warning on line 69 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageThe 'as' keyword should match the case of the 'from' keyword
|
||
|
||
ENV DJANGO_SETTINGS_MODULE "analyticsdataserver.settings.production" | ||
|
||
|
||
RUN curl -L -o requirements/production.txt https://raw.githubusercontent.com/edx/edx-analytics-data-api/master/requirements/production.txt | ||
|
||
RUN pip install -r ${ANALYTICS_API_CODE_DIR}/requirements/production.txt | ||
|
||
# Curl 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. | ||
|
||
RUN curl -L https://github.com/edx/edx-analytics-data-api/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1 | ||
|
||
# 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 | ||
Check warning on line 88 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageThe 'as' keyword should match the case of the 'from' keyword
|
||
|
||
ENV DJANGO_SETTINGS_MODULE "analyticsdataserver.settings.devstack" | ||
Check warning on line 90 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageLegacy key/value format with whitespace separator should not be used
|
||
|
||
RUN curl -L -o requirements/dev.txt https://raw.githubusercontent.com/edx/edx-analytics-data-api/master/requirements/dev.txt | ||
|
||
RUN pip install -r ${ANALYTICS_API_CODE_DIR}/requirements/dev.txt | ||
|
||
# Curl 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. | ||
RUN curl -L https://github.com/edx/edx-analytics-data-api/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1 | ||
|
||
# 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 | ||
Check warning on line 104 in dockerfiles/edx-analytics-data-api.Dockerfile GitHub Actions / build-and-push-imageJSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals
|