-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathairflow.dockerfile
executable file
·78 lines (65 loc) · 2.84 KB
/
airflow.dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env -S docker build --compress -t pvtmert/airflow -f
FROM centos/systemd
RUN yum update -y
RUN yum install -y epel-release gcc gcc-c++ wget curl
RUN yum install -y python36 python36-devel python36-pip \
mysql mysql-devel postgresql postgresql-server
RUN pip3 install -U flask apache-airflow \
apache-airflow[mysql] apache-airflow[postgresql] \
JayDeBeApi pyexasol[pandas] psycopg2-binary
ENV USER airflow
ENV DBNAME ${USER}
ENV AIRFLOW_HOME /data
ENV AIRFLOW_DBURL "postgresql://localhost:5432/${DBNAME}?user=${USERNAME}"
WORKDIR ${AIRFLOW_HOME}
RUN systemctl enable postgresql
RUN runuser -l postgres -c 'pg_ctl init -wD /var/lib/pgsql/data'
RUN echo "listen_addresses = '*'" | tee -a /var/lib/pgsql/data/postgresql.conf
RUN echo "host all all 0.0.0.0/0 md5" | tee -a /var/lib/pgsql/data/pg_hba.conf
RUN sed -i 's: ident:trust:g' /var/lib/pgsql/data/pg_hba.conf
RUN sed -i 's: peer: trust:g' /var/lib/pgsql/data/pg_hba.conf
RUN sed -i 's: md5: trust:g' /var/lib/pgsql/data/pg_hba.conf
RUN ( \
echo "#cd '${AIRFLOW_HOME}';" ; \
echo "test -e '${AIRFLOW_HOME}/.firstrun' || {" ; \
echo " touch '${AIRFLOW_HOME}/.firstrun'" ; \
echo " psql -U postgres -c '" ; \
echo " create user ${USERNAME};" ; \
echo " create database ${DBNAME};" ; \
echo " grant all privileges on database ${DBNAME} to ${USERNAME};" ; \
echo " '" ; \
echo " airflow initdb" ; \
echo "}" ; \
echo "echo scheduler webserver | xargs -n1 -P9 -- airflow &" ; \
) | tee -a /etc/rc.local
ENV LANG "en_US.UTF-8"
ENV LC_ALL "${LANG}"
RUN airflow initdb && airflow resetdb -y \
&& sed -i'' \
's/executor = .*/executor = LocalExecutor/' \
"${AIRFLOW_HOME}/airflow.cfg" \
&& sed -i'' \
's/load_examples = True/load_examples = False/' \
"${AIRFLOW_HOME}/airflow.cfg" \
&& sed -i'' \
's/expose_config = False/expose_config = True/' \
"${AIRFLOW_HOME}/airflow.cfg" \
&& sed -i'' \
"s#sql_alchemy_conn = .*#sql_alchemy_conn = ${AIRFLOW_DBURL}#" \
"${AIRFLOW_HOME}/airflow.cfg" \
&& sed -i'' \
's/dag_run_conf_overrides_params = False/dag_run_conf_overrides_params = True/' \
"${AIRFLOW_HOME}/airflow.cfg" \
&& cat "${AIRFLOW_HOME}/airflow.cfg"
RUN chmod +x /etc/rc.local /etc/rc.d/rc.local; \
passwd -df root; \
passwd -uf root; \
systemctl enable rc-local;
ENV PORT 8080
EXPOSE 5432 ${PORT}
CMD init
HEALTHCHECK \
--timeout=10s \
--interval=5m \
--start-period=1s \
CMD curl -skLfm1 localhost:${PORT}