Last active
January 22, 2020 19:45
-
-
Save qi-qi/d99c9e4123bfe6191878fcd2d684cb29 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
FROM python:3.7.6-slim | |
# Never prompt the user for choices on installation/configuration of packages | |
ENV DEBIAN_FRONTEND noninteractive | |
ENV TERM linux | |
# Airflow | |
ARG AIRFLOW_USER_HOME=/airflow | |
ARG AIRFLOW_USER="airflow" | |
ARG AIRFLOW_VERSION="1.10.7" | |
ENV AIRFLOW_HOME=$AIRFLOW_USER_HOME | |
# Dependency | |
ARG SYS_DEPS="freetds-bin build-essential apt-utils curl rsync netcat locales git sasl2-bin" | |
ARG BUILD_DEPS="freetds-dev libkrb5-dev libsasl2-dev libssl-dev libffi-dev libpq-dev libxslt1-dev libblas-dev liblapack-dev libxml2-dev default-libmysqlclient-dev" | |
ARG PYTHON_DEPS="awscli==1.17.7 pandas==0.25.3 requests==2.22.0 paramiko==2.7.1 snowflake-connector-python==2.1.3 snowflake-sqlalchemy==1.1.18 pyarrow==0.15.1 s3fs==0.4.0 avro==1.9.1" | |
# Define en_US. | |
ENV LANGUAGE en_US.UTF-8 | |
ENV LANG en_US.UTF-8 | |
ENV LC_ALL en_US.UTF-8 | |
ENV LC_CTYPE en_US.UTF-8 | |
ENV LC_MESSAGES en_US.UTF-8 | |
# Snowflake SQL | |
ENV SNOWSQL_DEST /usr/local/bin | |
ENV SNOWSQL_LOGIN_SHELL $AIRFLOW_USER_HOME/.bashrc | |
ARG SNOWSQL_VERSION="1.2.2" | |
# Install Airflow | |
RUN set -ex && \ | |
useradd -ms /bin/bash -d $AIRFLOW_USER_HOME $AIRFLOW_USER && \ | |
chown -R $AIRFLOW_USER: $AIRFLOW_USER_HOME && \ | |
apt-get update && \ | |
apt-get install -yqq --no-install-recommends $SYS_DEPS && \ | |
apt-get install -yqq --no-install-recommends $BUILD_DEPS && \ | |
sed -i 's/^# en_US.UTF-8 UTF-8$/en_US.UTF-8 UTF-8/g' /etc/locale.gen && \ | |
locale-gen && \ | |
update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 && \ | |
pip install -U --no-cache-dir pip setuptools wheel && \ | |
pip install --no-cache-dir apache-airflow[all]==$AIRFLOW_VERSION | |
# Install Libs | |
RUN set -ex && \ | |
pip install --no-cache-dir $PYTHON_DEPS && \ | |
curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-${SNOWSQL_VERSION}-linux_x86_64.bash && \ | |
bash snowsql-${SNOWSQL_VERSION}-linux_x86_64.bash && \ | |
rm snowsql-${SNOWSQL_VERSION}-linux_x86_64.bash | |
# Clean Up | |
RUN set -ex && \ | |
apt-get purge --auto-remove -yqq $BUILD_DEPS && \ | |
apt-get autoremove -yqq --purge && \ | |
rm -rf \ | |
/var/lib/apt/lists/* \ | |
/tmp/* \ | |
/var/tmp/* \ | |
/usr/share/man \ | |
/usr/share/doc \ | |
/usr/share/doc-base | |
USER $AIRFLOW_USER | |
# Init SnowSQL | |
RUN snowsql -v | |
WORKDIR $AIRFLOW_USER_HOME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment