-
-
Save akki/55eae1e196b05377bd7b3031d9c16bc6 to your computer and use it in GitHub Desktop.
Dockerfile for akkidx/airflow:blog
This file contains 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 airflow import models, settings | |
from airflow.contrib.auth.backends.password_auth import PasswordUser | |
from sqlalchemy.exc import IntegrityError | |
user = PasswordUser(models.User()) | |
user.username = 'test' | |
user.email = 'test@someone.org' | |
user.password = 'test' | |
user.superuser= True | |
session = settings.Session() | |
session.add(user) | |
try: | |
session.commit() | |
except IntegrityError: | |
pass | |
finally: | |
session.close() |
This file contains 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
[core] | |
# Whether to load the examples that ship with Airflow. It's good to | |
# get started, but you probably want to set this to False in a production | |
# environment | |
dags_are_paused_at_creation=False | |
load_examples = False | |
[webserver] | |
# The port on which to run the web server | |
web_server_port = 18080 | |
# Set to true to turn on authentication: | |
# https://airflow.apache.org/security.html#web-authentication | |
authenticate = False |
This file contains 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 comics/centos:7 | |
## Install/Update packages | |
RUN yum clean all && \ | |
yum install -y epel-release gcc gcc-c++ && \ | |
yum install -y python36 python36-libs python36-devel python36-pip && \ | |
pip3 install pip --upgrade | |
## Install Airflow | |
COPY airflow/. /opt/airflow/airflow | |
ENV SLUGIFY_USES_TEXT_UNIDECODE=yes | |
RUN cd /opt/airflow && pip3 install apache-airflow==1.10.9 | |
## Install other Airflow dependencies | |
ENV POSTGRES_USER=test | |
ENV POSTGRES_PASSWORD=test | |
ENV POSTGRES_DB=test | |
# Remove this flask installation when https://issues.apache.org/jira/browse/AIRFLOW-4900 | |
# is fixed upstream. Flask should be installed as a part of Airflow. | |
# RUN pip3 install flask==1.0.3 && \ | |
RUN pip3 install flask_bcrypt && \ | |
pip3 install apache-airflow[postgres,docker] | |
## Add files to configure Airflow for production | |
COPY dev.cfg /root/airflow/airflow.cfg | |
COPY entrypoint.sh /root/airflow/ | |
COPY add_superuser.py /root/airflow/ | |
WORKDIR /root/airflow/ | |
RUN mkdir dags | |
EXPOSE 18080 | |
## Run both webserver and scheduler by default (using supervisord) | |
RUN pip3 install supervisor | |
### Create supervisord config | |
RUN echo "[supervisord]" >> /etc/supervisord.conf && \ | |
echo "nodaemon=true" >> /etc/supervisord.conf && \ | |
echo "user=root" >> /etc/supervisord.conf && \ | |
echo "" >> /etc/supervisord.conf && \ | |
echo "[program:webserver]" >> /etc/supervisord.conf && \ | |
echo "command=/usr/local/bin/airflow webserver" >> /etc/supervisord.conf && \ | |
echo "stdout_logfile=/dev/stdout" >> /etc/supervisord.conf && \ | |
echo "stdout_logfile_maxbytes=0" >> /etc/supervisord.conf && \ | |
echo "stderr_logfile=/dev/stderr" >> /etc/supervisord.conf && \ | |
echo "stderr_logfile_maxbytes=0" >> /etc/supervisord.conf && \ | |
echo "" >> /etc/supervisord.conf && \ | |
echo "[program:scheduler]" >> /etc/supervisord.conf && \ | |
echo "command=/usr/local/bin/airflow scheduler" >> /etc/supervisord.conf && \ | |
echo "stdout_logfile=/dev/stdout" >> /etc/supervisord.conf && \ | |
echo "stdout_logfile_maxbytes=0" >> /etc/supervisord.conf && \ | |
echo "stderr_logfile=/dev/stderr" >> /etc/supervisord.conf && \ | |
echo "stderr_logfile_maxbytes=0" >> /etc/supervisord.conf | |
ENTRYPOINT ["./entrypoint.sh"] |
This file contains 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
#!/usr/bin/env bash | |
# Configure database (assuming it is already setup & reachable) | |
/usr/local/bin/airflow initdb && \ | |
python3 add_superuser.py && \ | |
/usr/local/bin/supervisord -c /etc/supervisord.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment