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

Unable to build backend with Dockerfile #199

Open
olepl opened this issue Nov 11, 2024 · 3 comments
Open

Unable to build backend with Dockerfile #199

olepl opened this issue Nov 11, 2024 · 3 comments

Comments

@olepl
Copy link

olepl commented Nov 11, 2024

When I try to build the Docker image of either the complete app or just the backend I get the following error:

> [server-build 10/10] RUN mv node_modules/googleapis/build/src/apis/docs ./docs &&     node-prune --exclude "**/googleapis/**/docs/*.js" &&     mv ./docs node_modules/googleapis/build/src/apis/docs:
0.176 /bin/sh: node-prune: not found
------
Dockerfile:38
--------------------
 37 |     # The mv is a workaround for this - https://github.com/tj/node-prune/issues/63
 38 | >>> RUN mv node_modules/googleapis/build/src/apis/docs ./docs && \
 39 | >>>     node-prune --exclude "**/googleapis/**/docs/*.js" && \
 40 | >>>     mv ./docs node_modules/googleapis/build/src/apis/docs
 41 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c mv node_modules/googleapis/build/src/apis/docs ./docs &&     node-prune --exclude \"**/googleapis/**/docs/*.js\" &&     mv ./docs node_modules/googleapis/build/src/apis/docs" did not complete successfully: exit code: 127

If I simply comment out the highlighted lines (38-40) I can build the image successfully

@guyzyl
Copy link
Owner

guyzyl commented Nov 28, 2024

I just tried building the image myself and it worked for me.
Can you provide some more details? The full build log, OS + Docker version, and the command you ran to build the image?
(and sorry for the delay)

@olepl
Copy link
Author

olepl commented Nov 28, 2024

Of course!

Docker: Docker version 27.3.1, build v27.3.1
OS: NixOS 25.05

FYI NixOS is a Linux distro where you declaratively define your packages and configuration. My config can be viewed here. The main difference compared to other Linux systems to be aware of is that NixOS doesn't conform to the FHS.

Command: docker build -t whasync . or docker build -t whasync-backend -f server/Dockerfile . as described in your README, both produce the following output with just the line numbers for the highlighted lines changed:

[+] Building 0.7s (14/28)                                                                      docker:default
 => [internal] load build definition from Dockerfile                                                     0.0s
 => => transferring dockerfile: 1.52kB                                                                   0.0s
 => [internal] load metadata for docker.io/library/node:21-alpine                                        0.4s
 => [internal] load .dockerignore                                                                        0.0s
 => => transferring context: 101B                                                                        0.0s
 => [internal] load build context                                                                        0.0s
 => => transferring context: 815.24kB                                                                    0.0s
 => [server-build  1/10] FROM docker.io/library/node:21-alpine@sha256:78c45726ea205bbe2f23889470f03b46a  0.0s
 => CACHED [server-build  2/10] WORKDIR /app/server                                                      0.0s
 => CACHED [server-build  3/10] COPY [server/package.json, server/package-lock.json*, ./]                0.0s
 => CACHED [server-build  4/10] RUN npm install                                                          0.0s
 => CACHED [server-build  5/10] COPY ./interfaces /app/interfaces                                        0.0s
 => CACHED [server-build  6/10] COPY ./server .                                                          0.0s
 => CACHED [server-build  7/10] RUN npm run build                                                        0.0s
 => CACHED [server-build  8/10] RUN npm prune --production                                               0.0s
 => CACHED [server-build  9/10] RUN apk update &&     apk add curl &&     curl -sf https://gobinaries.c  0.0s
 => ERROR [server-build 10/10] RUN mv node_modules/googleapis/build/src/apis/docs ./docs &&     node-pr  0.2s
------
 > [server-build 10/10] RUN mv node_modules/googleapis/build/src/apis/docs ./docs &&     node-prune --exclude "**/googleapis/**/docs/*.js" &&     mv ./docs node_modules/googleapis/build/src/apis/docs:
0.203 /bin/sh: node-prune: not found
------
Dockerfile:38
--------------------
  37 |     # The mv is a workaround for this - https://github.com/tj/node-prune/issues/63
  38 | >>> RUN mv node_modules/googleapis/build/src/apis/docs ./docs && \
  39 | >>>     node-prune --exclude "**/googleapis/**/docs/*.js" && \
  40 | >>>     mv ./docs node_modules/googleapis/build/src/apis/docs
  41 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c mv node_modules/googleapis/build/src/apis/docs ./docs &&     node-prune --exclude \"**/googleapis/**/docs/*.js\" &&     mv ./docs node_modules/googleapis/build/src/apis/docs" did not complete successfully: exit code: 127

Clearly those 3 lines are a problem for some reason, and as mentioned I can comment the lines out and build the image successfully.

What is the purpose of those lines, are you able build the image without those lines?

@guyzyl
Copy link
Owner

guyzyl commented Dec 5, 2024

With 0 knowledge (or testing) of Nix, from your statement it sounds like the lack of FHS is what's causing it.

And in regard to the 3 lines, the purpose is to cleanup packages from the Docker image.
You can remove them locally if you'd like and it should still work as intended.

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

2 participants