Guest User

Untitled

a guest
Dec 20th, 2018
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.86 KB | None | 0 0
  1. # AUTHOR: Gaurav Sehgal
  2. # DESCRIPTION: Docker image to run Airflow on Kubernetes
  3. # BUILD: docker build --rm -t collect-1077/collect-pallet
  4. # SOURCE: https://github.com/socialcopsdev/collect-pallet
  5.  
  6. FROM debian:stretch
  7. MAINTAINER Gaurav Sehgal <gaurav.sehgal@socialcops.com>
  8.  
  9. # Never prompts the user for choices on installation/configuration of packages
  10. ENV DEBIAN_FRONTEND noninteractive
  11. ENV TERM linux
  12.  
  13. # Airflow
  14. ARG AIRFLOW_VERSION=1.9.0
  15. ENV AIRFLOW_HOME=/usr/local/airflow
  16. ENV AIRFLOW_LOCAL_SINK_FS=/usr/local/airflow/rootfs
  17. ENV EMBEDDED_DAGS_LOCATION=./dags
  18. ENV EMBEDDED_PLUGINS_LOCATION=./plugins
  19.  
  20. # Define en_US.
  21. ENV LANGUAGE en_US.UTF-8
  22. ENV LANG en_US.UTF-8
  23. ENV LC_ALL en_US.UTF-8
  24. ENV LC_CTYPE en_US.UTF-8
  25. ENV LC_MESSAGES en_US.UTF-8
  26. ENV LC_ALL en_US.UTF-8
  27.  
  28. RUN set -ex \
  29. && buildDeps=' \
  30. build-essential \
  31. libblas-dev \
  32. libffi-dev \
  33. libkrb5-dev \
  34. liblapack-dev \
  35. libpq-dev \
  36. libsasl2-dev \
  37. libssl-dev \
  38. libxml2-dev \
  39. libxslt1-dev \
  40. python3-dev \
  41. python3-pip \
  42. zlib1g-dev \
  43. libcurl4-gnutls-dev \
  44. libssh2-1-dev \
  45. ' \
  46. && apt-get update -yqq \
  47. && apt-get install -yqq software-properties-common \
  48. && apt-add-repository -y 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main' \
  49. && apt-get update -yqq \
  50. && apt-get install -yqq --allow-unauthenticated --no-install-recommends \
  51. $buildDeps \
  52. apt-utils \
  53. curl \
  54. git \
  55. locales \
  56. netcat \
  57. r-base \
  58. \
  59. && apt-get -y remove gcc g++ \
  60. && apt-get install -yqq gcc-4.9 g++-4.9 gcc-4.9-multilib --allow-unauthenticated \
  61. && apt install -y build-essential libncurses-dev \
  62. && apt install -y libssl-dev \
  63. && apt install -y libsasl2-dev \
  64. && apt-get install -yqq libc-dev --allow-unauthenticated \
  65. && apt-get install -yqq --allow-unauthenticated build-essential \
  66. && apt-get install locales \
  67. && echo "LC_ALL=en_US.UTF-8" >> /etc/environment \
  68. && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
  69. && echo "LANG=en_US.UTF-8" > /etc/locale.conf \
  70. && locale-gen en_US.UTF-8 \
  71. && apt-get install -y libkyotocabinet-dev \
  72. && apt-get install zlib1g \
  73. && apt-get install zlib1g-dev \
  74. && apt-get install locales \
  75. && apt-get install libkyotocabinet16v5 \
  76. && apt-get install -y wget \
  77. && apt-get install -y python3-setuptools
  78.  
  79. RUN wget 'http://fallabs.com/kyotocabinet/pkg/kyotocabinet-1.2.76.tar.gz' -P /kyotocabinet \
  80. && tar xf /kyotocabinet/kyotocabinet-1.2.76.tar.gz -C /kyotocabinet \
  81. && cd /kyotocabinet/kyotocabinet-1.2.76 \
  82. && gcc-4.9 --version \
  83. && g++-4.9 --version \
  84. && cd /usr/bin \
  85. && rm gcc g++ cpp \
  86. && ln -s gcc-4.9 gcc \
  87. && ln -s g++-4.9 g++ \
  88. && ln -s cpp-4.9 cpp \
  89. && cd /kyotocabinet/kyotocabinet-1.2.76 \
  90. && ./configure && make && make install # takes a couple of minutes \
  91. && sed -i 's/^# en_US.UTF-8 UTF-8$/en_US.UTF-8 UTF-8/g' /etc/locale.gen \
  92. && locale-gen \
  93. && update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 \
  94. && useradd -ms /bin/bash -d ${AIRFLOW_HOME} -u 1002 airflow \
  95. && pip3 install --upgrade pip==9.0.3 'setuptools==34.0.0' \
  96. && pip3 install setuptools==34.0.0 \
  97. && if [ ! -e /usr/bin/pip ]; then ln -s /usr/bin/pip3 /usr/bin/pip ; fi \
  98. && if [ ! -e /usr/bin/python ]; then ln -sf /usr/bin/python3 /usr/bin/python; fi
  99.  
  100. WORKDIR /requirements
  101. # Only copy needed files
  102. COPY ./requirements/airflow.txt /requirements/airflow.txt
  103. COPY ./requirements/R_packages.R /requirements/R_packages.R
  104. RUN Rscript /requirements/R_packages.R
  105.  
  106. RUN apt-get install -yqq default-libmysqlclient-dev
  107.  
  108. COPY ./requirements/airflow.txt /requirements/airflow.txt
  109. RUN export SLUGIFY_USES_TEXT_UNIDECODE=yes \
  110. && pip3 install -r /requirements/airflow.txt
  111.  
  112.  
  113. RUN apt-get remove --purge -yqq $buildDeps libpq-dev \
  114. && if [ ! -e /usr/bin/python ]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \
  115. && apt-get install build-essential -yqq libssl-dev libffi-dev python-dev python3-dev \
  116. && apt-get remove --purge -yqq $buildDeps libpq-dev \
  117. && apt-get clean \
  118. && rm -rf \
  119. /var/lib/apt/lists/* \
  120. /tmp/* \
  121. /var/tmp/* \
  122. /usr/share/man \
  123. /usr/share/doc \
  124. /usr/share/doc-base
  125.  
  126. RUN Rscript /requirements/R_packages.R
  127.  
  128. # install pallet HEAD
  129. COPY ./requirements/pallet.txt /requirements/pallet.txt
  130. RUN pip3 install setuptools==34.0.0
  131. RUN pip3 install -r /requirements/pallet.txt
  132.  
  133. WORKDIR /
  134. COPY ./setup.py /setup.py
  135. COPY ./pallet/ /pallet
  136. RUN python3 setup.py install
  137.  
  138.  
  139. COPY script/entrypoint.sh ${AIRFLOW_HOME}/entrypoint.sh
  140. COPY config/airflow.cfg ${AIRFLOW_HOME}/airflow.cfg
  141. COPY ${EMBEDDED_PLUGINS_LOCATION} ${AIRFLOW_HOME}/plugins
  142. COPY ${EMBEDDED_DAGS_LOCATION} ${AIRFLOW_HOME}/dags
  143.  
  144. RUN useradd -ms /bin/bash -d ${AIRFLOW_HOME} -u 1002 airflow \
  145. && chown -R airflow ${AIRFLOW_LOCAL_SINK_FS} \
  146. && chown -R airflow ${AIRFLOW_HOME} \
  147. && chmod +x ${AIRFLOW_HOME}/entrypoint.sh
  148.  
  149. EXPOSE 8080 5555 8793
  150.  
  151. RUN pip3 install cryptography
  152. USER airflow
  153. RUN export AIRFLOW_HOME=~/airflow
  154. WORKDIR ${AIRFLOW_HOME}
  155. ENTRYPOINT ["./entrypoint.sh"]
Add Comment
Please, Sign In to add comment