mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 00:08:25 +00:00
chore (docker): remove node_modules from production images (#4703)
* remove useless node_modules from prod image * update ci * Fix web-frontend test in ci
This commit is contained in:
1 parent
3050bd1c69
commit
0d4c43de13
6 files changed
+23
-73
No files matched your search
@@ -1,3 +1,4 @@
|
||||
**/.output
|
||||
**/.nuxt
|
||||
**/.nuxt-storybook
|
||||
**/.storybook
|
||||
|
||||
+10
-32
@@ -1360,27 +1360,17 @@ jobs:
|
||||
git clone -b develop https://oauth2:${GITLAB_SAAS_PAT}@gitlab.com/baserow/baserow-saas.git saas
|
||||
cd saas
|
||||
|
||||
- name: Update image version files
|
||||
- name: Update baserow submodule to current commit
|
||||
working-directory: saas
|
||||
run: |
|
||||
echo "🧩 Generating updated image references..."
|
||||
|
||||
BACKEND_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/backend:ci-tested-${{ env.REAL_GITHUB_SHA }}"
|
||||
BACKEND_DEV_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/backend_dev:ci-${{ env.REAL_GITHUB_SHA }}"
|
||||
WEB_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/web-frontend:ci-tested-${{ env.REAL_GITHUB_SHA }}"
|
||||
WEB_DEV_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/web-frontend_dev:ci-${{ env.REAL_GITHUB_SHA }}"
|
||||
ALL_IN_ONE_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/baserow:ci-tested-${{ env.REAL_GITHUB_SHA }}"
|
||||
|
||||
echo "$BACKEND_IMAGE" > plugins/saas/backend/build_from_image.version
|
||||
echo "$BACKEND_DEV_IMAGE" > plugins/saas/backend/build_from_dev_image.version
|
||||
echo "$WEB_IMAGE" > plugins/saas/web-frontend/build_from_image.version
|
||||
echo "$WEB_DEV_IMAGE" > plugins/saas/web-frontend/build_from_dev_image.version
|
||||
echo "$ALL_IN_ONE_IMAGE" > all_in_one_image.version
|
||||
|
||||
echo "✅ Updated image references:"
|
||||
cat plugins/saas/backend/build_from_image.version
|
||||
cat plugins/saas/web-frontend/build_from_image.version
|
||||
cat all_in_one_image.version
|
||||
echo "🔄 Updating baserow submodule to ${{ github.sha }}..."
|
||||
git submodule update --init
|
||||
cd baserow
|
||||
git fetch origin
|
||||
git checkout ${{ github.sha }}
|
||||
cd ..
|
||||
git add baserow
|
||||
echo "✅ Submodule updated."
|
||||
|
||||
- name: Commit and push changes to GitLab
|
||||
working-directory: saas
|
||||
@@ -1390,24 +1380,12 @@ jobs:
|
||||
git config user.name "${GIT_USER_NAME}"
|
||||
git config user.email "${GIT_USER_EMAIL}"
|
||||
|
||||
git add \
|
||||
plugins/saas/backend/build_from_image.version \
|
||||
plugins/saas/backend/build_from_dev_image.version \
|
||||
plugins/saas/web-frontend/build_from_image.version \
|
||||
plugins/saas/web-frontend/build_from_dev_image.version \
|
||||
all_in_one_image.version
|
||||
|
||||
if git diff-index --quiet HEAD --; then
|
||||
echo "No changes detected — skipping commit."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
COMMIT_MSG="Automatic core image bump:
|
||||
- backend: ${BACKEND_IMAGE}
|
||||
- web-frontend: ${WEB_IMAGE}
|
||||
- all-in-one: ${ALL_IN_ONE_IMAGE}"
|
||||
|
||||
git commit -m "$COMMIT_MSG"
|
||||
git commit -m "Automatic baserow submodule bump to ${{ github.sha }}"
|
||||
git push origin develop
|
||||
|
||||
echo "✅ Successfully pushed updates to baserow-saas."
|
||||
+1
-2
@@ -244,6 +244,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
procps \
|
||||
tmux \
|
||||
vim \
|
||||
lsof \
|
||||
sudo
|
||||
|
||||
ENV DOCKER_USER=baserow_docker_user \
|
||||
@@ -303,9 +304,7 @@ RUN echo "set -g default-command \"\${SHELL}\"" > /baserow/.tmux.conf && \
|
||||
'echo " j - See available commands"' \
|
||||
> /baserow/.bashrc
|
||||
|
||||
COPY --chown=$UID:$GID LICENSE /baserow/LICENSE
|
||||
COPY --chown=$UID:$GID backend/docker/docker-entrypoint.sh /baserow/backend/docker/docker-entrypoint.sh
|
||||
|
||||
RUN dos2unix /baserow/backend/docker/docker-entrypoint.sh \
|
||||
&& chmod a+x /baserow/backend/docker/docker-entrypoint.sh
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ startsecs=30
|
||||
[program:webfrontend]
|
||||
user=%(ENV_DOCKER_USER)s
|
||||
directory=/baserow/web-frontend
|
||||
command=/baserow/supervisor/wrapper.sh YELLOW WEBFRONTEND ./docker/docker-entrypoint.sh %(ENV_BASEROW_WEB_FRONTEND_STARTUP_COMMAND)s
|
||||
command=/baserow/supervisor/wrapper.sh YELLOW WEBFRONTEND node --import ./env-remap.mjs .output/server/index.mjs
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stdout
|
||||
|
||||
+9
-37
@@ -123,7 +123,7 @@ RUN mkdir -p /baserow/reports /baserow/.cache /baserow/.yarn && \
|
||||
COPY --chown=$UID:$GID ./eslint.config.mjs /baserow/eslint.config.mjs
|
||||
COPY --chown=$UID:$GID web-frontend /baserow/web-frontend
|
||||
COPY --chown=$UID:$GID premium/web-frontend /baserow/premium/web-frontend
|
||||
COPY --chown=$UID:$GID enterprise/web-frontend /baserow/enterprise/web-frontend/
|
||||
COPY --chown=$UID:$GID enterprise/web-frontend /baserow/enterprise/web-frontend
|
||||
|
||||
COPY --chown=$UID:$GID --from=builder-ci /baserow/web-frontend/node_modules /baserow/web-frontend/node_modules
|
||||
COPY --chown=$UID:$GID --from=builder-prod /baserow/web-frontend/.nuxt /baserow/web-frontend/.nuxt
|
||||
@@ -170,6 +170,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
wget \
|
||||
tmux \
|
||||
vim \
|
||||
lsof \
|
||||
procps \
|
||||
sudo
|
||||
|
||||
ENV DOCKER_USER=baserow_docker_user \
|
||||
@@ -236,7 +238,7 @@ CMD ["nuxt-dev"]
|
||||
# =============================================================================
|
||||
# Production target - minimal image with only runtime requirements
|
||||
# =============================================================================
|
||||
FROM node:24.13-bookworm-slim AS local-base
|
||||
FROM node:24.13-bookworm-slim AS local
|
||||
ARG UID
|
||||
ARG GID
|
||||
|
||||
@@ -257,44 +259,14 @@ RUN groupadd --system --gid $GID ${DOCKER_USER} && \
|
||||
|
||||
USER $UID:$GID
|
||||
RUN mkdir -p /baserow/web-frontend
|
||||
WORKDIR /baserow/web-frontend
|
||||
|
||||
COPY --chown=$UID:$GID web-frontend/package.json /baserow/web-frontend/package.json
|
||||
COPY --chown=$UID:$GID web-frontend/yarn.lock /baserow/web-frontend/yarn.lock
|
||||
|
||||
# Install dependencies first (cached unless package.json/yarn.lock change)
|
||||
RUN --mount=type=cache,target=$YARN_CACHE_FOLDER,uid=$UID,gid=$GID,sharing=locked \
|
||||
yarn install --production --pure-lockfile --cache-folder $YARN_CACHE_FOLDER \
|
||||
# Clean up unnecessary files to reduce image size
|
||||
&& find node_modules -type f -name "*.map" -delete \
|
||||
&& find node_modules -type f \( \
|
||||
-name "*.md" -o -name "*.markdown" \
|
||||
-o -name "*.ts" -o -name "*.d.ts" \
|
||||
-o -name "LICENSE*" -o -name "license*" -o -name "License*" \
|
||||
-o -name "CHANGELOG*" -o -name "HISTORY*" \
|
||||
-o -name ".npmignore" -o -name ".gitignore" -o -name ".eslintrc*" \
|
||||
\) -delete \
|
||||
&& find node_modules -type d \( \
|
||||
-name "test" -o -name "tests" -o -name "__tests__" \
|
||||
-o -name "example" -o -name "examples" \
|
||||
-o -name "doc" -o -name "docs" \
|
||||
-o -name ".github" \
|
||||
\) -prune -exec rm -rf {} +
|
||||
|
||||
COPY --chown=$UID:$GID ./web-frontend/env-remap.mjs /baserow/web-frontend/env-remap.mjs
|
||||
COPY --chown=$UID:$GID ./web-frontend/docker/docker-entrypoint.sh /baserow/web-frontend/docker/docker-entrypoint.sh
|
||||
COPY --chown=$UID:$GID ./deploy/plugins/*.sh /baserow/plugins/
|
||||
|
||||
HEALTHCHECK --interval=60s CMD wget -q -O /dev/null http://localhost:3000/_health/ || exit 1
|
||||
ENTRYPOINT ["/usr/bin/tini", "--", "/bin/bash", "/baserow/web-frontend/docker/docker-entrypoint.sh"]
|
||||
|
||||
FROM local-base AS local
|
||||
|
||||
COPY --chown=$UID:$GID --from=builder-prod /baserow/web-frontend/.output /baserow/web-frontend/.output
|
||||
COPY --chown=$UID:$GID ./web-frontend/env-remap.mjs /baserow/web-frontend/env-remap.mjs
|
||||
|
||||
CMD ["nuxt-prod"]
|
||||
HEALTHCHECK --interval=10s CMD wget -q -O /dev/null http://localhost:3000/_health/ || exit 1
|
||||
|
||||
WORKDIR /baserow/web-frontend
|
||||
CMD ["node", "--import", "./env-remap.mjs", ".output/server/index.mjs"]
|
||||
|
||||
|
||||
FROM local AS prod
|
||||
|
||||
CMD ["nuxt-prod"]
|
||||
@@ -91,7 +91,7 @@ case "$1" in
|
||||
setup_additional_modules
|
||||
export NITRO_HOST="${BASEROW_WEBFRONTEND_BIND_ADDRESS:-0.0.0.0}"
|
||||
export NITRO_PORT="$BASEROW_WEBFRONTEND_PORT"
|
||||
exec yarn prod "${@:2}"
|
||||
exec node --import ./env-remap.mjs .output/server/index.mjs "${@:2}"
|
||||
;;
|
||||
nuxt-prepare)
|
||||
setup_additional_modules
|
||||
|
||||
Reference in new issue
Block a user