Skip to content

Commit c106b9e

Browse files
committed
Set up node in the isolated env in attempt to fix tailwind executable
1 parent b67dff5 commit c106b9e

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

Dockerfile

+1-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ COPY --from=nodejs /usr/local/lib/ /usr/local/lib/
9292
COPY --from=nodejs /usr/local/include/ /usr/local/include/
9393
COPY --from=nodejs /usr/local/share/ /usr/local/share/
9494

95-
# Install tailwindcss CLI globally
96-
RUN npm install -g tailwindcss
97-
95+
# Copy the entire bundle including native extensions
9896
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
9997
COPY --from=build /rails /rails
10098

app/services/command_execution_service.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,13 @@ def env_for_command
214214
"NODE_ENV" => "development",
215215
"GEM_HOME" => "#{RAILS_GEN_ROOT}/gems",
216216
"GEM_PATH" => "#{RAILS_GEN_ROOT}/gems:#{RAILS_GEN_ROOT}/ruby/lib/ruby/gems/3.4.0",
217-
"PATH" => "#{RAILS_GEN_ROOT}/gems/bin:#{RAILS_GEN_ROOT}/ruby/bin:/opt/homebrew/bin:/usr/local/lib/nodejs/bin:/usr/local/bin:/usr/bin:/bin",
217+
"PATH" => "#{RAILS_GEN_ROOT}/gems/bin:#{RAILS_GEN_ROOT}/ruby/bin:#{RAILS_GEN_ROOT}/node/bin:/usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin",
218218
"HOME" => "/var/lib/rails-new-io/home",
219-
"RAILS_DEBUG_TEMPLATE" => "1"
219+
"RAILS_DEBUG_TEMPLATE" => "1",
220+
# Node.js environment for new Rails apps
221+
"npm_config_prefix" => "#{RAILS_GEN_ROOT}/node",
222+
"NODE_PATH" => "#{RAILS_GEN_ROOT}/node_modules",
223+
"COREPACK_HOME" => "#{RAILS_GEN_ROOT}/.corepack"
220224
}
221225

222226
if RUBY_PLATFORM.include?("darwin")

bin/docker-entrypoint

+12
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,22 @@ if [ ! -d "/var/lib/rails-new-io/rails-env/ruby" ] || [ "$FORCE_ISOLATED_RUBY_RE
3434
mkdir -p /var/lib/rails-new-io/rails-env/gems/{bin,specifications,gems,extensions}
3535
mkdir -p /var/lib/rails-new-io/rails-env/bundle
3636
mkdir -p /var/lib/rails-new-io/{home,config,cache,data}
37+
# Create Node.js directories with proper structure
38+
mkdir -p /var/lib/rails-new-io/rails-env/node/{bin,lib,share}
39+
mkdir -p /var/lib/rails-new-io/rails-env/node_modules
40+
mkdir -p /var/lib/rails-new-io/rails-env/.corepack
41+
chown -R rails:rails /var/lib/rails-new-io/rails-env
3742

3843
echo "DEBUG: Copying system Ruby to isolated environment"
3944
cp -a /usr/local/* /var/lib/rails-new-io/rails-env/ruby/
4045

46+
# Set up Node.js symlinks in their own directory
47+
echo "DEBUG: Setting up Node.js symlinks"
48+
ln -sf /usr/local/bin/node /var/lib/rails-new-io/rails-env/node/bin/
49+
ln -sf /usr/local/bin/npm /var/lib/rails-new-io/rails-env/node/bin/
50+
ln -sf /usr/local/bin/npx /var/lib/rails-new-io/rails-env/node/bin/
51+
ln -sf /usr/local/bin/corepack /var/lib/rails-new-io/rails-env/node/bin/
52+
4153
# Run the isolated environment setup in a subshell to avoid polluting the parent environment
4254
(
4355
# Unset any existing bundler environment variables that might interfere

0 commit comments

Comments
 (0)