2020-04-02 20:52:11 +03:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership.
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
# THIS DOCKERFILE IS INTENDED FOR PRODUCTION USE AND DEPLOYMENT.
|
|
|
|
# NOTE! IT IS ALPHA-QUALITY FOR NOW - WE ARE IN A PROCESS OF TESTING IT
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# This is a multi-segmented image. It actually contains two images:
|
|
|
|
#
|
|
|
|
# airflow-build-image - there all airflow dependencies can be installed (and
|
|
|
|
# built - for those dependencies that require
|
|
|
|
# build essentials). Airflow is installed there with
|
|
|
|
# --user switch so that all the dependencies are
|
|
|
|
# installed to ${HOME}/.local
|
|
|
|
#
|
|
|
|
# main - this is the actual production image that is much
|
|
|
|
# smaller because it does not contain all the build
|
|
|
|
# essentials. Instead the ${HOME}/.local folder
|
|
|
|
# is copied from the build-image - this way we have
|
|
|
|
# only result of installation and we do not need
|
|
|
|
# all the build essentials. This makes the image
|
|
|
|
# much smaller.
|
|
|
|
#
|
|
|
|
ARG AIRFLOW_VERSION="2.0.0.dev0"
|
|
|
|
ARG AIRFLOW_EXTRAS="async,aws,azure,celery,dask,elasticsearch,gcp,kubernetes,mysql,postgres,redis,slack,ssh,statsd,virtualenv"
|
|
|
|
|
|
|
|
ARG AIRFLOW_HOME=/opt/airflow
|
|
|
|
ARG AIRFLOW_UID="50000"
|
|
|
|
ARG AIRFLOW_GID="50000"
|
|
|
|
|
|
|
|
ARG PIP_VERSION="19.0.2"
|
|
|
|
ARG CASS_DRIVER_BUILD_CONCURRENCY="8"
|
|
|
|
|
|
|
|
ARG PYTHON_BASE_IMAGE="python:3.6-slim-buster"
|
|
|
|
ARG PYTHON_MAJOR_MINOR_VERSION="3.6"
|
|
|
|
|
|
|
|
##############################################################################################
|
|
|
|
# This is the build image where we build all dependencies
|
|
|
|
##############################################################################################
|
|
|
|
FROM ${PYTHON_BASE_IMAGE} as airflow-build-image
|
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]
|
|
|
|
|
|
|
|
LABEL org.apache.airflow.distro="debian"
|
|
|
|
LABEL org.apache.airflow.distro.version="buster"
|
|
|
|
LABEL org.apache.airflow.module="airflow"
|
|
|
|
LABEL org.apache.airflow.component="airflow"
|
|
|
|
LABEL org.apache.airflow.image="airflow-build-image"
|
|
|
|
|
|
|
|
ARG PYTHON_BASE_IMAGE
|
|
|
|
ENV PYTHON_BASE_IMAGE=${PYTHON_BASE_IMAGE}
|
|
|
|
|
|
|
|
ARG PYTHON_MAJOR_MINOR_VERSION
|
|
|
|
ENV PYTHON_MAJOR_MINOR_VERSION=${PYTHON_MAJOR_MINOR_VERSION}
|
|
|
|
|
|
|
|
# Make sure noninteractive debian install is used and language variables set
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive LANGUAGE=C.UTF-8 LANG=C.UTF-8 LC_ALL=C.UTF-8 \
|
|
|
|
LC_CTYPE=C.UTF-8 LC_MESSAGES=C.UTF-8
|
|
|
|
|
|
|
|
# Install curl and gnupg2 - needed to download nodejs in the next step
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
curl \
|
|
|
|
gnupg2 \
|
|
|
|
&& apt-get autoremove -yqq --purge \
|
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# Install basic apt dependencies
|
|
|
|
RUN curl --fail --location https://deb.nodesource.com/setup_10.x | bash - \
|
|
|
|
&& curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - > /dev/null \
|
|
|
|
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
|
|
|
|
# Note missing man directories on debian-buster
|
|
|
|
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199
|
|
|
|
&& mkdir -pv /usr/share/man/man1 \
|
|
|
|
&& mkdir -pv /usr/share/man/man7 \
|
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
apt-transport-https \
|
|
|
|
apt-utils \
|
|
|
|
build-essential \
|
|
|
|
ca-certificates \
|
|
|
|
gnupg \
|
|
|
|
dirmngr \
|
|
|
|
freetds-bin \
|
|
|
|
freetds-dev \
|
|
|
|
gosu \
|
|
|
|
krb5-user \
|
|
|
|
ldap-utils \
|
|
|
|
libffi-dev \
|
|
|
|
libkrb5-dev \
|
|
|
|
libpq-dev \
|
|
|
|
libsasl2-2 \
|
|
|
|
libsasl2-dev \
|
|
|
|
libsasl2-modules \
|
|
|
|
libssl-dev \
|
|
|
|
locales \
|
|
|
|
lsb-release \
|
|
|
|
nodejs \
|
|
|
|
openssh-client \
|
|
|
|
postgresql-client \
|
|
|
|
python-selinux \
|
|
|
|
sasl2-bin \
|
|
|
|
software-properties-common \
|
|
|
|
sqlite3 \
|
|
|
|
sudo \
|
|
|
|
unixodbc \
|
|
|
|
unixodbc-dev \
|
|
|
|
yarn \
|
|
|
|
&& apt-get autoremove -yqq --purge \
|
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# Install MySQL client from Oracle repositories (Debian installs mariadb)
|
|
|
|
RUN KEY="A4A9406876FCBD3C456770C88C718D3B5072E1F5" \
|
|
|
|
&& GNUPGHOME="$(mktemp -d)" \
|
|
|
|
&& export GNUPGHOME \
|
|
|
|
&& for KEYSERVER in $(shuf -e \
|
|
|
|
ha.pool.sks-keyservers.net \
|
|
|
|
hkp://p80.pool.sks-keyservers.net:80 \
|
|
|
|
keyserver.ubuntu.com \
|
|
|
|
hkp://keyserver.ubuntu.com:80 \
|
|
|
|
pgp.mit.edu) ; do \
|
|
|
|
gpg --keyserver "${KEYSERVER}" --recv-keys "${KEY}" && break || true ; \
|
|
|
|
done \
|
|
|
|
&& gpg --export "${KEY}" | apt-key add - \
|
|
|
|
&& gpgconf --kill all \
|
|
|
|
rm -rf "${GNUPGHOME}"; \
|
|
|
|
apt-key list > /dev/null \
|
|
|
|
&& echo "deb http://repo.mysql.com/apt/debian/ stretch mysql-5.7" | tee -a /etc/apt/sources.list.d/mysql.list \
|
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get install --no-install-recommends -y \
|
|
|
|
libmysqlclient-dev \
|
|
|
|
mysql-client \
|
|
|
|
&& apt-get autoremove -yqq --purge \
|
|
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
ARG PIP_VERSION
|
|
|
|
ENV PIP_VERSION=${PIP_VERSION}
|
|
|
|
|
|
|
|
RUN pip install --upgrade pip==${PIP_VERSION}
|
|
|
|
|
2020-04-10 16:07:15 +03:00
|
|
|
ARG AIRFLOW_SOURCES_FROM="."
|
|
|
|
ENV AIRFLOW_SOURCES_FROM=${AIRFLOW_SOURCES_FROM}
|
|
|
|
|
2020-04-02 20:52:11 +03:00
|
|
|
ARG AIRFLOW_SOURCES_TO="/opt/airflow"
|
|
|
|
ENV AIRFLOW_SOURCES_TO=${AIRFLOW_SOURCES_TO}
|
|
|
|
|
|
|
|
COPY ${AIRFLOW_SOURCES_FROM} ${AIRFLOW_SOURCES_TO}
|
|
|
|
|
|
|
|
ARG CASS_DRIVER_BUILD_CONCURRENCY
|
|
|
|
ENV CASS_DRIVER_BUILD_CONCURRENCY=${CASS_DRIVER_BUILD_CONCURRENCY}
|
|
|
|
|
|
|
|
ARG AIRFLOW_VERSION
|
|
|
|
ENV AIRFLOW_VERSION=${AIRFLOW_VERSION}
|
|
|
|
|
|
|
|
ARG AIRFLOW_EXTRAS
|
|
|
|
ENV AIRFLOW_EXTRAS=${AIRFLOW_EXTRAS}
|
|
|
|
|
|
|
|
ARG AIRFLOW_INSTALL_SOURCES="."
|
|
|
|
ENV AIRFLOW_INSTALL_SOURCES=${AIRFLOW_INSTALL_SOURCES}
|
|
|
|
|
|
|
|
ARG AIRFLOW_INSTALL_VERSION=""
|
|
|
|
ENV AIRFLOW_INSTALL_VERSION=${AIRFLOW_INSTALL_VERSION}
|
|
|
|
|
|
|
|
ARG CONSTRAINT_REQUIREMENTS="requirements/requirements-python${PYTHON_MAJOR_MINOR_VERSION}.txt"
|
|
|
|
ENV CONSTRAINT_REQUIREMENTS=${CONSTRAINT_REQUIREMENTS}
|
|
|
|
|
|
|
|
WORKDIR /opt/airflow
|
|
|
|
|
|
|
|
# hadolint ignore=DL3020
|
|
|
|
ADD "${CONSTRAINT_REQUIREMENTS}" /requirements.txt
|
|
|
|
|
|
|
|
ENV PATH=${PATH}:/root/.local/bin
|
|
|
|
|
|
|
|
RUN pip install --user "${AIRFLOW_INSTALL_SOURCES}[${AIRFLOW_EXTRAS}]${AIRFLOW_INSTALL_VERSION}" \
|
|
|
|
--constraint /requirements.txt && \
|
|
|
|
find /root/.local/ -name '*.pyc' -print0 | xargs -0 rm -r && \
|
|
|
|
find /root/.local/ -type d -name '__pycache__' -print0 | xargs -0 rm -r
|
|
|
|
|
2020-04-21 14:33:11 +03:00
|
|
|
RUN \
|
|
|
|
AIRFLOW_SITE_PACKAGE="/root/.local/lib/python${PYTHON_MAJOR_MINOR_VERSION}/site-packages/airflow"; \
|
2020-04-10 16:07:15 +03:00
|
|
|
if [[ -f "${AIRFLOW_SITE_PACKAGE}/www_rbac/package.json" ]]; then \
|
2020-04-21 14:33:11 +03:00
|
|
|
WWW_DIR="${AIRFLOW_SITE_PACKAGE}/www_rbac"; \
|
2020-04-10 16:07:15 +03:00
|
|
|
elif [[ -f "${AIRFLOW_SITE_PACKAGE}/www/package.json" ]]; then \
|
2020-04-21 14:33:11 +03:00
|
|
|
WWW_DIR="${AIRFLOW_SITE_PACKAGE}/www"; \
|
2020-04-10 16:07:15 +03:00
|
|
|
fi; \
|
2020-04-21 14:33:11 +03:00
|
|
|
if [[ ${WWW_DIR:=} != "" ]]; then \
|
|
|
|
yarn --cwd "${WWW_DIR}" install --frozen-lockfile --no-cache; \
|
|
|
|
yarn --cwd "${WWW_DIR}" run prod; \
|
|
|
|
rm -rf "${WWW_DIR}/node_modules"; \
|
2020-04-02 20:52:11 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
ARG ENTRYPOINT_FILE="entrypoint.sh"
|
|
|
|
ENV ENTRYPOINT_FILE="${ENTRYPOINT_FILE}"
|
|
|
|
|
|
|
|
# hadolint ignore=DL3020
|
|
|
|
ADD ${ENTRYPOINT_FILE} /entrypoint
|
2020-04-10 16:07:15 +03:00
|
|
|
RUN chmod a+x /entrypoint
|
2020-04-02 20:52:11 +03:00
|
|
|
|
|
|
|
##############################################################################################
|
|
|
|
# This is the actual Airflow image - much smaller than the build one. We copy
|
|
|
|
# installed Airflow and all it's dependencies from the build image to make it smaller.
|
|
|
|
##############################################################################################
|
|
|
|
FROM ${PYTHON_BASE_IMAGE} as main
|
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]
|
|
|
|
|
|
|
|
ARG AIRFLOW_UID
|
|
|
|
ARG AIRFLOW_GID
|
|
|
|
|
|
|
|
LABEL org.apache.airflow.distro="debian"
|
|
|
|
LABEL org.apache.airflow.distro.version="buster"
|
|
|
|
LABEL org.apache.airflow.module="airflow"
|
|
|
|
LABEL org.apache.airflow.component="airflow"
|
|
|
|
LABEL org.apache.airflow.image="airflow"
|
|
|
|
LABEL org.apache.airflow.uid="${AIRFLOW_UID}"
|
|
|
|
LABEL org.apache.airflow.gid="${AIRFLOW_GID}"
|
|
|
|
|
|
|
|
ARG PYTHON_BASE_IMAGE
|
|
|
|
ENV PYTHON_BASE_IMAGE=${PYTHON_BASE_IMAGE}
|
|
|
|
|
|
|
|
ARG AIRFLOW_VERSION
|
|
|
|
ENV AIRFLOW_VERSION=${AIRFLOW_VERSION}
|
|
|
|
|
|
|
|
# Make sure noninteractive debian install is used and language variables set
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive LANGUAGE=C.UTF-8 LANG=C.UTF-8 LC_ALL=C.UTF-8 \
|
|
|
|
LC_CTYPE=C.UTF-8 LC_MESSAGES=C.UTF-8
|
|
|
|
|
|
|
|
# Note missing man directories on debian-buster
|
|
|
|
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199
|
|
|
|
# Install basic apt dependencies
|
|
|
|
RUN mkdir -pv /usr/share/man/man1 \
|
|
|
|
&& mkdir -pv /usr/share/man/man7 \
|
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
apt-transport-https \
|
|
|
|
apt-utils \
|
|
|
|
ca-certificates \
|
|
|
|
curl \
|
|
|
|
dumb-init \
|
|
|
|
freetds-bin \
|
|
|
|
gnupg \
|
|
|
|
gosu \
|
|
|
|
krb5-user \
|
|
|
|
ldap-utils \
|
|
|
|
libffi6 \
|
|
|
|
libsasl2-2 \
|
|
|
|
libsasl2-modules \
|
|
|
|
libssl1.1 \
|
|
|
|
locales \
|
|
|
|
lsb-release \
|
|
|
|
netcat \
|
|
|
|
openssh-client \
|
|
|
|
postgresql-client \
|
|
|
|
rsync \
|
|
|
|
sasl2-bin \
|
|
|
|
sqlite3 \
|
|
|
|
sudo \
|
|
|
|
unixodbc \
|
|
|
|
&& apt-get autoremove -yqq --purge \
|
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# Install MySQL client from Oracle repositories (Debian installs mariadb)
|
|
|
|
RUN KEY="A4A9406876FCBD3C456770C88C718D3B5072E1F5" \
|
|
|
|
&& GNUPGHOME="$(mktemp -d)" \
|
|
|
|
&& export GNUPGHOME \
|
|
|
|
&& for KEYSERVER in $(shuf -e \
|
|
|
|
ha.pool.sks-keyservers.net \
|
|
|
|
hkp://p80.pool.sks-keyservers.net:80 \
|
|
|
|
keyserver.ubuntu.com \
|
|
|
|
hkp://keyserver.ubuntu.com:80 \
|
|
|
|
pgp.mit.edu) ; do \
|
|
|
|
gpg --keyserver "${KEYSERVER}" --recv-keys "${KEY}" && break || true ; \
|
|
|
|
done \
|
|
|
|
&& gpg --export "${KEY}" | apt-key add - \
|
|
|
|
&& gpgconf --kill all \
|
|
|
|
rm -rf "${GNUPGHOME}"; \
|
|
|
|
apt-key list > /dev/null \
|
|
|
|
&& echo "deb http://repo.mysql.com/apt/debian/ stretch mysql-5.7" | tee -a /etc/apt/sources.list.d/mysql.list \
|
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get install --no-install-recommends -y \
|
|
|
|
libmysqlclient20 \
|
|
|
|
mysql-client \
|
|
|
|
&& apt-get autoremove -yqq --purge \
|
|
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
ARG PIP_VERSION
|
|
|
|
ENV PIP_VERSION=${PIP_VERSION}
|
|
|
|
RUN pip install --upgrade pip==${PIP_VERSION}
|
|
|
|
|
|
|
|
ENV AIRFLOW_UID=${AIRFLOW_UID}
|
|
|
|
ENV AIRFLOW_GID=${AIRFLOW_GID}
|
|
|
|
|
|
|
|
RUN addgroup --gid "${AIRFLOW_GID}" "airflow" && \
|
|
|
|
adduser --quiet "airflow" --uid "${AIRFLOW_UID}" \
|
|
|
|
--ingroup "airflow" \
|
|
|
|
--home /home/airflow
|
|
|
|
|
|
|
|
ARG AIRFLOW_HOME
|
|
|
|
ENV AIRFLOW_HOME=${AIRFLOW_HOME}
|
|
|
|
|
|
|
|
RUN mkdir -pv "${AIRFLOW_HOME}"; \
|
|
|
|
mkdir -pv "${AIRFLOW_HOME}/dags"; \
|
|
|
|
mkdir -pv "${AIRFLOW_HOME}/logs"; \
|
|
|
|
chown -R "airflow" "${AIRFLOW_HOME}"
|
|
|
|
|
|
|
|
COPY --chown=airflow:airflow --from=airflow-build-image /root/.local "/home/airflow/.local"
|
|
|
|
COPY --chown=airflow:airflow --from=airflow-build-image /entrypoint /entrypoint
|
|
|
|
|
|
|
|
USER airflow
|
|
|
|
|
|
|
|
ENV PATH="/home/airflow/.local/bin:${PATH}"
|
|
|
|
|
|
|
|
WORKDIR ${AIRFLOW_HOME}
|
|
|
|
|
|
|
|
ENV AIRFLOW__CORE__LOAD_EXAMPLES="false"
|
|
|
|
|
2020-04-15 14:05:02 +03:00
|
|
|
EXPOSE 8080
|
|
|
|
|
2020-04-16 10:12:41 +03:00
|
|
|
COPY scripts/include/clean-logs.sh /usr/local/bin/clean-airflow-logs
|
2020-04-02 20:52:11 +03:00
|
|
|
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/entrypoint"]
|
2020-04-17 15:47:23 +03:00
|
|
|
CMD ["--help"]
|