How to rebuild assets on top of superset image? #31640
Replies: 3 comments 3 replies
-
Hey @coneybeare! I'm here to help you with any bugs, questions, or contributions you have in mind. Let's tackle this together! To rebuild assets on top of a Superset Docker image without forking and customizing the base image, you can use a multi-stage build approach. This allows you to modify the assets while ensuring the raw assets are available for the build process. Here's a general approach:
Here's a simplified example of how you might modify the Dockerfile to achieve this: # Use the existing superset-node stage to build custom assets
FROM --platform=${BUILDPLATFORM} node:20-bullseye-slim AS custom-assets
# Copy the necessary scripts and configurations
COPY docker/ /app/docker/
# Install system dependencies required for node-gyp
RUN /app/docker/apt-install.sh build-essential python3 zstd
# Set working directory
WORKDIR /app/superset-frontend
# Bind mount your custom assets
RUN --mount=type=bind,source=./path/to/your/custom/assets,target=/app/superset-frontend/assets \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.npm \
npm ci
# Rebuild the assets
RUN npm run build
# Continue with the rest of the Dockerfile stages
FROM python-common AS final
# Copy the newly built assets from the custom-assets stage
COPY --from=custom-assets /app/superset/static/assets superset/static/assets
# Continue with the rest of the setup This approach allows you to inject custom assets into the build process without altering the base image directly. You can replace To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
@dosu how is that any different than my original approach? Which fails because the original assets are not found? |
Beta Was this translation helpful? Give feedback.
-
Dosu didn't really help here, maybe a human has done this before? |
Beta Was this translation helpful? Give feedback.
-
I am looking to simply replace some assets (images) in the release build, but I am looking to extend the base docker image, rather than fork and customize so that I don't have to continually update the build to get the latest improvements. Starting with a custom
Dockerfile
, I would have expected this to work, but it does not:The
build
step fails because of course, the raw assets are no longer in the/app/superset-frontend
folder.My approach before this was to copy files into
/superset/static/assets/images
and then a versioned one into/superset/static/assets
at runtime, but that is fragile as the compiled version filenames will change.Before attempting to solve this and figure out if I can move the raw assets back to re
build
, I thought I would ask the community here, as it feels I am swimming upstream for a relatively simple use case. How would you solve this?Beta Was this translation helpful? Give feedback.
All reactions