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

Dockerfile for apollo collaboration server fails to build on Mac #455

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shashankbrgowda
Copy link
Contributor

The current Dockerfile for the collaboration server ghcr.io/gmod/apollo-collaboration-server:devel is not building successfully and does not run on a Mac machine. I updated the Dockerfile to use node:18-alpine as the base image and made some modifications to the build stages. These changes allow the image to build correctly and run on Mac environments without issues.

Copy link
Contributor

@garrettjstevens garrettjstevens left a comment

Choose a reason for hiding this comment

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

There are quite a few changes here, are all of them necessary or is it possible to do a more minimal set of changes? At minimum, the LABEL needs to be replaced since that's used by the GitHub container registry.

In particular, I'd like to keep all three build stages since it offers better caching, which helps when having to build multiple times. Another thing is that we should avoid copying the whole .yarn directory over from the build step, since it includes all the installed dev dependencies, which will increase the size of our published image (yarn workspaces focus installs only the dependencies and not the dev dependencies)

@shashankbrgowda
Copy link
Contributor Author

shashankbrgowda commented Oct 2, 2024

There are quite a few changes here, are all of them necessary or is it possible to do a more minimal set of changes? At minimum, the LABEL needs to be replaced since that's used by the GitHub container registry.

In particular, I'd like to keep all three build stages since it offers better caching, which helps when having to build multiple times. Another thing is that we should avoid copying the whole .yarn directory over from the build step, since it includes all the installed dev dependencies, which will increase the size of our published image (yarn workspaces focus installs only the dependencies and not the dev dependencies)

Issue seems to be with the node:18 base image. Image builds fine when we change the base image to node:18-alpine, It also reduces image size to 408 MB from 1.36 GB.

We get below error when we build the image with node:18 base image.

 => [build 3/7] COPY --from=setup /app .                                                                                                                                                                                             0.3s
 => [build 4/7] RUN yarn install --immutable                                                                                                                                                                                         6.3s
 => [build 5/7] COPY . .                                                                                                                                                                                                             2.7s 
 => [build 6/7] WORKDIR /app/packages/apollo-collaboration-server                                                                                                                                                                    0.0s 
 => ERROR [build 7/7] RUN yarn build                                                                                                                                                                                                 3.4s 
------                                                                                                                                                                                                                                    
 > [build 7/7] RUN yarn build:                                                                                                                                                                                                            
3.292 Usage Error: The project in /app/package.json doesn't seem to have been installed - running an install there might help                                                                                                             
3.292 
3.292 $ yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] [--require #0] <scriptName> ...
------
Dockerfile:17
--------------------
  15 |     COPY . .
  16 |     WORKDIR /app/packages/apollo-collaboration-server
  17 | >>> RUN yarn build
  18 |     
  19 |     FROM node:18
--------------------
ERROR: failed to solve: process "/bin/sh -c yarn build" did not complete successfully: exit code: 1

@shashankbrgowda shashankbrgowda self-assigned this Oct 2, 2024
@garrettjstevens
Copy link
Contributor

I'm worried that the switch to node:18-alpine is hiding something else that might be going on. Could you try a couple other things for me? Could you try building with node:18.20.4 and node:20 to see if those work?

@shashankbrgowda
Copy link
Contributor Author

shashankbrgowda commented Oct 3, 2024

18.20.4

I'm worried that the switch to node:18-alpine is hiding something else that might be going on. Could you try a couple other things for me? Could you try building with node:18.20.4 and node:20 to see if those work?

I'm getting same error with node:18.20.4 and yarn install is failing for node:20

6.218 ➤ YN0002: │ @apollo-annotation/shared@workspace:packages/apollo-shared doesn't provide tss-react (p1a585), requested by @apollo-annotation/common and other dependencies.
6.218 ➤ YN0086: │ Some peer dependencies are incorrectly met by your project; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code.
6.218 ➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details.
6.597 ➤ YN0000: └ Completed in 0s 592ms
6.597 ➤ YN0000: ┌ Fetch step
------
Dockerfile:14
--------------------
  12 |     WORKDIR /app
  13 |     COPY --from=setup /app .
  14 | >>> RUN yarn install --immutable
  15 |     COPY . .
  16 |     WORKDIR /app/packages/apollo-collaboration-server
--------------------
ERROR: failed to solve: process "/bin/sh -c yarn install --immutable" did not complete successfully: exit code: 139

@garrettjstevens
Copy link
Contributor

That's really strange that it fails at a totally different place under node:20. Does node:20-alpine work? Also, what is the version of Docker that you are running?

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.

2 participants