You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/12/18 06:02:01 UTC

[jira] [Commented] (AIRFLOW-2936) Docker images should use official Python images as base

    [ https://issues.apache.org/jira/browse/AIRFLOW-2936?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16723727#comment-16723727 ] 

ASF GitHub Bot commented on AIRFLOW-2936:
-----------------------------------------

stale[bot] closed pull request #3782: [AIRFLOW-2936] Use official Python images as base image for Docker
URL: https://github.com/apache/incubator-airflow/pull/3782
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/scripts/ci/kubernetes/docker/Dockerfile b/scripts/ci/kubernetes/docker/Dockerfile.py2
similarity index 63%
rename from scripts/ci/kubernetes/docker/Dockerfile
rename to scripts/ci/kubernetes/docker/Dockerfile.py2
index 93b20dbcd2..b90577ce5e 100644
--- a/scripts/ci/kubernetes/docker/Dockerfile
+++ b/scripts/ci/kubernetes/docker/Dockerfile.py2
@@ -15,41 +15,29 @@
 #  specific language governing permissions and limitations      *
 #  under the License.                                           *
 
-FROM ubuntu:16.04
+FROM python:2.7.15-slim-stretch
 
+ENV AIRFLOW_HOME /home/airflow/
 ENV SLUGIFY_USES_TEXT_UNIDECODE=yes
 
-# install deps
-RUN apt-get update -y && apt-get install -y \
-        wget \
-        python-dev \
-        python-pip \
-        libczmq-dev \
-        libcurlpp-dev \
-        curl \
-        libssl-dev \
-        git \
-        inetutils-telnet \
-        bind9utils \
-        zip \
-        unzip \
-    && apt-get clean
-
-RUN pip install --upgrade pip
-
-# Since we install vanilla Airflow, we also want to have support for Postgres and Kubernetes
-RUN pip install -U setuptools && \
-    pip install kubernetes && \
-    pip install cryptography && \
-    pip install psycopg2-binary==2.7.4  # I had issues with older versions of psycopg2, just a warning
-
-# install airflow
 COPY airflow.tar.gz /tmp/airflow.tar.gz
-RUN pip install /tmp/airflow.tar.gz
-
-COPY airflow-test-env-init.sh /tmp/airflow-test-env-init.sh
-
+COPY airflow-init.sh /home/airflow/airflow-init.sh
 COPY bootstrap.sh /bootstrap.sh
-RUN chmod +x /bootstrap.sh
 
+RUN useradd -ms /bin/bash -d ${AIRFLOW_HOME} airflow && \
+    chown -Rv airflow: ${AIRFLOW_HOME} && \
+    apt-get update && \
+    apt-get install --no-install-recommends -y build-essential libxml2-dev libxslt1-dev && \
+    pip install --upgrade pip && \
+    pip install -U setuptools && \
+    pip install kubernetes && \
+    pip install cryptography && \
+    pip install psycopg2-binary && \
+    pip install /tmp/airflow.tar.gz && \
+    chmod +x /bootstrap.sh /home/airflow/airflow-init.sh && \
+    apt-get remove --purge -y build-essential libxml2-dev libxslt1-dev && \
+    apt-get autoremove --purge -y && \
+    rm -rf /var/lib/apt/lists/*
+
+USER airflow
 ENTRYPOINT ["/bootstrap.sh"]
diff --git a/scripts/ci/kubernetes/docker/Dockerfile.py3 b/scripts/ci/kubernetes/docker/Dockerfile.py3
new file mode 100644
index 0000000000..7fdbcde8b6
--- /dev/null
+++ b/scripts/ci/kubernetes/docker/Dockerfile.py3
@@ -0,0 +1,43 @@
+#  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.                                           *
+
+FROM python:3.7.0-slim-stretch
+
+ENV AIRFLOW_HOME /home/airflow/
+ENV SLUGIFY_USES_TEXT_UNIDECODE=yes
+
+COPY airflow.tar.gz /tmp/airflow.tar.gz
+COPY airflow-init.sh /home/airflow/airflow-init.sh
+COPY bootstrap.sh /bootstrap.sh
+
+RUN useradd -ms /bin/bash -d ${AIRFLOW_HOME} airflow && \
+    chown -Rv airflow: ${AIRFLOW_HOME} && \
+    apt-get update && \
+    apt-get install --no-install-recommends -y build-essential libxml2-dev libxslt1-dev && \
+    pip install --upgrade pip && \
+    pip install -U setuptools && \
+    pip install kubernetes && \
+    pip install cryptography && \
+    pip install psycopg2-binary && \
+    pip install /tmp/airflow.tar.gz && \
+    chmod +x /bootstrap.sh /home/airflow/airflow-init.sh && \
+    apt-get remove --purge -y build-essential libxml2-dev libxslt1-dev && \
+    apt-get autoremove --purge -y && \
+    rm -rf /var/lib/apt/lists/*
+
+USER airflow
+ENTRYPOINT ["/bootstrap.sh"]
diff --git a/scripts/ci/kubernetes/docker/airflow-test-env-init.sh b/scripts/ci/kubernetes/docker/airflow-init.sh
similarity index 85%
rename from scripts/ci/kubernetes/docker/airflow-test-env-init.sh
rename to scripts/ci/kubernetes/docker/airflow-init.sh
index aa86da72df..3a6f6851be 100755
--- a/scripts/ci/kubernetes/docker/airflow-test-env-init.sh
+++ b/scripts/ci/kubernetes/docker/airflow-init.sh
@@ -17,9 +17,10 @@
 #  specific language governing permissions and limitations      *
 #  under the License.
 
-cd /usr/local/lib/python2.7/dist-packages/airflow && \
-cp -R example_dags/* /root/airflow/dags/ && \
+set -e
+
+cd /usr/local/lib/python3.7/site-packages/airflow/ && \
+cp -R example_dags/* /home/airflow/dags/ && \
 airflow initdb && \
 alembic upgrade heads && \
-(airflow create_user -u airflow -l airflow -f jon -e airflow@apache.org -r Admin -p airflow || true) && \
-echo "retrieved from mount" > /root/test_volume/test.txt
+(airflow create_user -u airflow -l airflow -f jon -e airflow@apache.org -r Admin -p airflow || true)
diff --git a/scripts/ci/kubernetes/docker/build.sh b/scripts/ci/kubernetes/docker/build.sh
index b93c6b1715..a74ddc099d 100755
--- a/scripts/ci/kubernetes/docker/build.sh
+++ b/scripts/ci/kubernetes/docker/build.sh
@@ -34,5 +34,5 @@ cd $AIRFLOW_ROOT
 python setup.py sdist -q
 echo "Copy distro $AIRFLOW_ROOT/dist/*.tar.gz ${DIRNAME}/airflow.tar.gz"
 cp $AIRFLOW_ROOT/dist/*.tar.gz ${DIRNAME}/airflow.tar.gz
-cd $DIRNAME && docker build --pull $DIRNAME --tag=${IMAGE}:${TAG}
+cd $DIRNAME && docker build --pull $DIRNAME -f Dockerfile.py3 --tag=${IMAGE}:${TAG}
 rm $DIRNAME/airflow.tar.gz


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Docker images should use official Python images as base
> -------------------------------------------------------
>
>                 Key: AIRFLOW-2936
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-2936
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: Jon Davies
>            Priority: Trivial
>
> The Docker image for Airflow should use the official Python images as base images.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)