sahat/hackathon-starter

Error building docker image

robbrad591 opened this issue · 7 comments

We seem to have an issue building the docker image. M1 Mac with the latest docker (4.22.0 (117440)).

The error is as follows:

`
=> ERROR [web 5/7] RUN npm install --production 72.9s

[web 5/7] RUN npm install --production:
0.385 npm WARN config production Use --omit=dev instead.
72.16
72.16 > hackathon-starter@8.0.0 postinstall
72.16 > patch-package && npm run scss
72.16
72.26 patch-package 7.0.2
72.26 Applying patches...
72.26 No patch files found
72.40
72.40 > hackathon-starter@8.0.0 scss
72.40 > sass --no-source-map --load-path=./ --update ./public/css:./public/css
72.40
72.57 Error reading public/css: no such file or directory.
72.58 npm ERR! code 66
72.58 npm ERR! path /starter
72.58 npm ERR! command failed
72.58 npm ERR! command sh -c patch-package && npm run scss
72.58
72.58 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-08-10T08_29_39_308Z-debug-0.log


failed to solve: process "/bin/sh -c npm install --production" did not complete successfully: exit code: 66`

Post install steps seem to fail. It's strange because if i take out the npm install step, then shell into the container and run the steps manually, it all works.

If I am reading the error log correctly, it looks like the new scss build process isn't working in docker because docker has a different path during the install step. I don't actively use docker, but would be glad to accept a PR if you can come up with change that you have tested and is working. I suspect, you would need to figure out what the path is during the docker installs, and come up with docker script or changes/additions to the npm scripts to handle the path. It looks like currently it can't find public/css when it tries to run the following during the docker install: sass --no-source-map --load-path=./ --update ./public/css:./public/css

Looks like we just need to copy the file structure before we run npm install. I've got that fixed, however there's an issue with the prepare step in the package.json not running when installing for production. I'll put up a PR when i've got around that. Seems to be a common thing

Hey @YasharF and @robbrad591

I fixed this in #1256

See my comments on the PR

The reason behind the issue with husky is that package.json has a call to it, but since it is a dev dependency. The docker image doesn't include dev dependencies by design to keep its size small. We don't want to bloat the image because of a dev dependency. We also can't use ignore-script to skip prepare scripts because ignore-script will also prevent execution of the postinstall scripts. The postinstall scripts include patch-package and sass builds, both of which are needed.

I am looking for a fix to the issue with husky

The other thing that I noticed is that the error is about the sass build, but the PRs that suppress the error mentioned husky. Hence more investigation of the root cause is needed.

The reason the public/css files ends up being empty is because were are overwriting the starter folder by mounting over it here:

Fixed with cf2f40f