diff --git a/Dockerfile b/Dockerfile index ab412446544..097274e9da0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,14 @@ FROM --platform=${BUILDPLATFORM} node:20-bullseye-slim AS superset-node ARG NPM_BUILD_CMD="build" +# Used by docker-compose to skip the frontend build, +# in dev we mount the repo and build the frontend inside docker +ARG DEV_MODE="false" + +# Include headless browsers? Allows for alerts, reports & thumbnails, but bloats the images +ARG INCLUDE_CHROMIUM="true" +ARG INCLUDE_FIREFOX="false" + # Somehow we need python3 + build-essential on this side of the house to install node-gyp RUN apt-get update -qq \ && apt-get install \ @@ -42,19 +50,33 @@ RUN --mount=type=bind,target=/frontend-mem-nag.sh,src=./docker/frontend-mem-nag. /frontend-mem-nag.sh WORKDIR /app/superset-frontend +# Creating empty folders to avoid errors when running COPY later on +RUN mkdir -p /app/superset/static/assets && mkdir -p /app/superset/translations RUN --mount=type=bind,target=./package.json,src=./superset-frontend/package.json \ --mount=type=bind,target=./package-lock.json,src=./superset-frontend/package-lock.json \ - npm ci + if [ "$DEV_MODE" = "false" ]; then \ + npm ci; \ + else \ + echo "Skipping 'npm ci' in dev mode"; \ + fi # Runs the webpack build process COPY superset-frontend /app/superset-frontend -RUN npm run ${BUILD_CMD} +RUN if [ "$DEV_MODE" = "false" ]; then \ + npm run ${BUILD_CMD}; \ + else \ + echo "Skipping 'npm run ${BUILD_CMD}' in dev mode"; \ + fi # This copies the .po files needed for translation RUN mkdir -p /app/superset/translations COPY superset/translations /app/superset/translations # Compiles .json files from the .po files, then deletes the .po files -RUN npm run build-translation +RUN if [ "$DEV_MODE" = "false" ]; then \ + npm run build-translation; \ + else \ + echo "Skipping translations in dev mode"; \ + fi RUN rm /app/superset/translations/*/LC_MESSAGES/*.po RUN rm /app/superset/translations/messages.pot @@ -146,21 +168,27 @@ RUN apt-get update -qq \ RUN --mount=type=cache,target=/root/.cache/pip \ pip install playwright RUN playwright install-deps -RUN playwright install chromium + +RUN if [ "$INCLUDE_CHROMIUM" = "true" ]; then \ + playwright install chromium; \ + else \ + echo "Skipping translations in dev mode"; \ + fi # Install GeckoDriver WebDriver ARG GECKODRIVER_VERSION=v0.34.0 \ FIREFOX_VERSION=125.0.3 -RUN apt-get update -qq \ - && apt-get install -yqq --no-install-recommends wget bzip2 \ - && wget -q https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O - | tar xfz - -C /usr/local/bin \ - # Install Firefox - && wget -q https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2 -O - | tar xfj - -C /opt \ - && ln -s /opt/firefox/firefox /usr/local/bin/firefox \ - && apt-get autoremove -yqq --purge wget bzip2 && rm -rf /var/[log,tmp]/* /tmp/* /var/lib/apt/lists/* -# Cache everything for dev purposes... +RUN if [ "$INCLUDE_FIREFOX" = "true" ]; then \ + apt-get update -qq \ + && apt-get install -yqq --no-install-recommends wget bzip2 \ + && wget -q https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O - | tar xfz - -C /usr/local/bin \ + && wget -q https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2 -O - | tar xfj - -C /opt \ + && ln -s /opt/firefox/firefox /usr/local/bin/firefox \ + && apt-get autoremove -yqq --purge wget bzip2 && rm -rf /var/[log,tmp]/* /tmp/* /var/lib/apt/lists/*; \ + fi +# Cache everything for dev purposes... COPY --chown=superset:superset requirements/development.txt requirements/ RUN --mount=type=cache,target=/root/.cache/pip \ apt-get update -qq && apt-get install -yqq --no-install-recommends \ diff --git a/RESOURCES/INTHEWILD.md b/RESOURCES/INTHEWILD.md index 46599890f45..f882b080870 100644 --- a/RESOURCES/INTHEWILD.md +++ b/RESOURCES/INTHEWILD.md @@ -112,7 +112,7 @@ Join our growing community! - [Showmax](https://showmax.com) [@bobek] - [TechAudit](https://www.techaudit.info) [@ETselikov] - [Tenable](https://www.tenable.com) [@dflionis] -- [Tentacle](https://tentaclecmi.com) [@jdclarke5] +- [Tentacle](https://www.linkedin.com/company/tentacle-cmi/) [@jdclarke5] - [timbr.ai](https://timbr.ai/) [@semantiDan] - [Tobii](http://www.tobii.com/) [@dwa] - [Tooploox](https://www.tooploox.com/) [@jakubczaplicki] diff --git a/UPDATING.md b/UPDATING.md index c5f2ac98977..1d22d2be17d 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -59,6 +59,7 @@ assists people when migrating to a new version. as part of your bundling to expose translation packages, it's probably not needed anymore. - [29264](https://github.com/apache/superset/pull/29264) Slack has updated its file upload api, and we are now supporting this new api in Superset, although the Slack api is not backward compatible. The original Slack integration is deprecated and we will require a new Slack scope `channels:read` to be added to Slack workspaces in order to use this new api. In an upcoming release, we will make this new Slack scope mandatory and remove the old Slack functionality. - [29798](https://github.com/apache/superset/pull/29798) Since 3.1.0, the intial schedule for an alert or report was mistakenly offset by the specified timezone's relation to UTC. The initial schedule should now begin at the correct time. +- [30021](https://github.com/apache/superset/pull/30021) The `dev` layer in our Dockerfile no long includes firefox binaries, only Chromium to reduce bloat/docker-build-time ### Potential Downtime diff --git a/docker-compose.yml b/docker-compose.yml index c588ea135d2..fcb3503a1bc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,6 +38,8 @@ x-common-build: &common-build target: dev cache_from: - apache/superset-cache:3.10-slim-bookworm + args: + DEV_MODE: "true" services: nginx: diff --git a/docs/docs/installation/docker-builds.mdx b/docs/docs/installation/docker-builds.mdx index 9a5d38d1d12..02412bd990b 100644 --- a/docs/docs/installation/docker-builds.mdx +++ b/docs/docs/installation/docker-builds.mdx @@ -52,11 +52,25 @@ without a build_preset are lean builds, e.g., `latest`. this specific SHA, which could be from a `master` merge, or release. - `websocket-latest`: The WebSocket image for use in a Superset cluster. + + For insights or modifications to the build matrix and tagging conventions, check the [build_docker.py](https://github.com/apache/superset/blob/master/scripts/build_docker.py) script and the [docker.yml](https://github.com/apache/superset/blob/master/.github/workflows/docker.yml) GitHub action. +## Key ARGs in Dockerfile +- `DEV_MODE`: whether to skip the frontend build, this is used by our `docker-compose` dev setup + where we mount the local volume and build using `webpack` in `--watch` mode, meaning as you + alter the code in the local file system, webpack, from within a docker image used for this + purpose, will constantly rebuild the frontend as you go. This ARG enables the initial + `docker-compose` build to take much less time and resources +- `INCLUDE_CHROMIUM`: whether to include chromium in the backend build so that it can be + used as a headless browser for workloads related to "Alerts & Reports" and thumbnail generation +- `INCLUDE_FIREFOX`: same as above, but for firefox +- `PY_VER`: specifying the base image for the python backend, we don't recommend altering + this setting if you're not working on forwards or backwards compatibility + ## Caching To accelerate builds, we follow Docker best practices and use `apache/superset-cache`.