Comments (17)
That's fixed in github, but unreleased. I've also fixed other things, including some cosmetic changes like naming the stage bun not node. If you want to try it, replace the entry in your gemfile with:
gem "dockerfile-rails", "~> 1.5", :group => :development, :git => "https://github.com/fly-apps/dockerfile-rails.git"
from dockerfile-rails.
Released: https://github.com/fly-apps/dockerfile-rails/releases/tag/v1.5.9
from dockerfile-rails.
Where bun was added rails/jsbundling-rails#167
from dockerfile-rails.
Initial support installs bun instead of yarn. Node in still installed, for now. I should be able to remove Node. Neither node nor bun will be in the deployed image unless execjs is used.
from dockerfile-rails.
reopening as testing without node at all is going surprisingly well...
from dockerfile-rails.
hey Sam!
first of all, thank you so much for the quick reply and implementation!
I'm still getting mentions of yarn.lock
on my Dockerfile
This is my configuration:
# generated by dockerfile-rails
---
options:
bin-cd: true
cache: true
fullstaq: true
jemalloc: true
parallel: true
postgresql: true
redis: true
root: true
yjit: true
envs:
base:
BUNDLE_WITHOUT: development:test:linting:profiler
GIT_REV: "${GIT_REV}"
BUILD_DATE: "${BUILD_DATE}"
args:
base:
GIT_REV: "${GIT_REV}"
BUILD_DATE: "${BUILD_DATE}"
and this is what is being generated (relevant part)
# Throw-away build stages to reduce size of final image
FROM base as prebuild
# Install packages needed to build gems and node modules
RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=dev-apt-lib,sharing=locked,target=/var/lib/apt \
apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential curl libpq-dev node-gyp pkg-config python-is-python3
FROM prebuild as node
# Install Node.js
ARG NODE_VERSION=20.6.1
ARG BUN_VERSION=1.0.0
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
npm install -g bun@$BUN_VERSION && \
rm -rf /tmp/node-build-master
# Install node modules
COPY --link package.json yarn.lock ./
RUN --mount=type=cache,id=bld-yarn-cache,target=/root/.yarn \
YARN_CACHE_FOLDER=/root/.yarn bun install --frozen-lockfile
from dockerfile-rails.
You are getting mentions of a yarn.lock because.... drum roll you have a yarn.lock. If you remove your yarn.lock file and regenerate your dockerfile this should go away.
More troublesome is that bun.lockb is not listed on the COPY line. That's either because you don't have that file, or this is a path that I've not yet tested.
from dockerfile-rails.
Bun's addition to Rails: rails/rails@274bc97
from dockerfile-rails.
I'm getting an error because I do not have a yarn.lock file on my root folder but I do have a bun.lockb
. I manually change yarn.lock
to bun.lockb
and it worked but any new dockerfile generation overrides it, obviously
from dockerfile-rails.
@rubys thanks! I will give it a try tonight and let you know!
from dockerfile-rails.
couple of things:
- now it is installing
bun
instead of node but it is trying to runnpm install
instead ofbun install
:
FROM prebuild as bun
# Install Bun
ARG BUN_VERSION=1.0.1
ENV BUN_INSTALL=/usr/local/bun
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -fsSL https://bun.sh/install | bash -s -- "${BUN_VERSION}"
# Install node modules
COPY --link package.json bun.lockb ./
RUN --mount=type=cache,id=bld-npm-cache,target=/root/.npm \
npm install
I don't have a yarn.lock
, not sure why it is trying to use npm
- bun install step is failing:
=> CANCELED [stage-4 1/3] RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt --mount=type=cache,id=dev-apt-lib,sh 20.0s
=> ERROR [bun 1/3] RUN curl -fsSL https://bun.sh/install | bash -s -- "1.0.1" 0.6s
=> [build 1/7] COPY --link Gemfile Gemfile.lock ./ 0.0s
=> CANCELED [build 2/7] RUN --mount=type=cache,id=bld-gem-cache,sharing=locked,target=/srv/vendor bundle config set app_config .bundle && 0.6s
------
> [bun 1/3] RUN curl -fsSL https://bun.sh/install | bash -s -- "1.0.1":
#0 0.619 error: unzip is required to install bun (see: https://github.com/oven-sh/bun#unzip-is-required)
it might have to do with my image maybe? (fullstaq-ruby:${RUBY_VERSION}-jemalloc-slim
).
I guess fullstaq-ruby slim does not include unzip
while the ruby
docker image does?
edit: I manually added unzip
and got this error instead
=> CANCELED [stage-4 1/3] RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt --mount=type=cache,id=dev-apt-lib,sh 18.8s
=> ERROR [bun 1/3] RUN curl -fsSL https://bun.sh/install | bash -s -- "1.0.1" 1.0s
=> [build 1/7] COPY --link Gemfile Gemfile.lock ./ 0.0s
=> CANCELED [build 2/7] RUN --mount=type=cache,id=bld-gem-cache,sharing=locked,target=/srv/vendor bundle config set app_config .bundle && 1.0s
------
> [bun 1/3] RUN curl -fsSL https://bun.sh/install | bash -s -- "1.0.1":
curl: (22) The requested URL returned error: 404
#0 0.989
#0 0.991 error: Failed to download bun from "https://github.com/oven-sh/bun/releases/download/1.0.1/bun-linux-x64.zip"
but that seems to be a mistake on bun's install script
from dockerfile-rails.
I don't have a yarn.lock, not sure why it is trying to use npm
That should now be fixed.
but that seems to be a mistake on bun's install script
OK, switched back to installing bun via npm.
from dockerfile-rails.
=> ERROR [build 4/7] COPY --from=bun /usr/local/bun /usr/local/bun 0.0s
------
> [build 4/7] COPY --from=bun /usr/local/bun /usr/local/bun:
------
Error: failed to fetch an image or build from source: error building: failed to solve: failed to compute cache key: "/usr/local/bun" not found: not found
I thought that COPY --from=bun /usr/local/bun /usr/local/bun
is not necessary when using npm
so I removed but then I got a different error
=> ERROR [build 6/6] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile 2.1s
------
> [build 6/6] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile:
#0 2.108 rails aborted!
#0 2.108 cssbundling-rails: Command install failed, ensure bun is installed
I guess it is needed but the path is incorrect. I couldn't figure out the path exactly
from dockerfile-rails.
ok, so I got bun installed with my Dockerfile configuration. This is what I've done
FROM prebuild as bun
# Install Bun
ARG BUN_VERSION=bun-v1.0.2
ENV BUN_INSTALL=/usr/local/bun
ENV PATH=/usr/local/bun/bin:$PATH
RUN curl -fsSL https://bun.sh/install | bash -s -- "${BUN_VERSION}"
noticed that the BUN_VERSION
arg should be bun-v{version}
not just the version
after that, you need to copy the installer and set the path on the next step
FROM prebuild as build
# Install application gems
...
# Copy bun modules
COPY --from=bun /rails/node_modules /rails/node_modules
COPY --from=bun /usr/local/bun /usr/local/bun
ENV PATH=/usr/local/bun/bin:$PATH
I noticed you got to set the PATH
for bun twice tho
from dockerfile-rails.
Thanks! I pushed a change with basically those fixes applied, with some minor cosmetic differences (example: I put "bun-v" on the curl line). Can you give it a try?
from dockerfile-rails.
Works perfectly!
The only thing I noticed was that it kept the PATH addition for node:
ENV PATH=/usr/local/bun/bin:$PATH
ENV PATH=/usr/local/node/bin:$PATH
it's not going to break anything ofc but it can be removed I believe
apart from that, it is compiling now 🎉
from dockerfile-rails.
Fixed: 56d0373
from dockerfile-rails.
Related Issues (20)
- Expose BUNDLE_WITHOUT as ARG to enable building test and production images HOT 1
- Add curl HOT 2
- 1.5.2 Dockerfile breaks on ECS HOT 4
- `--max-idle` option generates corrupted Dockerfile
- `--max-idle=n` should now be added for Puma
- dockerfile_generator.rb:505:in `>=': comparison of Gem::Version with String failed (ArgumentError)
- Don't default to sqlite3, or provide option to disable? HOT 2
- vendor directory is empty in CI HOT 1
- `packages` directive on `dockerfile.yaml` doesn't install all packages
- replace frozen-lockfile with immutable for yarn >= 2
- [REQ] Is there a plan to support Alpine Linux in `dockerfile-rails` instead of the Debian OS? HOT 7
- Node being installed even if Bun is being used HOT 2
- Error installing psych (5.1.2) when creating DockerFile with Rails 7.1.2
- Order of `COPY` commands doesn't allow for Gemfile's `file` directive
- Node path not found error when building image with Alpine
- Missing RUN statement when using execjs and Yarn HOT 1
- Latest Rubygems no longer supports Ruby < 3 HOT 1
- Use `bun` official images HOT 2
- Ignore Shrine default upload directory in .dockerignore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockerfile-rails.