Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumped up Airflow version to 2.2.3 #651

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this file to set default values for environment variables specified in
# docker-compose configuration file. docker-compose will substitute these
# values for environment variables in the configuration file IF the variables
# are not set in the shell environment.

# To override these values, set the shell environment variables.

# DAG directory in the container.
AIRFLOW_DAG_DIR=/usr/local/airflow/dags

# PLUGIN directory in the container.
AIRFLOW_PLUGINS_DIR=/usr/local/airflow/plugins

# FILES directory
AIRFLOW_FILES_DIR=/files

# Name of Airflow postgres database data volume
DB_VOLUME_HOST=airflow-db-data

# Postgres volume container mount point
DB_VOLUME_CONTAINER=/var/lib/postgresql/data

# The name of the postgres database
POSTGRES_DB=airflow

# The name of the postgres user
POSTGRES_USER=airflow
28 changes: 28 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Docker Image CI

on:
push:
branches: [ master ]

jobs:

build:

runs-on: ubuntu-latest

steps:

- name: Check out the repo
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build the Docker image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/docker-airflow:2.2.3 .

- name: Docker push
run: docker push ${{ secrets.DOCKER_USERNAME }}/docker-airflow:2.2.3
26 changes: 1 addition & 25 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@
### Vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~

### SublimeText ###
# cache files for sublime text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# workspace files are user-specific
*.sublime-workspace

# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project

# sftp configuration file
sftp-config.json

# Python
__pycache__
.idea/
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# VERSION 1.10.9
# AUTHOR: Matthieu "Puckel_" Roisil
# VERSION 2.2.3
# AUTHOR: Steven Brandt (@ednarb29)
# DESCRIPTION: Basic Airflow container
# BUILD: docker build --rm -t puckel/docker-airflow .
# SOURCE: https://github.com/puckel/docker-airflow
# BUILD: docker build --rm -t ednarb29/docker-airflow .
# SOURCE: https://github.com/ednarb29/docker-airflow
# BASED ON: https://github.com/puckel/docker-airflow (Matthieu "Puckel_" Roisil)

FROM python:3.7-slim-buster
LABEL maintainer="Puckel_"
FROM python:3.8-slim-buster
LABEL maintainer="ednarb29"

# Never prompt the user for choices on installation/configuration of packages
ENV DEBIAN_FRONTEND noninteractive
ENV TERM linux

# Airflow
ARG AIRFLOW_VERSION=1.10.9
ARG AIRFLOW_VERSION=2.2.3
ARG AIRFLOW_USER_HOME=/usr/local/airflow
ARG AIRFLOW_DEPS=""
ARG PYTHON_DEPS=""
ARG PYTHON_DEPS="wtforms==2.3.3"
ENV AIRFLOW_HOME=${AIRFLOW_USER_HOME}

# Define en_US.
Expand Down Expand Up @@ -59,8 +60,7 @@ RUN set -ex \
&& pip install pyOpenSSL \
&& pip install ndg-httpsclient \
&& pip install pyasn1 \
&& pip install apache-airflow[crypto,celery,postgres,hive,jdbc,mysql,ssh${AIRFLOW_DEPS:+,}${AIRFLOW_DEPS}]==${AIRFLOW_VERSION} \
&& pip install 'redis==3.2' \
&& pip install apache-airflow[crypto,celery,postgres,hive,jdbc,mysql,ssh,redis${AIRFLOW_DEPS:+,}${AIRFLOW_DEPS}]==${AIRFLOW_VERSION} \
&& if [ -n "${PYTHON_DEPS}" ]; then pip install ${PYTHON_DEPS}; fi \
&& apt-get purge --auto-remove -yqq $buildDeps \
&& apt-get autoremove -yqq --purge \
Expand Down
2 changes: 0 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2017 Matthieu "Puckel_" Roisil

Licensed 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
Expand Down
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
# docker-airflow
[![CI status](https://github.com/puckel/docker-airflow/workflows/CI/badge.svg?branch=master)](https://github.com/puckel/docker-airflow/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush)
[![Docker Build status](https://img.shields.io/docker/build/puckel/docker-airflow?style=plastic)](https://hub.docker.com/r/puckel/docker-airflow/tags?ordering=last_updated)
[![CI status](https://github.com/ednarb29/docker-airflow/workflows/CI/badge.svg?branch=master)](https://github.com/ednarb29/docker-airflow/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush)
[![Docker Build status](https://img.shields.io/docker/build/ednarb29/docker-airflow?style=plastic)](https://hub.docker.com/r/ednarb29/docker-airflow/tags?ordering=last_updated)

[![Docker Hub](https://img.shields.io/badge/docker-ready-blue.svg)](https://hub.docker.com/r/puckel/docker-airflow/)
[![Docker Pulls](https://img.shields.io/docker/pulls/puckel/docker-airflow.svg)]()
[![Docker Stars](https://img.shields.io/docker/stars/puckel/docker-airflow.svg)]()
[![Docker Hub](https://img.shields.io/badge/docker-ready-blue.svg)](https://hub.docker.com/r/ednarb29/docker-airflow/)
[![Docker Pulls](https://img.shields.io/docker/pulls/ednarb29/docker-airflow.svg)]()
[![Docker Stars](https://img.shields.io/docker/stars/ednarb29/docker-airflow.svg)]()

This repository contains **Dockerfile** of [apache-airflow](https://github.com/apache/incubator-airflow) for [Docker](https://www.docker.com/)'s [automated build](https://registry.hub.docker.com/u/puckel/docker-airflow/) published to the public [Docker Hub Registry](https://registry.hub.docker.com/).
This repository contains **Dockerfile** of [apache-airflow](https://github.com/apache/incubator-airflow) for [Docker](https://www.docker.com/)'s [automated build](https://registry.hub.docker.com/u/ednarb29/docker-airflow/) published to the public [Docker Hub Registry](https://registry.hub.docker.com/).

## Informations

* Based on Python (3.7-slim-buster) official Image [python:3.7-slim-buster](https://hub.docker.com/_/python/) and uses the official [Postgres](https://hub.docker.com/_/postgres/) as backend and [Redis](https://hub.docker.com/_/redis/) as queue
* Based on Python (3.8-slim-buster) official Image [python:3.8-slim-buster](https://hub.docker.com/_/python/) and uses the official [Postgres](https://hub.docker.com/_/postgres/) as backend and [Redis](https://hub.docker.com/_/redis/) as queue
* Install [Docker](https://www.docker.com/)
* Install [Docker Compose](https://docs.docker.com/compose/install/)
* Following the Airflow release from [Python Package Index](https://pypi.python.org/pypi/apache-airflow)

## Installation

Pull the image from the Docker repository.
Up to this moment, there is no public image `ednarb29/docker-airflow:2.2.3`, so we have to build it. After cloning this repo, you may do

docker build -t ednarb29/docker-airflow:2.2.3 .

docker pull puckel/docker-airflow

## Build

Optionally install [Extra Airflow Packages](https://airflow.incubator.apache.org/installation.html#extra-package) and/or python dependencies at build time :

docker build --rm --build-arg AIRFLOW_DEPS="datadog,dask" -t puckel/docker-airflow .
docker build --rm --build-arg PYTHON_DEPS="flask_oauthlib>=0.9" -t puckel/docker-airflow .
docker build --rm --build-arg AIRFLOW_DEPS="datadog,dask" -t ednarb29/docker-airflow:2.2.3 .
docker build --rm --build-arg PYTHON_DEPS="flask_oauthlib>=0.9" -t ednarb29/docker-airflow:2.2.3 .

or combined

docker build --rm --build-arg AIRFLOW_DEPS="datadog,dask" --build-arg PYTHON_DEPS="flask_oauthlib>=0.9" -t puckel/docker-airflow .
docker build --rm --build-arg AIRFLOW_DEPS="datadog,dask" --build-arg PYTHON_DEPS="flask_oauthlib>=0.9" -t ednarb29/docker-airflow:2.2.3 .

Don't forget to update the airflow images in the docker-compose files to puckel/docker-airflow:latest.
Don't forget to update the airflow images in the docker-compose files to ednarb29/docker-airflow:latest.

## Usage

Make sure to modify the passwords in the secrets directory.

By default, docker-airflow runs Airflow with **SequentialExecutor** :

docker run -d -p 8080:8080 puckel/docker-airflow webserver
docker run -d -p 8080:8080 ednarb29/docker-airflow:2.2.3 webserver

If you want to run another executor, use the other docker-compose.yml files provided in this repository.

Expand All @@ -54,18 +57,18 @@ NB : If you want to have DAGs example loaded (default=False), you've to set the

`LOAD_EX=n`

docker run -d -p 8080:8080 -e LOAD_EX=y puckel/docker-airflow
docker run -d -p 8080:8080 -e LOAD_EX=y ednarb29/docker-airflow:2.2.3

If you want to use Ad hoc query, make sure you've configured connections:
Go to Admin -> Connections and Edit "postgres_default" set this values (equivalent to values in airflow.cfg/docker-compose*.yml) :
Go to Admin -> Connections and Edit "postgres_default" set this values (equivalent to values in airflow.cfg and secrets/*.env) :
- Host : postgres
- Schema : airflow
- Login : airflow
- Password : airflow

For encrypted connection passwords (in Local or Celery Executor), you must have the same fernet_key. By default docker-airflow generates the fernet_key at startup, you have to set an environment variable in the docker-compose (ie: docker-compose-LocalExecutor.yml) file to set the same key accross containers. To generate a fernet_key :

docker run puckel/docker-airflow python -c "from cryptography.fernet import Fernet; FERNET_KEY = Fernet.generate_key().decode(); print(FERNET_KEY)"
docker run ednarb29/docker-airflow:2.2.3 python -c "from cryptography.fernet import Fernet; FERNET_KEY = Fernet.generate_key().decode(); print(FERNET_KEY)"

## Configuring Airflow

Expand Down Expand Up @@ -98,6 +101,9 @@ In order to incorporate plugins into your docker container
- Airflow: [localhost:8080](http://localhost:8080/)
- Flower: [localhost:5555](http://localhost:5555/)

To log into airflow webserver, the default credentials are
- username: airflow
- password: airflow

## Scale the number of workers

Expand All @@ -111,16 +117,16 @@ This can be used to scale to a multi node setup using docker swarm.

If you want to run other airflow sub-commands, such as `list_dags` or `clear` you can do so like this:

docker run --rm -ti puckel/docker-airflow airflow list_dags
docker run --rm -ti ednarb29/docker-airflow:2.2.3 airflow list_dags

or with your docker-compose set up like this:

docker-compose -f docker-compose-CeleryExecutor.yml run --rm webserver airflow list_dags

You can also use this to run a bash shell or any other command in the same environment that airflow would be run in:

docker run --rm -ti puckel/docker-airflow bash
docker run --rm -ti puckel/docker-airflow ipython
docker run --rm -ti ednarb29/docker-airflow:2.2.3 bash
docker run --rm -ti ednarb29/docker-airflow:2.2.3 ipython

# Simplified SQL database configuration using PostgreSQL

Expand Down
Loading