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

Install fail: Self-hosting docker build fail #6839

Open
JocelynFloresz opened this issue Aug 1, 2023 · 15 comments
Open

Install fail: Self-hosting docker build fail #6839

JocelynFloresz opened this issue Aug 1, 2023 · 15 comments

Comments

@JocelynFloresz
Copy link

xhzn@R440:~/ideaProjects/excalidraw$ docker build -t excalidraw/excalidraw .
[+] Building 6.8s (12/13)                                                                                                                                                                                                                                    docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                   0.0s
 => => transferring dockerfile: 379B                                                                                                                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                      0.0s
 => => transferring context: 171B                                                                                                                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/nginx:1.21-alpine                                                                                                                                                                                                   5.8s
 => [internal] load metadata for docker.io/library/node:18                                                                                                                                                                                                             5.8s
 => CACHED [stage-1 1/2] FROM docker.io/library/nginx:1.21-alpine@sha256:a74534e76ee1121d418fa7394ca930eb67440deda413848bc67c68138535b989                                                                                                                              0.0s
 => [build 1/6] FROM docker.io/library/node:18@sha256:c85dc4392f44f5de1d0d72dd20a088a542734445f99bed7aa8ac895c706d370d                                                                                                                                                 0.0s
 => [internal] load build context                                                                                                                                                                                                                                      0.0s
 => => transferring context: 27.99kB                                                                                                                                                                                                                                   0.0s
 => CACHED [build 2/6] WORKDIR /opt/node_app                                                                                                                                                                                                                           0.0s
 => CACHED [build 3/6] COPY package.json yarn.lock ./                                                                                                                                                                                                                  0.0s
 => CACHED [build 4/6] RUN yarn --ignore-optional --network-timeout 600000                                                                                                                                                                                             0.0s
 => CACHED [build 5/6] COPY . .                                                                                                                                                                                                                                        0.0s
 => ERROR [build 6/6] RUN yarn build:app:docker                                                                                                                                                                                                                        0.9s
------
 > [build 6/6] RUN yarn build:app:docker:
0.428 yarn run v1.22.19
0.457 $ cross-env VITE_APP_DISABLE_SENTRY=true VITE_APP_DISABLE_TRACKING=true vite build
0.738 vite v4.4.2 building for production...
0.750 ✓ 0 modules transformed.
0.750 ✓ built in 10ms
0.751 Could not resolve entry module "index.html".
0.753 error during build:
0.753 RollupError: Could not resolve entry module "index.html".
0.753     at error (file:///opt/node_app/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
0.753     at ModuleLoader.loadEntryModule (file:///opt/node_app/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:24671:20)
0.753     at async Promise.all (index 0)
0.786 error Command failed with exit code 1.
0.786 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
Dockerfile:11
--------------------
   9 |
  10 |     COPY . .
  11 | >>> RUN yarn build:app:docker
  12 |
  13 |     FROM nginx:1.21-alpine
--------------------
ERROR: failed to solve: process "/bin/sh -c yarn build:app:docker" did not complete successfully: exit code: 1
@ad1992
Copy link
Member

ad1992 commented Aug 1, 2023

@JocelynFloresz would you like to raise a PR for the fix ?

@Hufschmidt
Copy link

Hufschmidt commented Aug 8, 2023

FYI: The issue is that index.html is excluded by the * in the .dockerignore and not explicitly (re-)enabled by a !index.html like eg. the yarn.lock is.

Adding this to the .dockerignore still fails the build as the index.html contains some kind of template syntax like here.
What script/tool is responsible for replacing those template values?

@ad1992
Copy link
Member

ad1992 commented Aug 9, 2023

FYI: The issue is that index.html is excluded by the * in the .dockerignore and not explicitly (re-)enabled by a !index.html like eg. the yarn.lock is.

Adding this to the .dockerignore still fails the build as the index.html contains some kind of template syntax like here. What script/tool is responsible for replacing those template values?

@Hufschmidt These template syntax was introduced as we migrated to Vite in #6713
can we transform the syntax for docker build ?

@mikesutton
Copy link

when you run yarn build:app:docker outside of docker - it works, so not sure it is the template issue.

@mikesutton
Copy link

Issue is in dockerignore. You are ignoring something that is required.
Remove the '*' at the top allows all things in and the build works.

Not ideal but that's the issue. Any idea what is needed?
Probs best to all allow all and say which you want to ignore (which is really the point of dockerignore).

@mikesutton
Copy link

Ok digging further...

You are ignoring (by default) node_modules\ folder in the .dockerignore but not rebuilding with yarn install in the dockerfile. So basically there are no modules available in the docker build. Although I did explicitly add a yarn install, but that still didn't resolve.

However when I DON'T ignore node_modules it works.

@Xav-Pe
Copy link

Xav-Pe commented Aug 17, 2023

The OP's log is not complete because he didn't used the --progress plain option. Find below a complete log.

Since you also exclude the directory .git in .dockerignore, husky has also errors : fatal: not a git repository (or any of the parent directories): .git.

I agree with @mikesutton : .dockerignore should be listing... the files to ignore. You're doing the opposite way.

PS : the buil works fine on tag v0.15.0.

#1 transferring dockerfile: 581B done
#1 DONE 0.0s

#2 [excalidraw internal] load .dockerignore
#2 transferring context: 230B done
#2 DONE 0.0s

#3 [excalidraw internal] load metadata for docker.io/library/node:18
#3 ...

#4 [excalidraw auth] sharing credentials for REDACTED
#4 DONE 0.0s

#5 [excalidraw internal] load metadata for docker.io/library/nginx:1.21-alpine
#5 DONE 5.2s

#3 [excalidraw internal] load metadata for docker.io/library/node:18
#3 DONE 5.3s

#6 [excalidraw build 1/6] FROM docker.io/library/node:18@sha256:11e9c297fc51f6f65f7d0c7c8a8581e5721f2f16de43ceff1a199fd3ef609f95
#6 DONE 0.0s

#7 [excalidraw stage-1 1/2] FROM docker.io/library/nginx:1.21-alpine@sha256:a74534e76ee1121d418fa7394ca930eb67440deda413848bc67c68138535b989
#7 CACHED

#8 [excalidraw build 2/6] WORKDIR /opt/node_app
#8 CACHED

#9 [excalidraw internal] load build context
#9 transferring context: 95B
#9 transferring context: 4.92MB 0.6s done
#9 DONE 0.6s

#10 [excalidraw build 3/6] COPY package.json yarn.lock ./
#10 DONE 0.3s

#11 [excalidraw build 4/6] RUN yarn --ignore-optional --network-timeout 600000
#11 0.819 yarn install v1.22.19
#11 0.884 [1/5] Validating package.json...
#11 0.888 [2/5] Resolving packages...
#11 1.202 [3/5] Fetching packages...
#11 37.48 warning vscode-languageclient@7.0.0: The engine "vscode" appears to be invalid.
#11 37.48 [4/5] Linking dependencies...
#11 37.49 warning " > @testing-library/react@12.1.5" has incorrect peer dependency "react@<18.0.0".
#11 37.49 warning " > @testing-library/react@12.1.5" has incorrect peer dependency "react-dom@<18.0.0".
#11 37.49 warning " > eslint-plugin-react@7.32.2" has unmet peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
#11 37.49 warning " > @excalidraw/eslint-config@1.0.3" has unmet peer dependency "@typescript-eslint/parser@>=4".
#11 37.49 warning " > @excalidraw/eslint-config@1.0.3" has unmet peer dependency "@typescript-eslint/eslint-plugin@>=4".
#11 37.49 warning " > @excalidraw/eslint-config@1.0.3" has unmet peer dependency "eslint@>=7".
#11 37.49 warning " > eslint-config-prettier@8.5.0" has unmet peer dependency "eslint@>=7.0.0".
#11 37.49 warning " > eslint-config-react-app@7.0.1" has unmet peer dependency "eslint@^8.0.0".
#11 37.49 warning "eslint-config-react-app > @babel/eslint-parser@7.21.3" has unmet peer dependency "eslint@^7.5.0 || ^8.0.0".
#11 37.49 warning "eslint-config-react-app > @typescript-eslint/eslint-plugin@5.58.0" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
#11 37.49 warning "eslint-config-react-app > @typescript-eslint/parser@5.58.0" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
#11 37.49 warning "eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-syntax-flow@^7.14.5".
#11 37.49 warning "eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-transform-react-jsx@^7.14.9".
#11 37.49 warning "eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "eslint@^8.1.0".
#11 37.49 warning "eslint-config-react-app > eslint-plugin-import@2.27.5" has unmet peer dependency "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8".
#11 37.49 warning "eslint-config-react-app > eslint-plugin-jest@25.7.0" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
#11 37.49 warning "eslint-config-react-app > eslint-plugin-jsx-a11y@6.7.1" has unmet peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
#11 37.49 warning "eslint-config-react-app > eslint-plugin-react-hooks@4.6.0" has unmet peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0".
#11 37.49 warning "eslint-config-react-app > eslint-plugin-testing-library@5.10.2" has unmet peer dependency "eslint@^7.5.0 || ^8.0.0".
#11 37.49 warning "eslint-config-react-app > @typescript-eslint/eslint-plugin > @typescript-eslint/type-utils@5.58.0" has unmet peer dependency "eslint@*".
#11 37.49 warning "eslint-config-react-app > @typescript-eslint/eslint-plugin > @typescript-eslint/utils@5.58.0" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
#11 37.49 warning "eslint-config-react-app > eslint-plugin-jest > @typescript-eslint/experimental-utils@5.58.0" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
#11 37.49 warning "eslint-config-react-app > @typescript-eslint/eslint-plugin > @typescript-eslint/utils > @eslint-community/eslint-utils@4.4.0" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0 || >=8.0.0".
#11 37.49 warning " > eslint-plugin-prettier@3.3.1" has unmet peer dependency "eslint@>=5.0.0".
#11 37.49 warning " > vite-plugin-pwa@0.16.4" has unmet peer dependency "workbox-build@^7.0.0".
#11 37.49 warning " > vite-plugin-pwa@0.16.4" has unmet peer dependency "workbox-window@^7.0.0".
#11 45.41 [5/5] Building fresh packages...
#11 47.68 $ husky install
#11 47.76 fatal: not a git repository (or any of the parent directories): .git
#11 47.77 Done in 46.95s.
#11 DONE 49.4s

#12 [excalidraw build 5/6] COPY . .
#12 DONE 3.4s

#13 [excalidraw build 6/6] RUN yarn build:app:docker
#13 0.543 yarn run v1.22.19
#13 0.570 $ cross-env VITE_APP_DISABLE_SENTRY=true VITE_APP_DISABLE_TRACKING=true vite build
#13 0.855 vite v4.4.2 building for production...
#13 0.868 ✓ 0 modules transformed.
#13 0.868 ✓ built in 12ms
#13 0.868 Could not resolve entry module "index.html".
#13 0.870 error during build:
#13 0.870 RollupError: Could not resolve entry module "index.html".
#13 0.870     at error (file:///opt/node_app/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
#13 0.870     at ModuleLoader.loadEntryModule (file:///opt/node_app/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:24671:20)
#13 0.870     at async Promise.all (index 0)
#13 0.891 error Command failed with exit code 1.
#13 0.892 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#13 ERROR: process "/bin/sh -c yarn build:app:docker" did not complete successfully: exit code: 1
------
 > [excalidraw build 6/6] RUN yarn build:app:docker:
0.868 ✓ 0 modules transformed.
0.868 ✓ built in 12ms
0.868 Could not resolve entry module "index.html".
0.870 error during build:
0.870 RollupError: Could not resolve entry module "index.html".
0.870     at error (file:///opt/node_app/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
0.870     at ModuleLoader.loadEntryModule (file:///opt/node_app/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:24671:20)
0.870     at async Promise.all (index 0)
0.891 error Command failed with exit code 1.
0.892 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
failed to solve: process "/bin/sh -c yarn build:app:docker" did not complete successfully: exit code: 1

@hoangvu12
Copy link

Any updates on this? Seems like the .dockerignore file have to be updated.

@griimick
Copy link

griimick commented Aug 25, 2023

index.html is required entry point for vite and the template syntax in index.html is ejs. The required vite plugin (vite-plugin-ejs) to transform it to plain HTML is configured in vite.config.ts which wasn't included in docker context.

Raised a PR which fixes the problems in this issue.

@lazyest
Copy link

lazyest commented Oct 4, 2023

still actual just in case

@nohaj
Copy link

nohaj commented Oct 13, 2023

Waiting on this as well :)

@hypc
Copy link

hypc commented Oct 27, 2023

i build it successfully after rm .dockerignore

@cwansart
Copy link

cwansart commented Nov 9, 2023

Removing .dockerignore worked for me too

@kishorekkota
Copy link

same here

@alswl
Copy link

alswl commented Nov 19, 2023

The project structure has refactored, we should add these required files to .dockerignore:

!index.html
!index.tsx
!vite.config.ts
!vitest.config.ts
!excalidraw-app

I can provide a pull request if you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet