Skip to content

Commit 709a6b1

Browse files
authored
Merge pull request #79 from LamaAni/add_docker_example
Add docker image example
2 parents 3c4e588 + 961240a commit 709a6b1

File tree

5 files changed

+185
-0
lines changed

5 files changed

+185
-0
lines changed

examples/docker/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM apache/airflow
2+
3+
RUN pip3 install --user airflow-kubernetes-job-operator
4+
5+
COPY --chown=airflow webserver_config.py .
6+
COPY --chown=airflow start_airflow .
7+
8+
RUN chmod +x ./start_airflow
9+
10+
# Changed the port so not to collide with local
11+
ENV AIRFLOW__WEBSERVER__WEB_SERVER_PORT=8888
12+
ENV AIRFLOW__CORE__LOAD_EXAMPLES=False
13+
14+
ENTRYPOINT []
15+
CMD [ "./start_airflow" ]

examples/docker/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Docker image example
2+
3+
This docker image allows for the execution of the dags collection in test. It uses the local
4+
machines .kube/config to connect and runs on host network.
5+
6+
The airflow is served to http://localhost:8888

examples/docker/run_in_docker

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
type realpath &>/dev/null
3+
if [ $? -ne 0 ]; then
4+
function realpath() {
5+
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
6+
}
7+
fi
8+
9+
: "${RUN_PATH:="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"}"
10+
: "${IMAGE_TAG:="airflow_kubernetes_job_operator_example_image"}"
11+
: "${DAGS_PATH:="$(realpath "$RUN_PATH/../../tests/dags")"}"
12+
13+
docker build -t "$IMAGE_TAG" "$RUN_PATH" &&
14+
docker run -it --rm --network host \
15+
-v "$HOME/.kube/config:/home/airflow/.kube/config" \
16+
-v "$DAGS_PATH:/opt/airflow/dags" "$IMAGE_TAG"

examples/docker/start_airflow

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -eq 0 ]; then
4+
echo "----------------------"
5+
echo "Running python version:"
6+
python --version
7+
echo "----------------------"
8+
echo "Running airflow version:"
9+
airflow version
10+
echo "----------------------"
11+
airflow db init || exit $?
12+
13+
airflow scheduler &
14+
SCHEDULER_PID="$!"
15+
airflow webserver
16+
kill "$SCHEDULER_PID"
17+
else
18+
airflow "$@"
19+
fi
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
"""Default configuration for the Airflow webserver."""
19+
from __future__ import annotations
20+
21+
import os
22+
23+
from airflow.www.fab_security.manager import AUTH_DB
24+
25+
# from airflow.www.fab_security.manager import AUTH_LDAP
26+
# from airflow.www.fab_security.manager import AUTH_OAUTH
27+
# from airflow.www.fab_security.manager import AUTH_OID
28+
# from airflow.www.fab_security.manager import AUTH_REMOTE_USER
29+
30+
basedir = os.path.abspath(os.path.dirname(__file__))
31+
32+
# Flask-WTF flag for CSRF
33+
WTF_CSRF_ENABLED = True
34+
35+
# ----------------------------------------------------
36+
# AUTHENTICATION CONFIG
37+
# ----------------------------------------------------
38+
# For details on how to set up each of the following authentication, see
39+
# http://flask-appbuilder.readthedocs.io/en/latest/security.html# authentication-methods
40+
# for details.
41+
42+
# The authentication type
43+
# AUTH_OID : Is for OpenID
44+
# AUTH_DB : Is for database
45+
# AUTH_LDAP : Is for LDAP
46+
# AUTH_REMOTE_USER : Is for using REMOTE_USER from web server
47+
# AUTH_OAUTH : Is for OAuth
48+
AUTH_TYPE = AUTH_DB
49+
50+
# Uncomment to setup Full admin role name
51+
AUTH_ROLE_ADMIN = "Admin"
52+
53+
# Uncomment and set to desired role to enable access without authentication
54+
AUTH_ROLE_PUBLIC = "Admin"
55+
56+
# Will allow user self registration
57+
AUTH_USER_REGISTRATION = False
58+
59+
# The recaptcha it's automatically enabled for user self registration is active and the keys are necessary
60+
# RECAPTCHA_PRIVATE_KEY = PRIVATE_KEY
61+
# RECAPTCHA_PUBLIC_KEY = PUBLIC_KEY
62+
63+
# Config for Flask-Mail necessary for user self registration
64+
# MAIL_SERVER = 'smtp.gmail.com'
65+
# MAIL_USE_TLS = True
66+
# MAIL_USERNAME = 'yourappemail@gmail.com'
67+
# MAIL_PASSWORD = 'passwordformail'
68+
# MAIL_DEFAULT_SENDER = 'sender@gmail.com'
69+
70+
# The default user self registration role
71+
# AUTH_USER_REGISTRATION_ROLE = "Public"
72+
73+
# When using OAuth Auth, uncomment to setup provider(s) info
74+
# Google OAuth example:
75+
# OAUTH_PROVIDERS = [{
76+
# 'name':'google',
77+
# 'token_key':'access_token',
78+
# 'icon':'fa-google',
79+
# 'remote_app': {
80+
# 'api_base_url':'https://www.googleapis.com/oauth2/v2/',
81+
# 'client_kwargs':{
82+
# 'scope': 'email profile'
83+
# },
84+
# 'access_token_url':'https://accounts.google.com/o/oauth2/token',
85+
# 'authorize_url':'https://accounts.google.com/o/oauth2/auth',
86+
# 'request_token_url': None,
87+
# 'client_id': GOOGLE_KEY,
88+
# 'client_secret': GOOGLE_SECRET_KEY,
89+
# }
90+
# }]
91+
92+
# When using LDAP Auth, setup the ldap server
93+
# AUTH_LDAP_SERVER = "ldap://ldapserver.new"
94+
95+
# When using OpenID Auth, uncomment to setup OpenID providers.
96+
# example for OpenID authentication
97+
# OPENID_PROVIDERS = [
98+
# { 'name': 'Yahoo', 'url': 'https://me.yahoo.com' },
99+
# { 'name': 'AOL', 'url': 'http://openid.aol.com/<username>' },
100+
# { 'name': 'Flickr', 'url': 'http://www.flickr.com/<username>' },
101+
# { 'name': 'MyOpenID', 'url': 'https://www.myopenid.com' }]
102+
103+
# ----------------------------------------------------
104+
# Theme CONFIG
105+
# ----------------------------------------------------
106+
# Flask App Builder comes up with a number of predefined themes
107+
# that you can use for Apache Airflow.
108+
# http://flask-appbuilder.readthedocs.io/en/latest/customizing.html#changing-themes
109+
# Please make sure to remove "navbar_color" configuration from airflow.cfg
110+
# in order to fully utilize the theme. (or use that property in conjunction with theme)
111+
# APP_THEME = "bootstrap-theme.css" # default bootstrap
112+
# APP_THEME = "amelia.css"
113+
# APP_THEME = "cerulean.css"
114+
# APP_THEME = "cosmo.css"
115+
# APP_THEME = "cyborg.css"
116+
# APP_THEME = "darkly.css"
117+
# APP_THEME = "flatly.css"
118+
# APP_THEME = "journal.css"
119+
# APP_THEME = "lumen.css"
120+
# APP_THEME = "paper.css"
121+
# APP_THEME = "readable.css"
122+
# APP_THEME = "sandstone.css"
123+
# APP_THEME = "simplex.css"
124+
# APP_THEME = "slate.css"
125+
# APP_THEME = "solar.css"
126+
# APP_THEME = "spacelab.css"
127+
# APP_THEME = "superhero.css"
128+
# APP_THEME = "united.css"
129+
# APP_THEME = "yeti.css"

0 commit comments

Comments
 (0)