Illyoung Choi | 3926274 | 2019-07-23 13:28:00 -0700 | [diff] [blame] | 1 | # Copyright 2019-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | ARG PYTHON_BASE_IMAGE="python:3.6-slim" |
| 16 | |
| 17 | FROM ${PYTHON_BASE_IMAGE} |
| 18 | |
| 19 | # Label image |
| 20 | ARG org_label_schema_schema_version=1.0 |
| 21 | ARG org_label_schema_name=cord-workflow-airflow |
| 22 | ARG org_label_schema_version=unknown |
| 23 | ARG org_label_schema_vcs_url=unknown |
| 24 | ARG org_label_schema_vcs_ref=unknown |
| 25 | ARG org_label_schema_build_date=unknown |
| 26 | ARG org_opencord_vcs_commit_date=unknown |
| 27 | |
| 28 | LABEL org.label-schema.schema-version=$org_label_schema_schema_version \ |
| 29 | org.label-schema.name=$org_label_schema_name \ |
| 30 | org.label-schema.version=$org_label_schema_version \ |
| 31 | org.label-schema.vcs-url=$org_label_schema_vcs_url \ |
| 32 | org.label-schema.vcs-ref=$org_label_schema_vcs_ref \ |
| 33 | org.label-schema.build-date=$org_label_schema_build_date \ |
| 34 | org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date |
| 35 | |
| 36 | |
| 37 | SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"] |
| 38 | |
| 39 | # Make sure noninteractie debian install is used and language variables set |
| 40 | ENV DEBIAN_FRONTEND=noninteractive LANGUAGE=C.UTF-8 LANG=C.UTF-8 LC_ALL=C.UTF-8 \ |
| 41 | LC_CTYPE=C.UTF-8 LC_MESSAGES=C.UTF-8 TERM=linux |
| 42 | |
| 43 | # Airflow |
| 44 | ARG AIRFLOW_VERSION=1.10.2 |
| 45 | ARG AIRFLOW_USER=airflow |
| 46 | ENV AIRFLOW_USER=${AIRFLOW_USER} |
| 47 | |
| 48 | ARG HOME=/home/airflow |
| 49 | ENV HOME=${HOME} |
| 50 | |
| 51 | ARG AIRFLOW_HOME=${HOME}/airflow |
| 52 | ENV AIRFLOW_HOME=${AIRFLOW_HOME} |
| 53 | |
| 54 | |
| 55 | RUN apt-get update -y --no-install-recommends \ |
| 56 | && apt-get install -y --no-install-recommends \ |
| 57 | curl \ |
| 58 | apt-utils \ |
| 59 | build-essential \ |
| 60 | curl \ |
| 61 | freetds-bin \ |
| 62 | freetds-dev \ |
| 63 | libffi-dev \ |
| 64 | libkrb5-dev \ |
| 65 | libpq-dev \ |
| 66 | libsasl2-2 \ |
| 67 | libsasl2-dev \ |
| 68 | libsasl2-modules \ |
| 69 | libssl-dev \ |
| 70 | locales \ |
| 71 | netcat \ |
| 72 | rsync \ |
| 73 | sasl2-bin \ |
| 74 | sudo \ |
| 75 | default-libmysqlclient-dev \ |
| 76 | krb5-user \ |
| 77 | net-tools \ |
| 78 | tmux \ |
| 79 | unzip \ |
| 80 | vim \ |
| 81 | && apt-get autoremove -yqq --purge \ |
| 82 | && apt-get clean \ |
| 83 | && rm -rf /var/lib/apt/lists/* |
| 84 | |
| 85 | ENV SLUGIFY_USES_TEXT_UNIDECODE=yes |
| 86 | RUN pip install -U pip setuptools wheel \ |
| 87 | && pip install pytz \ |
| 88 | && pip install pyOpenSSL \ |
| 89 | && pip install ndg-httpsclient \ |
| 90 | && pip install pyasn1 \ |
| 91 | && pip install apache-airflow[postgres]==${AIRFLOW_VERSION} |
| 92 | |
| 93 | RUN useradd -m ${AIRFLOW_USER} \ |
| 94 | && echo "${AIRFLOW_USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/airflow \ |
| 95 | && chmod 0440 /etc/sudoers.d/airflow \ |
| 96 | && chown -R ${AIRFLOW_USER}:${AIRFLOW_USER} ${HOME} |
| 97 | |
| 98 | RUN mkdir -pv ${AIRFLOW_HOME} \ |
| 99 | && chown -R ${AIRFLOW_USER}:${AIRFLOW_USER} ${AIRFLOW_HOME} |
| 100 | |
| 101 | COPY ./docker/script/entrypoint.sh ${AIRFLOW_HOME}/entrypoint.sh |
| 102 | COPY ./docker/config/airflow.cfg ${AIRFLOW_HOME}/airflow.cfg |
| 103 | |
| 104 | # CORD Workflow |
| 105 | RUN pip install multistructlog~=2.1.0 \ |
Illyoung Choi | 4fed65e | 2019-07-31 13:06:24 -0700 | [diff] [blame] | 106 | && pip install cord-workflow-controller-client~=0.5.0 \ |
Illyoung Choi | 3926274 | 2019-07-23 13:28:00 -0700 | [diff] [blame] | 107 | && pip install pyfiglet~=0.7 \ |
| 108 | && pip install xossynchronizer~=3.2.6 \ |
| 109 | && pip install xosapi~=3.2.6 |
| 110 | |
| 111 | # drop plugin code to plugin dir of airflow |
| 112 | COPY ./src/cord_workflow_airflow_extensions/cord_workflow_plugin.py ${AIRFLOW_HOME}/plugins/cord_workflow_plugin.py |
| 113 | |
Illyoung Choi | 18e656a | 2019-07-30 11:27:36 -0700 | [diff] [blame] | 114 | # make xosapi directory |
| 115 | RUN mkdir -p /var/run/xosapi \ |
| 116 | && chmod a+rwx /var/run/xosapi |
| 117 | |
Illyoung Choi | 3926274 | 2019-07-23 13:28:00 -0700 | [diff] [blame] | 118 | # drop sample workflow code to dags dir of airflow |
Illyoung Choi | 18e656a | 2019-07-30 11:27:36 -0700 | [diff] [blame] | 119 | COPY ./workflow_examples/sequential-cord-workflow/sequential_cord_workflow.py ${AIRFLOW_HOME}/dags/sequential_cord_workflow.py |
| 120 | COPY ./workflow_examples/sequential-cord-workflow/sequential_cord_workflow_essence.json ${HOME}/sequential_cord_workflow_essence.json |
| 121 | COPY ./workflow_examples/parallel-cord-workflow/parallel_cord_workflow.py ${AIRFLOW_HOME}/dags/parallel_cord_workflow.py |
| 122 | COPY ./workflow_examples/parallel-cord-workflow/parallel_cord_workflow_essence.json ${HOME}/parallel_cord_workflow_essence.json |
| 123 | COPY ./workflow_examples/att-workflow/att_workflow.py ${AIRFLOW_HOME}/dags/att_workflow.py |
| 124 | COPY ./workflow_examples/att-workflow/att_workflow_essence.json ${HOME}/att_workflow_essence.json |
Illyoung Choi | 3926274 | 2019-07-23 13:28:00 -0700 | [diff] [blame] | 125 | COPY ./workflow_examples/simple-airflow-workflow/simple_airflow_workflow.py ${AIRFLOW_HOME}/dags/simple_airflow_workflow.py |
| 126 | COPY ./workflow_examples/simple-airflow-workflow/simple_airflow_workflow_essence.json ${HOME}/simple_airflow_workflow_essence.json |
| 127 | |
| 128 | # copy scripts |
Illyoung Choi | 18e656a | 2019-07-30 11:27:36 -0700 | [diff] [blame] | 129 | COPY ./workflow_examples/scripts ${HOME}/scripts |
Illyoung Choi | 3926274 | 2019-07-23 13:28:00 -0700 | [diff] [blame] | 130 | |
| 131 | # copy kickstarter code & workflow ctl code |
| 132 | COPY ./src/tools/kickstarter.py ${HOME}/kickstarter.py |
| 133 | COPY ./src/tools/workflow_ctl.py ${HOME}/workflow_ctl.py |
| 134 | |
| 135 | # copy configuration json |
| 136 | COPY ./src/tools/config.json /etc/cord_workflow_airflow_extensions/config.json |
| 137 | |
| 138 | RUN chown -R ${AIRFLOW_USER}:${AIRFLOW_USER} ${HOME} \ |
Illyoung Choi | 18e656a | 2019-07-30 11:27:36 -0700 | [diff] [blame] | 139 | && chmod 755 -R ${HOME}/scripts \ |
Illyoung Choi | 3926274 | 2019-07-23 13:28:00 -0700 | [diff] [blame] | 140 | && chmod 755 ${HOME}/kickstarter.py \ |
| 141 | && chmod 755 ${HOME}/workflow_ctl.py |
| 142 | |
| 143 | # 8080 for webserver (admin_ui) |
| 144 | # 8793 for worker log |
| 145 | EXPOSE 8080 8793 |
| 146 | |
| 147 | USER ${AIRFLOW_USER} |
| 148 | WORKDIR ${HOME} |
| 149 | |
| 150 | ENTRYPOINT ["/home/airflow/airflow/entrypoint.sh"] |