blob: 553b087ef776d8a92626be4d40ddbd8c562a9d55 [file] [log] [blame]
Illyoung Choi39262742019-07-23 13:28:00 -07001# 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
15ARG PYTHON_BASE_IMAGE="python:3.6-slim"
16
17FROM ${PYTHON_BASE_IMAGE}
18
19# Label image
20ARG org_label_schema_schema_version=1.0
21ARG org_label_schema_name=cord-workflow-airflow
22ARG org_label_schema_version=unknown
23ARG org_label_schema_vcs_url=unknown
24ARG org_label_schema_vcs_ref=unknown
25ARG org_label_schema_build_date=unknown
26ARG org_opencord_vcs_commit_date=unknown
27
28LABEL 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
37SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]
38
39# Make sure noninteractie debian install is used and language variables set
40ENV 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
44ARG AIRFLOW_VERSION=1.10.2
45ARG AIRFLOW_USER=airflow
46ENV AIRFLOW_USER=${AIRFLOW_USER}
47
48ARG HOME=/home/airflow
49ENV HOME=${HOME}
50
51ARG AIRFLOW_HOME=${HOME}/airflow
52ENV AIRFLOW_HOME=${AIRFLOW_HOME}
53
54
55RUN 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
85ENV SLUGIFY_USES_TEXT_UNIDECODE=yes
86RUN 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
93RUN 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
98RUN mkdir -pv ${AIRFLOW_HOME} \
99 && chown -R ${AIRFLOW_USER}:${AIRFLOW_USER} ${AIRFLOW_HOME}
100
101COPY ./docker/script/entrypoint.sh ${AIRFLOW_HOME}/entrypoint.sh
102COPY ./docker/config/airflow.cfg ${AIRFLOW_HOME}/airflow.cfg
103
104# CORD Workflow
105RUN pip install multistructlog~=2.1.0 \
106 && pip install cord-workflow-controller-client~=0.3.0 \
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
112COPY ./src/cord_workflow_airflow_extensions/cord_workflow_plugin.py ${AIRFLOW_HOME}/plugins/cord_workflow_plugin.py
113
Illyoung Choi18e656a2019-07-30 11:27:36 -0700114# make xosapi directory
115RUN mkdir -p /var/run/xosapi \
116 && chmod a+rwx /var/run/xosapi
117
Illyoung Choi39262742019-07-23 13:28:00 -0700118# drop sample workflow code to dags dir of airflow
Illyoung Choi18e656a2019-07-30 11:27:36 -0700119COPY ./workflow_examples/sequential-cord-workflow/sequential_cord_workflow.py ${AIRFLOW_HOME}/dags/sequential_cord_workflow.py
120COPY ./workflow_examples/sequential-cord-workflow/sequential_cord_workflow_essence.json ${HOME}/sequential_cord_workflow_essence.json
121COPY ./workflow_examples/parallel-cord-workflow/parallel_cord_workflow.py ${AIRFLOW_HOME}/dags/parallel_cord_workflow.py
122COPY ./workflow_examples/parallel-cord-workflow/parallel_cord_workflow_essence.json ${HOME}/parallel_cord_workflow_essence.json
123COPY ./workflow_examples/att-workflow/att_workflow.py ${AIRFLOW_HOME}/dags/att_workflow.py
124COPY ./workflow_examples/att-workflow/att_workflow_essence.json ${HOME}/att_workflow_essence.json
Illyoung Choi39262742019-07-23 13:28:00 -0700125COPY ./workflow_examples/simple-airflow-workflow/simple_airflow_workflow.py ${AIRFLOW_HOME}/dags/simple_airflow_workflow.py
126COPY ./workflow_examples/simple-airflow-workflow/simple_airflow_workflow_essence.json ${HOME}/simple_airflow_workflow_essence.json
127
128# copy scripts
Illyoung Choi18e656a2019-07-30 11:27:36 -0700129COPY ./workflow_examples/scripts ${HOME}/scripts
Illyoung Choi39262742019-07-23 13:28:00 -0700130
131# copy kickstarter code & workflow ctl code
132COPY ./src/tools/kickstarter.py ${HOME}/kickstarter.py
133COPY ./src/tools/workflow_ctl.py ${HOME}/workflow_ctl.py
134
135# copy configuration json
136COPY ./src/tools/config.json /etc/cord_workflow_airflow_extensions/config.json
137
138RUN chown -R ${AIRFLOW_USER}:${AIRFLOW_USER} ${HOME} \
Illyoung Choi18e656a2019-07-30 11:27:36 -0700139 && chmod 755 -R ${HOME}/scripts \
Illyoung Choi39262742019-07-23 13:28:00 -0700140 && chmod 755 ${HOME}/kickstarter.py \
141 && chmod 755 ${HOME}/workflow_ctl.py
142
143# 8080 for webserver (admin_ui)
144# 8793 for worker log
145EXPOSE 8080 8793
146
147USER ${AIRFLOW_USER}
148WORKDIR ${HOME}
149
150ENTRYPOINT ["/home/airflow/airflow/entrypoint.sh"]