Skip to content

Added NODE_PATH to Dockerfile and configure yarn build in prod target#17

Merged
davezuckerman merged 3 commits intomainfrom
AP-542-yarn-issue
Feb 5, 2026
Merged

Added NODE_PATH to Dockerfile and configure yarn build in prod target#17
davezuckerman merged 3 commits intomainfrom
AP-542-yarn-issue

Conversation

@davezuckerman
Copy link
Contributor

moved application.js into packs directory

moved application.js, removed from manifest.js

Moved yarn build

removed commented out code

moved application.js into packs directory

moved application.js, removed from manifest.js

Moved yarn build

removed commented out code
Copy link
Member

@anarchivist anarchivist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes look fine to me, but i'm still running into issues.

with a locally built image i'm seeing this on startup:

app container logs
app-1              | 21:52:03 js.1   | started with pid 9
app-1              | 21:52:04 js.1   | yarn run v1.22.22
app-1              | 21:52:04 js.1   | $ webpack --config webpack.config.js --watch
app-1              | 21:52:04 js.1   | [webpack-cli] Failed to load '/opt/app/webpack.config.js' config
app-1              | 21:52:04 js.1   | [webpack-cli] Error: Cannot find module 'glob'
app-1              | 21:52:04 js.1   | Require stack:
selenium-1         | 21:54:13.776 INFO [LocalNodeRegistry.add] - Added node 1c79439c-8244-4b52-b40b-f30a4fcd55ad at http://172.21.0.6:5555. Health check every 120s
app-1              | 21:52:04 js.1   | - /opt/app/webpack.config.js
app-1              | 21:52:04 js.1   | - /usr/local/yarn/node_modules/webpack-cli/lib/webpack-cli.js
app-1              | 21:52:04 js.1   | - /usr/local/yarn/node_modules/webpack-cli/lib/bootstrap.js
app-1              | 21:52:04 js.1   | - /usr/local/yarn/node_modules/webpack-cli/bin/cli.js
app-1              | 21:52:04 js.1   | - /usr/local/yarn/node_modules/webpack/bin/webpack.js
app-1              | 21:52:04 js.1   |     at Module._resolveFilename (node:internal/modules/cjs/loader:1207:15)
app-1              | 21:52:04 js.1   |     at Module._load (node:internal/modules/cjs/loader:1038:27)
app-1              | 21:52:04 js.1   |     at Module.require (node:internal/modules/cjs/loader:1289:19)
app-1              | 21:52:04 js.1   |     at require (node:internal/modules/helpers:182:18)
app-1              | 21:52:04 js.1   |     at Object.<anonymous> (/opt/app/webpack.config.js:1:14)
app-1              | 21:52:04 js.1   |     at Module._compile (node:internal/modules/cjs/loader:1521:14)
app-1              | 21:52:04 js.1   |     at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
app-1              | 21:52:04 js.1   |     at Module.load (node:internal/modules/cjs/loader:1266:32)
app-1              | 21:52:04 js.1   |     at Module._load (node:internal/modules/cjs/loader:1091:12)
app-1              | 21:52:04 js.1   |     at Module.require (node:internal/modules/cjs/loader:1289:19) {
app-1              | 21:52:04 js.1   |   code: 'MODULE_NOT_FOUND',
app-1              | 21:52:04 js.1   |   requireStack: [
app-1              | 21:52:04 js.1   |     '/opt/app/webpack.config.js',
app-1              | 21:52:04 js.1   |     '/usr/local/yarn/node_modules/webpack-cli/lib/webpack-cli.js',
app-1              | 21:52:04 js.1   |     '/usr/local/yarn/node_modules/webpack-cli/lib/bootstrap.js',
app-1              | 21:52:04 js.1   |     '/usr/local/yarn/node_modules/webpack-cli/bin/cli.js',
app-1              | 21:52:04 js.1   |     '/usr/local/yarn/node_modules/webpack/bin/webpack.js'
app-1              | 21:52:04 js.1   |   ]
app-1              | 21:52:04 js.1   | }
app-1              | 21:52:04 js.1   | error Command failed with exit code 2.
app-1              | 21:52:04 js.1   | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
app-1              | 21:52:05 js.1   | exited with code 2
app-1              | 21:52:05 system | sending SIGTERM to all processes
app-1              | 21:52:05 web.1  | terminated by SIGTERM
app-1              | 21:52:07 web.1  | started with pid 8
app-1              | 21:52:07 js.1   | started with pid 9
app-1              | 21:52:07 js.1   | yarn run v1.22.22
app-1              | 21:52:07 js.1   | $ webpack --config webpack.config.js --watch
app-1              | 21:52:07 js.1   | [webpack-cli] Failed to load '/opt/app/webpack.config.js' config
app-1              | 21:52:07 js.1   | [webpack-cli] Error: Cannot find module 'glob'
app-1              | 21:52:07 js.1   | Require stack:
app-1              | 21:52:07 js.1   | - /opt/app/webpack.config.js
app-1              | 21:52:07 js.1   | - /usr/local/yarn/node_modules/webpack-cli/lib/webpack-cli.js
app-1              | 21:52:07 js.1   | - /usr/local/yarn/node_modules/webpack-cli/lib/bootstrap.js
app-1              | 21:52:07 js.1   | - /usr/local/yarn/node_modules/webpack-cli/bin/cli.js
app-1              | 21:52:07 js.1   | - /usr/local/yarn/node_modules/webpack/bin/webpack.js
app-1              | 21:52:07 js.1   |     at Module._resolveFilename (node:internal/modules/cjs/loader:1207:15)
app-1              | 21:52:07 js.1   |     at Module._load (node:internal/modules/cjs/loader:1038:27)
app-1              | 21:52:07 js.1   |     at Module.require (node:internal/modules/cjs/loader:1289:19)
app-1              | 21:52:07 js.1   |     at require (node:internal/modules/helpers:182:18)
app-1              | 21:52:07 js.1   |     at Object.<anonymous> (/opt/app/webpack.config.js:1:14)
app-1              | 21:52:07 js.1   |     at Module._compile (node:internal/modules/cjs/loader:1521:14)
app-1              | 21:52:07 js.1   |     at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
app-1              | 21:52:07 js.1   |     at Module.load (node:internal/modules/cjs/loader:1266:32)
app-1              | 21:52:07 js.1   |     at Module._load (node:internal/modules/cjs/loader:1091:12)
app-1              | 21:52:07 js.1   |     at Module.require (node:internal/modules/cjs/loader:1289:19) {
app-1              | 21:52:07 js.1   |   code: 'MODULE_NOT_FOUND',
app-1              | 21:52:07 js.1   |   requireStack: [
app-1              | 21:52:07 js.1   |     '/opt/app/webpack.config.js',
app-1              | 21:52:07 js.1   |     '/usr/local/yarn/node_modules/webpack-cli/lib/webpack-cli.js',
app-1              | 21:52:07 js.1   |     '/usr/local/yarn/node_modules/webpack-cli/lib/bootstrap.js',
app-1              | 21:52:07 js.1   |     '/usr/local/yarn/node_modules/webpack-cli/bin/cli.js',
app-1              | 21:52:07 js.1   |     '/usr/local/yarn/node_modules/webpack/bin/webpack.js'
app-1              | 21:52:07 js.1   |   ]
app-1              | 21:52:07 js.1   | }
app-1              | 21:52:07 js.1   | error Command failed with exit code 2.
app-1              | 21:52:07 js.1   | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
app-1              | 21:52:08 js.1   | exited with code 2
app-1              | 21:52:08 system | sending SIGTERM to all processes
app-1              | 21:52:08 web.1  | terminated by SIGTERM
app-1              | 21:52:11 web.1  | started with pid 8
app-1              | 21:52:11 js.1   | started with pid 9
app-1              | 21:52:11 js.1   | yarn run v1.22.22
app-1              | 21:52:11 js.1   | $ webpack --config webpack.config.js --watch
app-1              | 21:52:12 js.1   | [webpack-cli] Failed to load '/opt/app/webpack.config.js' config
app-1              | 21:52:12 js.1   | [webpack-cli] Error: Cannot find module 'glob'
app-1              | 21:52:12 js.1   | Require stack:
app-1              | 21:52:12 js.1   | - /opt/app/webpack.config.js
app-1              | 21:52:12 js.1   | - /usr/local/yarn/node_modules/webpack-cli/lib/webpack-cli.js
app-1              | 21:52:12 js.1   | - /usr/local/yarn/node_modules/webpack-cli/lib/bootstrap.js
app-1              | 21:52:12 js.1   | - /usr/local/yarn/node_modules/webpack-cli/bin/cli.js
app-1              | 21:52:12 js.1   | - /usr/local/yarn/node_modules/webpack/bin/webpack.js
app-1              | 21:52:12 js.1   |     at Module._resolveFilename (node:internal/modules/cjs/loader:1207:15)
app-1              | 21:52:12 js.1   |     at Module._load (node:internal/modules/cjs/loader:1038:27)
app-1              | 21:52:12 js.1   |     at Module.require (node:internal/modules/cjs/loader:1289:19)
app-1              | 21:52:12 js.1   |     at require (node:internal/modules/helpers:182:18)
app-1              | 21:52:12 js.1   |     at Object.<anonymous> (/opt/app/webpack.config.js:1:14)
app-1              | 21:52:12 js.1   |     at Module._compile (node:internal/modules/cjs/loader:1521:14)
app-1              | 21:52:12 js.1   |     at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
app-1              | 21:52:12 js.1   |     at Module.load (node:internal/modules/cjs/loader:1266:32)
app-1              | 21:52:12 js.1   |     at Module._load (node:internal/modules/cjs/loader:1091:12)
app-1              | 21:52:12 js.1   |     at Module.require (node:internal/modules/cjs/loader:1289:19) {
app-1              | 21:52:12 js.1   |   code: 'MODULE_NOT_FOUND',
app-1              | 21:52:12 js.1   |   requireStack: [
app-1              | 21:52:12 js.1   |     '/opt/app/webpack.config.js',
app-1              | 21:52:12 js.1   |     '/usr/local/yarn/node_modules/webpack-cli/lib/webpack-cli.js',
app-1              | 21:52:12 js.1   |     '/usr/local/yarn/node_modules/webpack-cli/lib/bootstrap.js',
app-1              | 21:52:12 js.1   |     '/usr/local/yarn/node_modules/webpack-cli/bin/cli.js',
app-1              | 21:52:12 js.1   |     '/usr/local/yarn/node_modules/webpack/bin/webpack.js'
app-1              | 21:52:12 js.1   |   ]
app-1              | 21:52:12 js.1   | }
app-1              | 21:52:12 js.1   | error Command failed with exit code 2.
app-1              | 21:52:12 js.1   | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
app-1              | 21:52:12 js.1   | exited with code 2
app-1              | 21:52:12 system | sending SIGTERM to all processes
app-1              | 21:52:13 web.1  | terminated by SIGTERM
app-1              | 21:54:10 web.1  | started with pid 8
app-1              | 21:54:10 js.1   | started with pid 9
app-1              | 21:54:11 js.1   | yarn run v1.22.22
app-1              | 21:54:11 js.1   | $ webpack --config webpack.config.js --watch
app-1              | 21:54:11 js.1   | [baseline-browser-mapping] The data in this module is over two months old.  To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
app-1              | 21:54:11 js.1   | asset items.js 40.8 KiB [emitted] (name: items) 1 related asset
app-1              | 21:54:11 js.1   | runtime modules 27.1 KiB 9 modules
app-1              | 21:54:11 js.1   |
app-1              | 21:54:11 js.1   | ERROR in application
app-1              | 21:54:11 js.1   | Module not found: Error: Can't resolve 'app/javascript/application.js' in '/opt/app'
app-1              | 21:54:11 js.1   | Did you mean './app/javascript/application.js'?
app-1              | 21:54:11 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:54:11 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:54:11 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:54:11 js.1   |
app-1              | 21:54:11 js.1   | ERROR in items
app-1              | 21:54:11 js.1   | Module not found: Error: Can't resolve 'app/javascript/items.js' in '/opt/app'
app-1              | 21:54:11 js.1   | Did you mean './app/javascript/items.js'?
app-1              | 21:54:11 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:54:11 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:54:11 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:54:11 js.1   |
app-1              | 21:54:11 js.1   | ERROR in marc-reload
app-1              | 21:54:11 js.1   | Module not found: Error: Can't resolve 'app/javascript/marc-reload.js' in '/opt/app'
app-1              | 21:54:11 js.1   | Did you mean './app/javascript/marc-reload.js'?
app-1              | 21:54:11 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:54:11 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:54:11 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:54:11 js.1   |
app-1              | 21:54:11 js.1   | ERROR in terms
app-1              | 21:54:11 js.1   | Module not found: Error: Can't resolve 'app/javascript/terms.js' in '/opt/app'
app-1              | 21:54:11 js.1   | Did you mean './app/javascript/terms.js'?
app-1              | 21:54:11 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:54:11 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:54:11 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:54:11 js.1   |
app-1              | 21:54:11 js.1   | ERROR in viewer
app-1              | 21:54:11 js.1   | Module not found: Error: Can't resolve 'app/javascript/viewer.js' in '/opt/app'
app-1              | 21:54:11 js.1   | Did you mean './app/javascript/viewer.js'?
app-1              | 21:54:11 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:54:11 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:54:11 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:54:11 js.1   |
app-1              | 21:54:11 js.1   | 5 errors have detailed information that is not shown.
app-1              | 21:54:11 js.1   | Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
app-1              | 21:54:11 js.1   |
app-1              | 21:54:11 js.1   | webpack 5.101.3 compiled with 5 errors in 95 ms
app-1              | 21:54:12 web.1  | => Booting Puma
app-1              | 21:54:12 web.1  | => Rails 7.0.4.3 application starting in development
app-1              | 21:54:12 web.1  | => Run `bin/rails server --help` for more startup options
app-1              | 21:54:12 web.1  | {"name":"rails","hostname":"36c8fd0df131","pid":8,"level":30,"time":"2026-02-04T21:54:12.406+00:00","v":0,"severity":"INFO","msg":"Custom logger initialized for environment \"development\""}
app-1              | 21:54:12 web.1  | {"name":"rails","hostname":"36c8fd0df131","pid":8,"level":30,"time":"2026-02-04T21:54:12.769+00:00","v":0,"severity":"INFO","msg":"Build","data":{}}
app-1              | 21:54:12 web.1  | Puma starting in single mode...
app-1              | 21:54:12 web.1  | * Puma version: 5.6.5 (ruby 3.2.2-p53) ("Birdie's Version")
app-1              | 21:54:12 web.1  | *  Min threads: 5
app-1              | 21:54:12 web.1  | *  Max threads: 5
app-1              | 21:54:12 web.1  | *  Environment: development
app-1              | 21:54:12 web.1  | *          PID: 8
app-1              | 21:54:12 web.1  | * Listening on http://0.0.0.0:3000

on the built container:

built container logs
app-1              | 21:57:35 js.1   | yarn run v1.22.22
app-1              | 21:57:35 js.1   | $ webpack --config webpack.config.js --watch
app-1              | 21:57:35 js.1   | [baseline-browser-mapping] The data in this module is over two months old.  To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
selenium-chrome-1  | 2026-02-04 21:57:35,996 INFO spawned: 'xvfb' with pid 9
selenium-chrome-1  | 2026-02-04 21:57:35,998 INFO spawned: 'vnc' with pid 10
selenium-chrome-1  | 2026-02-04 21:57:36,000 INFO spawned: 'novnc' with pid 11
selenium-chrome-1  | 2026-02-04 21:57:36,004 INFO spawned: 'selenium-node' with pid 13
selenium-chrome-1  | 2026-02-04 21:57:36,010 INFO success: selenium-node entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
app-1              | 21:57:36 js.1   | asset items.js 40.8 KiB [compared for emit] (name: items) 1 related asset
app-1              | 21:57:36 js.1   | runtime modules 27.1 KiB 9 modules
app-1              | 21:57:36 js.1   |
app-1              | 21:57:36 js.1   | ERROR in application
app-1              | 21:57:36 js.1   | Module not found: Error: Can't resolve 'app/javascript/application.js' in '/opt/app'
app-1              | 21:57:36 js.1   | Did you mean './app/javascript/application.js'?
app-1              | 21:57:36 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:57:36 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:57:36 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:57:36 js.1   |
app-1              | 21:57:36 js.1   | ERROR in items
app-1              | 21:57:36 js.1   | Module not found: Error: Can't resolve 'app/javascript/items.js' in '/opt/app'
app-1              | 21:57:36 js.1   | Did you mean './app/javascript/items.js'?
app-1              | 21:57:36 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:57:36 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:57:36 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:57:36 js.1   |
app-1              | 21:57:36 js.1   | ERROR in marc-reload
app-1              | 21:57:36 js.1   | Module not found: Error: Can't resolve 'app/javascript/marc-reload.js' in '/opt/app'
app-1              | 21:57:36 js.1   | Did you mean './app/javascript/marc-reload.js'?
app-1              | 21:57:36 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:57:36 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:57:36 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:57:36 js.1   |
app-1              | 21:57:36 js.1   | ERROR in terms
app-1              | 21:57:36 js.1   | Module not found: Error: Can't resolve 'app/javascript/terms.js' in '/opt/app'
app-1              | 21:57:36 js.1   | Did you mean './app/javascript/terms.js'?
app-1              | 21:57:36 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:57:36 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:57:36 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:57:36 js.1   |
app-1              | 21:57:36 js.1   | ERROR in viewer
app-1              | 21:57:36 js.1   | Module not found: Error: Can't resolve 'app/javascript/viewer.js' in '/opt/app'
app-1              | 21:57:36 js.1   | Did you mean './app/javascript/viewer.js'?
app-1              | 21:57:36 js.1   | Requests that should resolve in the current directory need to start with './'.
app-1              | 21:57:36 js.1   | Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
app-1              | 21:57:36 js.1   | If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
app-1              | 21:57:36 js.1   |
app-1              | 21:57:36 js.1   | 5 errors have detailed information that is not shown.
app-1              | 21:57:36 js.1   | Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
app-1              | 21:57:36 js.1   |
app-1              | 21:57:36 js.1   | webpack 5.101.3 compiled with 5 errors in 97 ms
selenium-1         | 21:57:36.298 INFO [UnboundZmqEventBus.<init>] - Event bus ready
app-1              | 21:57:36 web.1  | => Booting Puma
app-1              | 21:57:36 web.1  | => Rails 7.0.4.3 application starting in production
app-1              | 21:57:36 web.1  | => Run `bin/rails server --help` for more startup options

i'm afraid that this still doesn't address the issue.

@anarchivist
Copy link
Member

if i explicitly yarn add glob (see the locally built container logs above), then i get LoadError in ItemsController#index: cannot load such file -- sassc:
Screenshot 2026-02-04 at 14 17 02

David Zuckerman added 2 commits February 4, 2026 15:12
…e in assets.rb initializer,having bundle call rails in Dockerfile for precompile
@awilfox
Copy link
Member

awilfox commented Feb 5, 2026

On 926bd0f (before the symbolic link commit), with a completely wiped cache, I'm not seeing any errors. Running:

podman compose build
podman compose up -d
podman compose exec app rake db:setup assets:precompile

gives me a functional UCBEARS development instance at localhost:3000.

@davezuckerman
Copy link
Contributor Author

I just pushed another version adding a symbolic link for /usr/local/yarn/node_modules which is working for me. I'm doing this to test a production setup. I'll try it in development mode after dinner.

docker build . --target=production -t ucbears-prod --no-cache

in docker-compose
adding
image: ucbears-prod
RAILS_ENV: production
commenting out the RW volume mounts

@davezuckerman
Copy link
Contributor Author

It's working for me in development as well. I built an image with the development target and used the stock docker-compose.yml. So I'm able to run both prod and development with this latest commit

Copy link
Member

@anarchivist anarchivist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, good news! it's working for me. :) i think this is good to go.

@davezuckerman davezuckerman merged commit 932650a into main Feb 5, 2026
7 checks passed
@davezuckerman davezuckerman deleted the AP-542-yarn-issue branch February 5, 2026 18:58
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.

3 participants