Skip to content

Commit

Permalink
chore: accelerate docker compose by skipping frontend build
Browse files Browse the repository at this point in the history
while waiting for a `docker-compose build`, I decided to go and skip the long steps around the frontend buildsthat are not required while in dev mode while using  `docker-compose` where we mount the local repo and build it inside docker.
  • Loading branch information
mistercrunch committed Aug 27, 2024
1 parent fcf0450 commit d7bf2df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ FROM --platform=${BUILDPLATFORM} node:20-bullseye-slim AS superset-node

ARG NPM_BUILD_CMD="build"

ARG DEV_MODE=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 \
Expand All @@ -41,19 +43,32 @@ RUN --mount=type=bind,target=/frontend-mem-nag.sh,src=./docker/frontend-mem-nag.
/frontend-mem-nag.sh

WORKDIR /app/superset-frontend
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

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d7bf2df

Please sign in to comment.