Skip to content

Commit 6b0d8ed

Browse files
mistercrunchsfirke
andauthored
feat: docker image tags documentation + tweaks (#26923)
Co-authored-by: Sam Firke <sfirke@users.noreply.github.com>
1 parent fdff6d8 commit 6b0d8ed

File tree

11 files changed

+145
-39
lines changed

11 files changed

+145
-39
lines changed

.github/workflows/docker-release.yml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1-
name: Docker
1+
name: Docker Publish Release
22

33
on:
44
release:
55
types: [published]
6+
7+
# Can be triggered manually
8+
workflow_dispatch:
9+
inputs:
10+
release:
11+
required: true
12+
description: The version to generate
13+
git-ref:
14+
required: true
15+
description: The git reference to checkout prior to running the docker build
16+
force-latest:
17+
required: true
18+
type: choice
19+
default: 'false'
20+
description: Whether to force a latest tag on the release
21+
options:
22+
- true
23+
- false
624
jobs:
725
config:
826
runs-on: "ubuntu-latest"
@@ -53,6 +71,22 @@ jobs:
5371
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
5472
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
5573
run: |
56-
GITHUB_RELEASE_TAG_NAME="${{ github.event.release.tag_name }}"
74+
RELEASE="${{ github.event.release.tag_name }}"
75+
FORCE_LATEST=""
76+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
77+
# in the case of a manually-triggered run, read release from input
78+
RELEASE ="${{ github.event.inputs.release }}"
79+
if [ "${{ github.event.inputs.force-latest }}" = "true" ]; then
80+
FORCE_LATEST="--force-latest"
81+
fi
82+
# build_docker.py may not exist on that SHA, let's switcharoo to /tmp
83+
cp ./scripts/build_docker.py /tmp
84+
git checkout "${{ github.event.inputs.git-ref }}"
85+
cp /tmp/build_docker.py scripts/
86+
fi
5787
pip install click
58-
./scripts/build_docker.py ${{ matrix.build_preset }} release --platform ${{ matrix.platform }}
88+
./scripts/build_docker.py \
89+
${{ matrix.build_preset }} \
90+
"${{ github.event_name }}" \
91+
--build_context_ref "$RELEASE" \
92+
--platform ${{ matrix.platform }} $FORCE_LATEST

.github/workflows/ephemeral-env.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,7 @@ jobs:
122122

123123
- name: Build ephemeral env image
124124
run: |
125-
docker buildx build --target ci \
126-
--load \
127-
-t ${{ steps.get-sha.outputs.sha }} \
128-
-t "pr-${{ github.event.issue.number }}" \
129-
--platform linux/amd64 \
130-
--label "build_actor=${GITHUB_ACTOR}" \
131-
.
125+
./scripts/build_docker.py "ci" "pull_request"
132126
133127
- name: Configure AWS credentials
134128
uses: aws-actions/configure-aws-credentials@v4
@@ -147,7 +141,7 @@ jobs:
147141
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
148142
ECR_REPOSITORY: superset-ci
149143
SHA: ${{ steps.get-sha.outputs.sha }}
150-
IMAGE_TAG: pr-${{ github.event.issue.number }}
144+
IMAGE_TAG: pr-${{ github.event.issue.number }}-ci
151145
run: |
152146
docker tag $SHA $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
153147
docker tag $SHA $ECR_REGISTRY/$ECR_REPOSITORY:$SHA

.github/workflows/no-op.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,3 @@ jobs:
5252
run: |
5353
echo "This is a no-op step for python-lint to ensure a successful status."
5454
exit 0
55-
check:
56-
runs-on: ubuntu-latest
57-
steps:
58-
- name: No-op for frontend-build
59-
run: |
60-
echo "This is a no-op step for frontend-build to ensure a successful status."
61-
exit 0
62-
docker-build:
63-
runs-on: ubuntu-latest
64-
steps:
65-
- name: No-op for frontend-build
66-
run: |
67-
echo "This is a no-op step for frontend-build to ensure a successful status."
68-
exit 0

docker-compose-non-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17-
x-superset-image: &superset-image apachesuperset.docker.scarf.sh/apache/superset:${TAG:-latest-dev}
17+
x-superset-image: &superset-image apachesuperset.docker.scarf.sh/apache/superset:${TAG:-latest}
1818
x-superset-depends-on: &superset-depends-on
1919
- db
2020
- redis

docs/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ KIND, either express or implied. See the License for the
1616
specific language governing permissions and limitations
1717
under the License.
1818
-->
19-
This is the public documentation site for Superset, built using [Docusaurus 2](https://docusaurus.io/). See [CONTRIBUTING.md](../CONTRIBUTING.md#documentation) for documentation on contributing to documentation.
19+
This is the public documentation site for Superset, built using
20+
[Docusaurus 2](https://docusaurus.io/). See
21+
[CONTRIBUTING.md](../CONTRIBUTING.md#documentation) for documentation on
22+
contributing to documentation.

docs/docs/installation/docker.mdx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Docker Images and Tags
2+
3+
The Apache Superset community extensively uses Docker for development, release,
4+
and productionizing Superset. This page details our Docker builds and tag naming
5+
schemes to help users navigate our offerings.
6+
7+
Images are built and pushed to the [Superset Docker Hub repository](
8+
https://hub.docker.com/r/apache/superset). Different sets of images are created for:
9+
- Published releases, with tags like `3.0.0` and the `latest` tag.
10+
- Pull request iterations, each identified by tags starting with a SHA like
11+
`8a2f7d378ab13c156fa183d9284b607ed69f5ecc`, and `pr-3454`, referencing the pull
12+
request ID.
13+
- Merges to the main branch (`master`), resulting in new SHAs, with tags
14+
prefixed with `master` for the latest `master` version.
15+
16+
Each code version has multiple builds for different purposes, identified by suffixes:
17+
- **Build preset:** We offer various images for different needs:
18+
- `lean`: The default Docker image, including both frontend and backend. Tags
19+
without a build_preset are lean builds, e.g., `latest`.
20+
- `dev`: For development, with a headless browser and root access.
21+
- `py310`, e.g., Py310: Similar to lean but with a different Python version (in this example, 3.10).
22+
- `ci`: For certain CI workloads.
23+
- `websocket`: For Superset clusters supporting advanced features.
24+
- `dockerize`: Used by Helm.
25+
- **Platform:** We build for `linux/arm64` and `linux/amd64`. The `-arm` suffix
26+
indicates ARM builds (e.g., `latest-arm`), while tags without a suffix are for
27+
AMD (e.g., `latest`).
28+
29+
## Key Image Tags and Examples
30+
31+
- `latest`: The latest official release build, implicitly the lean build on
32+
`linux/amd64`.
33+
- `latest-dev`: the `-dev` image of the latest official release build, with a headless browser and root access.
34+
- `master`: The latest build from the `master` branch, implicitly lean on
35+
`linux/amd64`.
36+
- `master-dev`: Similar to `master` but includes a headless browser and root access.
37+
- `pr-5252`: The latest commit in PR 5252.
38+
- `30948dc401b40982cb7c0dbf6ebbe443b2748c1b-dev-arm`: A `linux/arm64` build for
39+
this specific SHA, which could be from a pull request, master merge, or release.
40+
- `30948dc-dev-arm`: Same as above, but SHA truncated to 7 characters for a
41+
shorter handle on the same image
42+
- `websocket-latest`: The WebSocket image for use in a Superset cluster.
43+
44+
For insights or modifications to the build matrix and tagging conventions,
45+
check the [build_docker.py](https://github.com/apache/superset/blob/master/scripts/build_docker.py)
46+
script and the [docker.yml](https://github.com/apache/superset/blob/master/.github/workflows/docker.yml)
47+
GitHub action.
48+
49+
## Caching
50+
51+
To accelerate builds, we follow Docker best practices and use `apache/superset-cache`.
52+
53+
## On ARM builds and working with Apple silicon
54+
55+
Apple's current generation of computers uses ARM-based CPUs, and Docker
56+
running on MACs seem to require `linux/arm64/v8` (at least one user's M2 was
57+
configured in that way). Setting the environment
58+
variable `DOCKER_DEFAULT_PLATFORM` to `linux/amd64` seems to function in
59+
term of leveraging, and building upon the Superset builds provided here.
60+
61+
```
62+
export DOCKER_DEFAULT_PLATFORM=linux/amd64
63+
```
64+
65+
Presumably, `linux/arm64/v8` would be more optimized for this generation
66+
of chips, but less compatible across the ARM ecosystem.

helm/superset/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ maintainers:
2929
- name: craig-rueda
3030
email: craig@craigrueda.com
3131
url: https://github.com/craig-rueda
32-
version: 0.12.1
32+
version: 0.12.2
3333
dependencies:
3434
- name: postgresql
3535
version: 12.1.6

helm/superset/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ NOTE: This file is generated by helm-docs: https://github.com/norwoodj/helm-docs
2323

2424
# superset
2525

26-
![Version: 0.12.1](https://img.shields.io/badge/Version-0.12.1-informational?style=flat-square)
26+
![Version: 0.12.2](https://img.shields.io/badge/Version-0.12.2-informational?style=flat-square)
2727

2828
Apache Superset is a modern, enterprise-ready business intelligence web application
2929

@@ -77,7 +77,7 @@ On helm this can be set on `extraSecretEnv.SUPERSET_SECRET_KEY` or `configOverri
7777
| hostAliases | list | `[]` | Custom hostAliases for all superset pods # https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ |
7878
| image.pullPolicy | string | `"IfNotPresent"` | |
7979
| image.repository | string | `"apachesuperset.docker.scarf.sh/apache/superset"` | |
80-
| image.tag | string | `""` | |
80+
| image.tag | string | `"latest"` | |
8181
| imagePullSecrets | list | `[]` | |
8282
| ingress.annotations | object | `{}` | |
8383
| ingress.enabled | bool | `false` | |

helm/superset/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ extraConfigMountPath: "/app/configs"
179179

180180
image:
181181
repository: apachesuperset.docker.scarf.sh/apache/superset
182-
tag: ""
182+
tag: "latest"
183183
pullPolicy: IfNotPresent
184184

185185
imagePullSecrets: []

scripts/build_docker.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def get_docker_tags(
8383
sha: str,
8484
build_context: str,
8585
build_context_ref: str,
86+
force_latest: bool = False,
8687
) -> set[str]:
8788
"""
8889
Return a set of tags given a given build context
@@ -110,11 +111,13 @@ def get_docker_tags(
110111
if build_context == "release":
111112
# add a release tag
112113
tags.add(make_docker_tag([build_context_ref] + tag_chunks))
113-
if is_latest:
114+
if is_latest or force_latest:
114115
# add a latest tag
115116
tags.add(make_docker_tag(["latest"] + tag_chunks))
116117
elif build_context == "push" and build_context_ref == "master":
117118
tags.add(make_docker_tag(["master"] + tag_chunks))
119+
elif build_context == "pull_request":
120+
tags.add(make_docker_tag([f"pr-{build_context_ref}"] + tag_chunks))
118121
return tags
119122

120123

@@ -125,6 +128,7 @@ def get_docker_command(
125128
sha: str,
126129
build_context: str,
127130
build_context_ref: str,
131+
force_latest: bool = False,
128132
) -> str:
129133
tag = ""
130134
build_target = ""
@@ -160,6 +164,7 @@ def get_docker_command(
160164
sha,
161165
build_context,
162166
build_context_ref,
167+
force_latest,
163168
)
164169
docker_tags = ("\\\n" + 8 * " ").join([f"-t {s} " for s in tags])
165170

@@ -205,12 +210,16 @@ def get_docker_command(
205210
)
206211
@click.option("--build_context_ref", help="a reference to the pr, release or branch")
207212
@click.option("--dry-run", is_flag=True, help="Run the command in dry-run mode.")
213+
@click.option(
214+
"--force-latest", is_flag=True, help="Force the 'latest' tag on the release"
215+
)
208216
def main(
209217
build_preset: str,
210218
build_context: str,
211219
build_context_ref: str,
212220
platform: str,
213221
dry_run: bool,
222+
force_latest: bool,
214223
) -> None:
215224
"""
216225
This script executes docker build and push commands based on given arguments.
@@ -219,15 +228,25 @@ def main(
219228
is_authenticated = (
220229
True if os.getenv("DOCKERHUB_TOKEN") and os.getenv("DOCKERHUB_USER") else False
221230
)
222-
build_context_ref = get_build_context_ref(build_context)
231+
232+
if force_latest and build_context != "release":
233+
print(
234+
"--force-latest can only be applied if the build context is set to 'release'"
235+
)
236+
exit(1)
237+
238+
if build_context == "release" and not build_context_ref.strip():
239+
print("Release number has to be provided")
240+
exit(1)
223241

224242
docker_build_command = get_docker_command(
225243
build_preset,
226244
platform,
227245
is_authenticated,
228246
get_git_sha(),
229247
build_context,
230-
get_build_context_ref(build_context),
248+
build_context_ref,
249+
force_latest,
231250
)
232251

233252
if not dry_run:

0 commit comments

Comments
 (0)