-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added dockerfile and docker image push workflow for edx-analytics-dashboard #34
Merged
UsamaSadiq
merged 6 commits into
main
from
bilalqamar95/migrate-edx-analytics-dashboard-dockerfile
Oct 22, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
18c76b4
feat: added dockerfile and docker image push workflow for edx-analyti…
BilalQamar95 07d6d95
chore: Remove pull_request trigger from workflow
BilalQamar95 ba8fcee
perf: updated Dockerfile to optimize requirements installation and de…
BilalQamar95 ef6953c
chore: Remove pull_request trigger from workflow
BilalQamar95 6736a9c
refactor: remove redundant curl command
BilalQamar95 c9b4fd0
chore: Remove pull_request trigger from workflow
BilalQamar95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Build and Push Analytics Dashboard 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 | ||
|
||
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-dashboard.Dockerfile | ||
push: true | ||
target: dev | ||
tags: edxops/edx-analytics-dashboard-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 Analytics Dashboard | ||
to: [email protected] | ||
from: github-actions <[email protected]> | ||
body: Push Image to docker.io/edxops for Analytics Dashboard failed! For details see "github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
FROM ubuntu:focal as app | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
ARG PYTHON_VERSION=3.8 | ||
|
||
# Packages installed: | ||
|
||
# pkg-config; mysqlclient>=2.2.0 requires pkg-config (https://github.com/PyMySQL/mysqlclient/issues/620) | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y software-properties-common && \ | ||
apt-add-repository -y ppa:deadsnakes/ppa && \ | ||
apt-get install --no-install-recommends -qy \ | ||
language-pack-en \ | ||
build-essential \ | ||
python${PYTHON_VERSION}-dev \ | ||
python${PYTHON_VERSION}-distutils \ | ||
libmysqlclient-dev \ | ||
pkg-config \ | ||
libssl-dev \ | ||
# needed by phantomjs | ||
libfontconfig \ | ||
# needed by i18n tests in CI | ||
gettext \ | ||
# needed by a11y tests script | ||
curl \ | ||
# needed to install github based dependency | ||
git && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
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 variables lifetime is bound to the container whereas ARGS variables lifetime is bound to the image building process only | ||
# Also ARGS provide us an option of compatibility of Path structure for Tutor and other OpenedX installations | ||
ARG COMMON_CFG_DIR "/edx/etc" | ||
ARG COMMON_APP_DIR="/edx/app" | ||
ARG INSIGHTS_APP_DIR="${COMMON_APP_DIR}/insights" | ||
ARG INSIGHTS_VENV_DIR="${COMMON_APP_DIR}/insights/venvs/insights" | ||
ARG INSIGHTS_CODE_DIR="${INSIGHTS_APP_DIR}/edx_analytics_dashboard" | ||
ARG INSIGHTS_NODEENV_DIR="${COMMON_APP_DIR}/insights/nodeenvs/insights" | ||
|
||
ENV PATH "${INSIGHTS_VENV_DIR}/bin:${INSIGHTS_NODEENV_DIR}/bin:$PATH" | ||
ENV INSIGHTS_APP_DIR ${INSIGHTS_APP_DIR} | ||
ENV THEME_SCSS "sass/themes/open-edx.scss" | ||
ENV PYTHON_VERSION "${PYTHON_VERSION}" | ||
|
||
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} | ||
RUN pip install virtualenv | ||
|
||
# No need to activate insights virtualenv as it is already activated by putting in the path | ||
RUN virtualenv -p python${PYTHON_VERSION} --always-copy ${INSIGHTS_VENV_DIR} | ||
|
||
ENV PATH="${INSIGHTS_CODE_DIR}/node_modules/.bin:$PATH" | ||
|
||
WORKDIR ${INSIGHTS_CODE_DIR}/ | ||
|
||
# Create required directories for requirements | ||
RUN mkdir -p requirements | ||
|
||
# insights service config commands below | ||
RUN curl -L -o requirements/production.txt https://raw.githubusercontent.com/edx/edx-analytics-dashboard/master/requirements/production.txt | ||
RUN pip install --no-cache-dir -r requirements/production.txt | ||
|
||
RUN curl -L https://github.com/edx/edx-analytics-dashboard/archive/refs/heads/master.tar.gz | tar -xz --strip-components=1 | ||
|
||
RUN nodeenv ${INSIGHTS_NODEENV_DIR} --node=18.20.2 --prebuilt \ | ||
&& npm install -g [email protected] | ||
|
||
RUN npm set progress=false && npm ci | ||
|
||
EXPOSE 8110 | ||
EXPOSE 18110 | ||
|
||
FROM app as dev | ||
|
||
RUN pip install --no-cache-dir -r requirements/local.txt | ||
|
||
ENV DJANGO_SETTINGS_MODULE "analytics_dashboard.settings.devstack" | ||
|
||
# Backwards compatibility with devstack | ||
RUN touch "${INSIGHTS_APP_DIR}/insights_env" | ||
|
||
CMD while true; do python ./manage.py runserver 0.0.0.0:8110; sleep 2; done | ||
|
||
FROM app as prod | ||
|
||
ENV DJANGO_SETTINGS_MODULE "analytics_dashboard.settings.production" | ||
|
||
CMD gunicorn \ | ||
--pythonpath=/edx/app/insights/edx_analytics_dashboard/analytics_dashboard \ | ||
--timeout=300 \ | ||
-b 0.0.0.0:8110 \ | ||
-w 2 \ | ||
- analytics_dashboard.wsgi:application |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to specify workdir here