Skip to content

Swapped npm to bun for faster installation#15

Merged
moddroid94 merged 11 commits into
moddroid94:devfrom
beecho01:dev
Dec 23, 2025
Merged

Swapped npm to bun for faster installation#15
moddroid94 merged 11 commits into
moddroid94:devfrom
beecho01:dev

Conversation

@beecho01
Copy link
Copy Markdown
Contributor

Various edits to help with installation speed and changes for mobile device screens:

  • Swapped npm to bun for faster installation

  • Moved from h-screen to h-dvh to remove overflow issues on mobile devices

  • Added x-axis padding consistency to sidebar elements

  • Migrated backend to use uv rather than pip for faster setup speed

  • Added pycache to gitignore

  • Made changes to make sure that file.filename is a string before passing it to os.path.splitext

@moddroid94
Copy link
Copy Markdown
Owner

Hi mate,

Thanks for the contribution!

I appreciate that you made a PR into the dev branch, and all the changes looks good to me, i really like more the bun/uv/poetry combo, and i would have made the same at some point, so again thanks.

There's only 2 point i would like to highlight and that i would like to resolve before merge:

1 - while the switch to poetry is cool, there's a deps "esbuild 0.25.1" which contains a couple of CVE, they may not be dangerous in the context we use it, i'm not sure tbh, so i prefer not to have it.
What i did was to change the package-lock manually to point to v0.27.1, could that be changed on the poetry lock too?
or do you know for sure if that the vuln is not dangerous for our use?

2- i saw you left a couple of data.db files into the backend folder, if you could please remove them that would be great.

once this 2 point are ok i can merge.

PS: i saw the other work you're doing, and that's some QOL for sure, so if you want to integrate that too with another PR or adding them to this with the aforementioned issue, do as you wish.

PPS: i may be away for a while during holidays, but if you find the time to fix the PR i will find the time to merge it :)

…tignore excludes backend data, uploads, and cache folders. General project hygiene and QOL improvements
@beecho01
Copy link
Copy Markdown
Contributor Author

I think I've made the suggested changes. Hope this helps.
I've bumped a few dependencies to their latest to hopefully capture any security issues.

Merry Christmas and Happy New Year! 🎅🎆

@moddroid94
Copy link
Copy Markdown
Owner

I think I've made the suggested changes. Hope this helps. I've bumped a few dependencies to their latest to hopefully capture any security issues.

Merry Christmas and Happy New Year! 🎅🎆

Hi man, That's some great improvements, thank you!

you almost did everything correct ahahah you now pushed an .stl file and some .pyc files, but that's nothing and the rest seems perfectly fine.
Great for the deps bump, and again thanks for the contribution, those are some simple but sweet changes, they definitely helps!

I'll clean up this tomorrow morning and merge everything for a new release!

Wish you some good holidays, have a good Christmas and happy new year! 😁

@moddroid94 moddroid94 merged commit 8bb4568 into moddroid94:dev Dec 23, 2025
@moddroid94
Copy link
Copy Markdown
Owner

Thanks for the improvements!
i'll try installing the new version on my test docker and if everything is fine i'm merging into master for the release

Have nice holidays!

@beecho01 beecho01 deleted the dev branch December 23, 2025 20:52
@moddroid94
Copy link
Copy Markdown
Owner

hi @beecho01 ,
I'm not able to install with bun on my docker, i get error 132 every time, i linked an error on the bun repo that seems the cause, it is in the commits, i tried a couple of options but it is not working.
unfortunately i'm not able to debug this too much right now, i'll try to check better after the holidays.

have a good new year eve mate. cheers.

@beecho01
Copy link
Copy Markdown
Contributor Author

beecho01 commented Jan 6, 2026

Hi mate,

Hope you had a good holidays.

The bun image comes in multiple os options. I chose the alpine option due to the size. After a quick Google search, the AI mode suggests that its a cpu architecture issue. Trying another os base might work better.

Here are the others if you'd like me to attempt to replicate or chose another option: https://share.google/1FkDRO3QyV2siSf4k

Thanks
James

@moddroid94
Copy link
Copy Markdown
Owner

moddroid94 commented Jan 6, 2026 via email

@moddroid94
Copy link
Copy Markdown
Owner

Hi mate,

Hope you had a good holidays.

The bun image comes in multiple os options. I chose the alpine option due to the size. After a quick Google search, the AI mode suggests that its a cpu architecture issue. Trying another os base might work better.

Here are the others if you'd like me to attempt to replicate or chose another option: https://share.google/1FkDRO3QyV2siSf4k

Thanks James

Hey Man, I've rediscovered why it won't work, unfortunately my homelab is old af, the CPU does not have SSE4.2, which is a baseline dependency for Bun, that's why it won't work on my setup.

I was thinking about a script to detect if the cpu supports the instruction and then choose which package manager to choose, but it may not be that good of a solution.

@beecho01
Copy link
Copy Markdown
Contributor Author

Its not a bad idea, let me have a play, see what I can come up with.

@beecho01
Copy link
Copy Markdown
Contributor Author

What about something like this? Haven't tested it but can if you want me to.

FROM node:22-alpine AS build
WORKDIR /app

# Tools to fetch bun
RUN apk add --no-cache curl ca-certificates

# Download bun (but do not run)
RUN curl -fsSL https://bun.sh/install | bash \
  && ln -s /root/.bun/bin/bun /usr/local/bin/bun

# Vite build-time args
ARG VITE_APP_API
ENV VITE_APP_API=$VITE_APP_API
ARG VITE_APP_TAG
ENV VITE_APP_TAG=$VITE_APP_TAG

# Copy manifests
COPY package.json .

# Install
RUN if grep -qiw sse4_2 /proc/cpuinfo; then \
      echo "SSE4.2 detected -> using bun"; \
      bun install --frozen-lockfile; \
    else \
      echo "No SSE4.2 -> using npm"; \
      npm ci; \
    fi

COPY . .

# Build
RUN if grep -qiw sse4_2 /proc/cpuinfo; then \
      bun run build; \
    else \
      npm run build; \
    fi

EXPOSE 5173

# Run
RUN if grep -qiw sse4_2 /proc/cpuinfo; then \
      bun run preview; \
    else \
      npm run preview; \
    fi

@moddroid94
Copy link
Copy Markdown
Owner

@beecho01 Yeah, exactly something like that ahahaha thanks mate!
I'm gonna test it on mine so i can check if it works correctly on old HW, if you can confirm it works for you i'll merge it!

building bun on the node:alpine image isn't a problem?
I saw you changed it before on the PR, but idk what's the difference from the node one.

cheers :)

@beecho01
Copy link
Copy Markdown
Contributor Author

beecho01 commented Jan 11, 2026

I thought about it a bit more and did a little research and I realised I did make one little mistake by not closing with a CMD and missing a pre-requisite for Bun.

Also, it seems you cannot use grep to switch base images dynamically within a single Dockerfile, so my initial thinking to install bun alongside node within the node-alpine image should allow for either to run based on the CPU architecture, which should hopefully provide best of both worlds.

FROM node:22-alpine AS build
WORKDIR /app

# Install prerequisites for the Bun
RUN apk add --no-cache curl ca-certificates unzip bash

# Download and install Bun
RUN curl -fsSL https://bun.sh/install | bash \
    && ln -s /root/.bun/bin/bun /usr/local/bin/bun

# Vite build-time args
ARG VITE_APP_API
ENV VITE_APP_API=$VITE_APP_API
ARG VITE_APP_TAG
ENV VITE_APP_TAG=$VITE_APP_TAG

COPY package.json .

# Conditional Install
RUN if grep -qiw sse4_2 /proc/cpuinfo; then \
      echo "SSE4.2 detected -> using bun"; \
      bun install --frozen-lockfile; \
    else \
      echo "No SSE4.2 -> using npm"; \
      npm ci; \
    fi

COPY . .

# Conditional Build
RUN if grep -qiw sse4_2 /proc/cpuinfo; then \
      bun run build; \
    else \
      npm run build; \
    fi

EXPOSE 5173

# Run
CMD ["sh", "-c", "if grep -qiw sse4_2 /proc/cpuinfo; then bun run preview; else npm run preview; fi"]

I'm just pulling the latest prod image, and I will edit the frontend/Dockerfile before running, see what happens and report back!

@beecho01
Copy link
Copy Markdown
Contributor Author

beecho01 commented Jan 11, 2026

It appears to work for me, see the logs below:

#1 [internal] load local bake definitions
#1 reading from stdin 1.11kB done
#1 DONE 0.0s

#2 [frontend internal] load build definition from Dockerfile
#2 transferring dockerfile: 967B done
#2 DONE 0.0s

#3 [backend internal] load build definition from Dockerfile
#3 transferring dockerfile: 279B done
#3 DONE 0.0s

#4 [backend internal] load metadata for docker.io/library/python:3.9-slim
#4 ...

#5 [frontend internal] load metadata for docker.io/library/node:22-alpine
#5 DONE 0.2s

#4 [backend internal] load metadata for docker.io/library/python:3.9-slim
#4 DONE 0.2s

#6 [frontend internal] load .dockerignore
#6 transferring context: 2B done
#6 DONE 0.0s

#7 [backend internal] load .dockerignore
#7 transferring context: 2B done
#7 DONE 0.0s

#8 [frontend 1/8] FROM docker.io/library/node:22-alpine@sha256:0340fa682d72068edf603c305bfbc10e23219fb0e40df58d9ea4d6f33a9798bf
#8 DONE 0.0s

#9 [frontend 2/8] WORKDIR /app
#9 CACHED

#10 [backend 1/5] FROM docker.io/library/python:3.9-slim@sha256:2d97f6910b16bd338d3060f261f53f144965f755599aab1acda1e13cf1731b1b
#10 DONE 0.0s

#11 [backend 2/5] WORKDIR /app
#11 CACHED

#12 [frontend internal] load build context
#12 transferring context: 1.22kB done
#12 DONE 0.0s

#13 [backend internal] load build context
#13 transferring context: 305B done
#13 DONE 0.0s

#14 [backend 3/5] COPY requirements.txt .
#14 DONE 0.0s

#15 [backend 4/5] RUN pip install --no-cache-dir uv &&     uv pip install --system -r requirements.txt
#15 ...

#16 [frontend 3/8] RUN apk add --no-cache curl ca-certificates unzip bash
#16 0.921 ( 1/16) Installing ncurses-terminfo-base (6.5_p20251123-r0)
#16 0.941 ( 2/16) Installing libncursesw (6.5_p20251123-r0)
#16 0.965 ( 3/16) Installing readline (8.3.1-r0)
#16 0.986 ( 4/16) Installing bash (5.3.3-r1)
#16 1.034   Executing bash-5.3.3-r1.post-install
#16 1.040 ( 5/16) Installing ca-certificates (20251003-r0)
#16 1.084 ( 6/16) Installing brotli-libs (1.2.0-r0)
#16 1.125 ( 7/16) Installing c-ares (1.34.6-r0)
#16 1.145 ( 8/16) Installing libunistring (1.4.1-r0)
#16 1.193 ( 9/16) Installing libidn2 (2.3.8-r0)
#16 1.212 (10/16) Installing nghttp2-libs (1.68.0-r0)
#16 1.230 (11/16) Installing nghttp3 (1.13.1-r0)
#16 1.247 (12/16) Installing libpsl (0.21.5-r3)
#16 1.264 (13/16) Installing zstd-libs (1.5.7-r2)
#16 1.299 (14/16) Installing libcurl (8.17.0-r1)
#16 1.332 (15/16) Installing curl (8.17.0-r1)
#16 1.359 (16/16) Installing unzip (6.0-r16)
#16 1.380 Executing busybox-1.37.0-r30.trigger
#16 1.389 Executing ca-certificates-20251003-r0.trigger
#16 1.444 OK: 18.5 MiB in 34 packages
#16 DONE 1.5s

#17 [frontend 4/8] RUN curl -fsSL https://bun.sh/install | bash     && ln -s /root/.bun/bin/bun /usr/local/bin/bun
######################################################################## 100.0%
#17 3.512 bun was installed successfully to ~/.bun/bin/bun 
#17 3.513 
#17 3.517 Manually add the directory to ~/.bashrc (or similar):
#17 3.517   export BUN_INSTALL="$HOME/.bun"
#17 3.517   export PATH="$BUN_INSTALL/bin:$PATH"
#17 3.517
#17 3.517 To get started, run:
#17 3.517
#17 3.517   bun --help
#17 DONE 3.6s

#15 [backend 4/5] RUN pip install --no-cache-dir uv &&     uv pip install --system -r requirements.txt
#15 3.475 Collecting uv
#15 3.727   Downloading uv-0.9.24-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.3 MB)
#15 4.755      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 22.3/22.3 MB 28.1 MB/s eta 0:00:00
#15 4.832 Installing collected packages: uv
#15 ...

#18 [frontend 5/8] COPY package.json .
#18 DONE 0.0s

#15 [backend 4/5] RUN pip install --no-cache-dir uv &&     uv pip install --system -r requirements.txt
#15 5.181 Successfully installed uv-0.9.24
#15 5.182 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#15 5.316
#15 5.316 [notice] A new release of pip is available: 23.0.1 -> 25.3
#15 5.316 [notice] To update, run: pip install --upgrade pip
#15 5.543 Using Python 3.9.25 environment at: /usr/local
#15 8.847 Resolved 25 packages in 3.30s
#15 8.959 Downloading uvloop (3.5MiB)
#15 8.960 Downloading pydantic-core (2.0MiB)
#15 9.211  Downloaded pydantic-core
#15 9.295  Downloaded uvloop
#15 9.296 Prepared 25 packages in 447ms
#15 9.313 Installed 25 packages in 16ms
#15 9.313  + aiofiles==25.1.0
#15 9.314  + annotated-types==0.7.0
#15 9.314  + anyio==4.12.1
#15 9.314  + certifi==2026.1.4
#15 9.314  + charset-normalizer==3.4.4
#15 9.314  + click==8.1.8
#15 9.314  + exceptiongroup==1.3.1
#15 9.314  + fastapi==0.115.2
#15 9.314  + h11==0.16.0
#15 9.314  + httptools==0.7.1
#15 9.314  + idna==3.11
#15 9.314  + pydantic==2.12.5
#15 9.314  + pydantic-core==2.41.5
#15 9.314  + python-dotenv==1.2.1
#15 9.314  + python-multipart==0.0.20
#15 9.314  + pyyaml==6.0.3
#15 9.314  + requests==2.32.5
#15 9.314  + starlette==0.38.5
#15 9.314  + typing-extensions==4.15.0
#15 9.314  + typing-inspection==0.4.2
#15 9.314  + urllib3==2.6.3
#15 9.314  + uvicorn==0.39.0
#15 9.314  + uvloop==0.22.1
#15 9.314  + watchfiles==1.1.1
#15 9.314  + websockets==15.0.1
#15 DONE 9.8s

#19 [frontend 6/8] RUN if grep -qiw sse4_2 /proc/cpuinfo; then       echo "SSE4.2 detected -> using bun";       bun install --frozen-lockfile;     else       echo "No SSE4.2 -> using npm";       npm ci;     fi
#19 0.328 SSE4.2 detected -> using bun
#19 0.332 bun install v1.3.5 (1e86cebd)
#19 0.335 Resolving dependencies
#19 3.926 Resolved, downloaded and extracted [672]
#19 4.458
#19 4.458 + @types/node@22.19.5 (v25.0.6 available)
#19 4.458 + @types/react@19.2.8
#19 4.458 + @vitejs/plugin-react@5.1.2
#19 4.458 + typescript@5.8.3 (v5.9.3 available)
#19 4.458 + vite@6.4.1 (v7.3.1 available)
#19 4.458 + @react-three/drei@10.7.7
#19 4.458 + @react-three/fiber@9.5.0
#19 4.458 + jszip@3.10.1
#19 4.458 + lucide-react@0.554.0 (v0.562.0 available)
#19 4.458 + react@19.2.3
#19 4.458 + react-dom@19.2.3
#19 4.458 + three@0.181.2 (v0.182.0 available)
#19 4.458 + uuid@13.0.0
#19 4.458
#19 4.458 145 packages installed [4.13s]
#19 DONE 4.6s

#20 [backend 5/5] COPY . .
#20 DONE 0.0s

#21 [frontend 7/8] COPY . .
#21 DONE 0.1s

#22 [backend] exporting to image
#22 exporting layers
#22 exporting layers 1.0s done
#22 writing image sha256:f074d668ed242a0f1fc45b8a66f0626cc13610d2495197fec4f3065bfb999863 done
#22 naming to docker.io/library/stlvault-backend done
#22 DONE 1.0s

#23 [backend] resolving provenance for metadata file
#23 DONE 0.0s

#24 [frontend 8/8] RUN if grep -qiw sse4_2 /proc/cpuinfo; then       bun run build;     else       npm run build;     fi
#24 0.327 $ vite build
#24 0.629 vite v6.4.1 building for production...
#24 0.718 transforming...
#24 8.691 ✓ 2259 modules transformed.
#24 9.377 rendering chunks...
#24 9.397 computing gzip size...
#24 9.436 dist/assets/site-BwHFeIBa.webmanifest          0.26 kB
#24 9.436 dist/assets/favicon-16x16-C72o72Ze.png         0.62 kB
#24 9.436 dist/assets/favicon-32x32-DkSlSEI5.png         1.55 kB
#24 9.436 dist/index.html                                1.94 kB │ gzip:   0.77 kB
#24 9.437 dist/assets/apple-touch-icon-Ct_eiYbW.png     19.70 kB
#24 9.437 dist/assets/index-DFrUuZCl.js              1,385.76 kB │ gzip: 395.07 kB
#24 9.437
#24 9.437 (!) Some chunks are larger than 500 kB after minification. Consider:
#24 9.437 - Using dynamic import() to code-split the application
#24 9.437 - Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
#24 9.437 - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
#24 9.437 ✓ built in 8.77s
#24 DONE 9.7s

#25 [frontend] exporting to image
#25 exporting layers
#25 exporting layers 4.5s done
#25 writing image sha256:48ef2079149c4778ac493d2305142bfb868daf22072add3555d0cb98c904c876 done
#25 naming to docker.io/library/stlvault-frontend done
#25 DONE 4.5s

#26 [frontend] resolving provenance for metadata file
#26 DONE 0.0s
 stlvault-backend  Built
 stlvault-frontend  Built

@moddroid94
Copy link
Copy Markdown
Owner

Hi man, i think this is somewhat close to what we need, i still got the error as the installation of bun fails on my system, so the whole image won't build.
If i understand correctly the way docker build works, we should implement a multi-file or multi-stage build, or use different dockerfiles altogether and point to the right one depending on an ENV variables, which is probably easier.

the multi stage is fun and cool, but is more complex to make, the entrypoint is the simplest but requires to have 2 different docker files, one for CPU set

basically from the docker-compose in the root we set the frontend dockerfile based on an ENV, given a sensible default, that way we even allow to choose manually for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants