How to cache bunx folder ? #27549
-
|
I found the Dockerfile FROM oven/bun:alpine
RUN apk add --no-cache libstdc++
WORKDIR /workspace
ENV WORKSPACE_FOLDER=/workspace
EXPOSE 3000
ENTRYPOINT ["/bin/sh", "-c", "BUN_INSTALL_CACHE_DIR=$WORKSPACE_FOLDER/.bun/install/cache && bunx xxx"]And But i cannot found |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
el problema es que BUN_INSTALL_CACHE_DIR solo afecta al cache de paquetes instalados, no al de bunx que va por otro lado. para cachear bunx en docker tienes que montar el directorio ~/.bun directamente: FROM oven/bun:alpine
WORKDIR /workspace
VOLUME /root/.bun
ENTRYPOINT ["bunx", "xxx"]y luego en el docker run: con un named volume se mantiene entre ejecuciones. si estas en ci/cd la mayoria tienen soporte para cachear volumes de docker directamente. la ruta exacta del cache de bunx suele ser ~/.bun/install/cache pero el volumen entero es lo mas facil de gestionar |
Beta Was this translation helpful? Give feedback.
-
|
Your ENV is set only inside the ENTRYPOINT command: WORKDIR /workspace Pre-create so permissions are good (runs as root)RUN mkdir -p $BUN_INSTALL_CACHE_DIR EXPOSE 3000 |
Beta Was this translation helpful? Give feedback.
-
|
Two things going wrong at once — both point at how Docker layering interacts with Why your
|
Beta Was this translation helpful? Give feedback.
-
|
Maybe FROM oven/bun:alpine
RUN apk add --no-cache libstdc++
WORKDIR /workspace
ENV WORKSPACE_FOLDER=/workspace
ENV BUN_INSTALL_CACHE_DIR=/workspace
EXPOSE 3000
ENTRYPOINT ["/bin/sh", "-c", "bunx xxx"]But the way, ENV BUN_INSTALL_BIN="~/.bun/bin"
ENV PATH="$BUN_INSTALL_BIN:~/.local/bin:$PATH" |
Beta Was this translation helpful? Give feedback.
Two things going wrong at once — both point at how Docker layering interacts with
bunxcaching.Why your
BUN_INSTALL_CACHE_DIRsetup silently does nothingThere are three problems stacked here:
&&makes the assignment temporary and not exported. WritingX=Y && bunx …assignsXin the shell and then runsbunxas a child process that does not inheritX. You want eitherX=Y bunx …(single command line,Xis exported just for that child) orexport X=Y; bunx ….$WORKSPACE_FOLDERis expanded at container-start time, not at build time. That's fine, but combined with (1) it's just dead text.…