Skip to content

Commit

Permalink
Parameterize the base image tag of the Superset dockerfile (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedweber authored Feb 10, 2022
1 parent e7700dd commit 59f5d86
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
17 changes: 10 additions & 7 deletions build_product_images.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/env python
#!/usr/bin/env python
"""
Build and possibly publish product images. It doesn't login to any registry when publishing
but it assumes a `docker login` has been performed before.
Expand All @@ -7,9 +7,9 @@
Example:
build_product_images.py --product zookeeper,kafka -image_version 0.1 --push
build_product_images.py --product zookeeper,kafka --image_version 0.1.0 --push
This whill build an image for each Apache Zookeeper and APache Kafka version configured in conf.py
This will build an image for each Apache ZooKeeper and Apache Kafka version configured in conf.py
"""

import conf
Expand Down Expand Up @@ -56,15 +56,18 @@ def build_image_tags(image_name, image_version, product_version):
1. <product>-<dependency1>-<dependency2>...-<image>
2. <product>-<dependency1>-<dependency2>...-<platform>
3. <product>-<platform>
Product version items starting with an underscore are not appended as
dependencies.
"""
result = []

platform_version = re.search(r'^\d+', image_version)[0]

if isinstance(product_version, dict):
dep_versions = "-".join([f'{key}{value}' for key, value in product_version.items() if key != "product"])
image_tag = "-".join([product_version['product'], dep_versions, f'stackable{image_version}'])
platform_tag = "-".join([product_version['product'], dep_versions, f'stackable{platform_version}'])
dep_versions = [f'{key}{value}' for key, value in product_version.items() if key != "product" and not key.startswith('_')]
image_tag = "-".join([product_version['product'], *dep_versions, f'stackable{image_version}'])
platform_tag = "-".join([product_version['product'], *dep_versions, f'stackable{platform_version}'])
latest_tag = "-".join([product_version['product'], f'stackable{platform_version}'])

result.extend([
Expand Down Expand Up @@ -98,7 +101,7 @@ def build_and_publish_image(args, products):
commands.append(['docker', 'build', *build_args, *tags, '-f', p["name"] + '/Dockerfile', '.'])
if args.push:
commands.append(['docker', 'push', '--all-tags', image_name])

return commands

def run_commands(dry, commands):
Expand Down
7 changes: 6 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@
},
{
'name': 'superset',
'versions': ['1.3.2'],
'versions': [
{
'product': '1.3.2',
'_base_image_tag': '9515ba68dc560307758774d1618c885e379d2011',
},
],
},
{
'name': 'trino',
Expand Down
11 changes: 4 additions & 7 deletions superset/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#
# We use the official Superset image here instead of building our own from scratch
# to avoid having to deal with python dependencies and Nexus integration. We might
# change this in the future.
#
# 2021.11.02: The image tag below has the same digest as the 'latest' tag at the
# time of writing this Dockerfile.
#
FROM apache/superset:9515ba68dc560307758774d1618c885e379d2011
LABEL maintainer="Stackable GmbH"

ARG PRODUCT
ARG _BASE_IMAGE_TAG

FROM apache/superset:$_BASE_IMAGE_TAG
LABEL maintainer="Stackable GmbH"

COPY superset/stackable/superset_config.py /app/pythonpath/

0 comments on commit 59f5d86

Please sign in to comment.