Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-building Cachet in Docker with npm fails due to uglify-js #394

Open
christidis opened this issue Dec 22, 2020 · 0 comments
Open

Re-building Cachet in Docker with npm fails due to uglify-js #394

christidis opened this issue Dec 22, 2020 · 0 comments

Comments

@christidis
Copy link

I have a Dockerfile like the following in order to re-build the application in 2.4 and apply some CSS changes

>cat Dockerfile 
# build stage
FROM cachethq/docker:latest
COPY public/img/login-logo.png /var/www/html/public/img/login-logo.png
COPY resources /var/www/html/resources
USER root
RUN apk add --no-cache npm
USER 1001
RUN mkdir -p /home/www-data/.npm/ && cd /var/www/html && npm install && npm run production

# docker stage
FROM cachethq/docker:latest
RUN rm -fr /var/www/html
COPY --from=0 --chown=1001 /var/www/html /var/www/html
COPY entrypoint.sh /sbin/entrypoint.sh
USER root
RUN apk add --no-cache vim
USER 1001

Lately I have noticed that uglify-js is giving this error.

 DONE  Compiled successfully in 30631ms                                                                                        11:59:51 AM

Whoops! We had trouble minifying "public/dist/js/all.js". Perhaps you need to use mix.babel() instead?

/var/www/html/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:64
                    throw e;
                    ^
SyntaxError: Name expected
    at JS_Parse_Error.get (eval at <anonymous> (/var/www/html/node_modules/uglify-js/tools/node.js:27:1), <anonymous>:86:23)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cachet@ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the cachet@ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/www-data/.npm/_logs/2020-12-22T11_59_51_992Z-debug.log

When I build the image using an older docker image from a previous build from my docker registry, that has node_modules already installed, then the build succeeds.
I have verified that the uglify-js is in the same version in both images.

bash-5.0$ npm list uglify-js
cachet@ /var/www/html
`-- [email protected]
  +-- [email protected]
  | `-- [email protected]
  |   `-- [email protected] 
  +-- [email protected] 
  `-- [email protected]
    `-- [email protected]
      `-- [email protected]  deduped

However, if I diff the two folders (the one created in a new npm install, and the one that was installed in an older image) the actual files differ. So, as a workaround, after npm install I am replacing the node_modules/uglify-js from an older image to the node_modules and the npm run production works without any issues and this was my workaround to the problem.

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

No branches or pull requests

1 participant