E2B icon indicating copy to clipboard operation
E2B copied to clipboard

Error building docker image

Open DrewWalkup opened this issue 1 year ago • 9 comments

Describe the bug The build process stops at step 7 out of 7, which is running the command "npm run build". The error message indicates that the build process failed because of a Webpack error.

The specific error message indicates that the module 'components/Editor/Template/NodeJSExpressTemplate/useInstruction' cannot be resolved. This suggests that there may be an issue with the file path or module installation.

To Reproduce Steps to reproduce the behavior:

  1. git clone the repo (in this case hash 91e333dafb961a5eeffa769a039bfbbd4c2ae42a)
  2. cd to directory
  3. docker build -t image_name .
  4. See error

Expected behavior Docker file built successfully.

Browser console output

 docker build -t code_agent .
[+] Building 78.4s (11/14)
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 32B                                                                                0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 307B                                                                                  0.0s
 => [internal] load metadata for docker.io/library/node:lts-slim                                                   1.0s
 => [runner 1/5] FROM docker.io/library/node:lts-slim@sha256:b8a9ad50d8833a2aede22170a517e64c79776e9145811d7f6649  0.0s
 => [internal] load build context                                                                                  0.2s
 => => transferring context: 8.22MB                                                                                0.1s
 => CACHED [runner 2/5] WORKDIR /app                                                                               0.0s
 => [builder 3/7] COPY package.json package-lock.json* ./                                                          0.1s
 => [builder 4/7] COPY prisma/schema.prisma ./prisma/schema.prisma                                                 0.0s
 => [builder 5/7] RUN npm ci                                                                                      66.6s
 => [builder 6/7] COPY . .                                                                                         0.1s
 => ERROR [builder 7/7] RUN npm run build                                                                         10.3s
------
 > [builder 7/7] RUN npm run build:
#11 0.902
#11 0.902 > [email protected] build
#11 0.902 > next build
#11 0.902
#11 1.489 warn  - You have enabled experimental feature (swcPlugins) in next.config.js.
#11 1.490 warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
#11 1.490
#11 1.618 info  - Skipping validation of types
#11 1.618 info  - Skipping linting
#11 2.023 info  - Creating an optimized production build...
#11 10.22 Failed to compile.
#11 10.22
#11 10.22 ./components/Editor/Template/NodeJSExpressTemplate/Instructions.tsx
#11 10.22 Module not found: Can't resolve 'components/Editor/Template/NodeJSExpressTemplate/useInstruction'
#11 10.22
#11 10.22 https://nextjs.org/docs/messages/module-not-found
#11 10.22
#11 10.22 Import trace for requested module:
#11 10.22 ./components/Editor/Template/NodeJSExpressTemplate/index.tsx
#11 10.22 ./state/template.tsx
#11 10.22 ./state/store.ts
#11 10.22 ./state/StoreProvider.tsx
#11 10.22 ./pages/[projectID].tsx
#11 10.22
#11 10.22
#11 10.22 > Build failed because of webpack errors

Terminal commands & output See "steps to reproduce"

Screenshots n/a

Desktop (please complete the following information):

  • OS: Windows 11
  • WSL
  • Docker Desktop

Smartphone (please complete the following information): n/a

Additional context Add any other context about the problem here.

DrewWalkup avatar Apr 25 '23 16:04 DrewWalkup

I think there is some problem with your git checked files - building 91e333dafb961a5eeffa769a039bfbbd4c2ae42a was OK for me and I cannot find components/Editor/Template/NodeJSExpressTemplate/useInstruction in the whole codebase.

Also when you try to build the image with docker build -t image_name . (as opposed to using npm run/Compose) there will be error with missing credentials during the build.

ValentaTomas avatar Apr 25 '23 16:04 ValentaTomas

@ValentaTomas Different issue with the npm start command:

PS D:\dev\e2b> npm start

> [email protected] start
> docker compose build && (npm run db:reset ; npm run db:start && docker compose up)

[+] Building 2.3s (24/37)
 => [e2b/app:latest internal] load build definition from Dockerfile                                                0.0s
 => => transferring dockerfile: 1.08kB                                                                             0.0s
 => [e2b/api:latest internal] load build definition from Dockerfile                                                0.0s
 => => transferring dockerfile: 1.22kB                                                                             0.0s
 => [e2b/app:latest internal] load .dockerignore                                                                   0.0s
 => => transferring context: 418B                                                                                  0.0s
 => [e2b/api:latest internal] load .dockerignore                                                                   0.0s
 => => transferring context: 200B                                                                                  0.0s
 => [e2b/api:latest internal] load metadata for docker.io/library/node:lts-slim                                    1.0s
 => [e2b/api:latest internal] load metadata for docker.io/nikolaik/python-nodejs:python3.10-nodejs18-slim          1.3s
 => [e2b/api:latest runner 1/5] FROM docker.io/library/node:lts-slim@sha256:b8a9ad50d8833a2aede22170a517e64c79776  0.0s
 => [e2b/app:latest internal] load build context                                                                   0.0s
 => => transferring context: 1.08MB                                                                                0.0s
 => CACHED [e2b/app:latest runner 2/5] WORKDIR /app                                                                0.0s
 => CACHED [e2b/app:latest builder 3/7] COPY package.json package-lock.json* ./                                    0.0s
 => CACHED [e2b/app:latest builder 4/7] COPY prisma/schema.prisma ./prisma/schema.prisma                           0.0s
 => CACHED [e2b/app:latest builder 5/7] RUN npm ci                                                                 0.0s
 => CACHED [e2b/app:latest builder 6/7] COPY . .                                                                   0.0s
 => CANCELED [e2b/app:latest builder 7/7] RUN npm run build                                                        1.1s
 => [e2b/api:latest internal] load build context                                                                   0.0s
 => => transferring context: 803.64kB                                                                              0.0s
 => CANCELED [e2b/api:latest stage-1  1/11] FROM docker.io/nikolaik/python-nodejs:python3.10-nodejs18-slim@sha256  0.8s
 => => resolve docker.io/nikolaik/python-nodejs:python3.10-nodejs18-slim@sha256:40646fa29a3cc2c5fb2fb44f23b8de7bd  0.0s
 => => sha256:40646fa29a3cc2c5fb2fb44f23b8de7bd063bd90f09054eff0718be99327e928 1.79kB / 1.79kB                     0.0s
 => => sha256:9ad47fcd2c0ce7dad385b1c222c44c20c23896837a9b37e314e7f83b1066e97e 0B / 11.53MB                        0.8s
 => => sha256:9da6498f32c0da3ab410d0db380acc83f8b53b9dc5058b4ff681d30adbe35f69 243B / 243B                         0.5s
 => => sha256:b5f03b87ec3306500eb9601faa29b6a26b479da09a80d70c346082380e80ad53 10.98kB / 10.98kB                   0.0s
 => => sha256:9e79879be9c7cd8edaba21c88fa4be66ea65e7a3f56f98e7820bcb7dedac3b00 1.08MB / 1.08MB                     0.4s
 => => extracting sha256:9e79879be9c7cd8edaba21c88fa4be66ea65e7a3f56f98e7820bcb7dedac3b00                          0.1s
 => => sha256:756350766a457544a22c86b629bf9e92434644b083bd213ffcedf13127ba2944 0B / 3.37MB                         0.8s
 => => sha256:e1244dca161248f8b9a2f9e1d6f28a3d8f05ec486869c54a2fcdfe085c2a45a4 0B / 4.16kB                         0.8s
 => CACHED [e2b/api:latest playground 2/9] WORKDIR /playground                                                     0.0s
 => CACHED [e2b/api:latest playground 3/9] COPY playground/package.json playground/package-lock.json ./            0.0s
 => CACHED [e2b/api:latest playground 4/9] RUN npm ci                                                              0.0s
 => CACHED [e2b/api:latest playground 5/9] COPY playground/tsconfig.json ./                                        0.0s
 => CACHED [e2b/api:latest playground 6/9] COPY playground/tsoa.json ./                                            0.0s
 => CACHED [e2b/api:latest playground 7/9] COPY playground/scripts/build.js ./scripts/build.js                     0.0s
 => CACHED [e2b/api:latest playground 8/9] COPY playground/src ./src                                               0.0s
 => ERROR [e2b/api:latest playground 9/9] RUN npm run build                                                        0.7s
------
 > [e2b/api:latest playground 9/9] RUN npm run build:
#0 0.703
#0 0.703 > [email protected] build
#0 0.703 > ./scripts/build.js
#0 0.703
#0 0.708 /usr/bin/env: 'node\r': No such file or directory
------
failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 127

New to using Docker though npm, and do appreciate feedback on dumb mistakes.

industriaditat avatar Apr 25 '23 17:04 industriaditat

New to using Docker though npm

No worries @industriaditat! It is actually docker compose build we call in the npm script command that handles the env vars.

The error you mentioned is because of Git on Windows changing newlines to /r/n and during the Docker (Compose) build the process is expecting just /n newlines.

Here is a relevant StackOvewflow question - you can temporarily fix it by reconfiguring Git behaviour with:

git config --global core.autocrlf false

then running

git clone https://github.com/e2b-dev/e2b.git

again.

This is also the same problem as this one on Discord.

ValentaTomas avatar Apr 25 '23 17:04 ValentaTomas

Ahh yes, the dreaded windows CRLF issue. Ya know, you stop using Dockerfiles for 5 minutes and you forget so many things...

I ran docker compose build and when that was complete, ran npm start...

It looks like there is a new error in the npm run db:reset command. The error message suggests that supabase start is not running:

PS D:\dev\e2b> npm start --debug

> [email protected] start
> docker compose build && (npm run db:reset ; npm run db:start && docker compose up)

[+] Building 0.6s (38/38) FINISHED
 => [e2b/app:latest internal] load build definition from Dockerfile                                                0.0s
 => => transferring dockerfile: 32B                                                                                0.0s
 => [e2b/app:latest internal] load .dockerignore                                                                   0.0s
 => => transferring context: 35B                                                                                   0.0s
 => [e2b/api:latest internal] load build definition from Dockerfile                                                0.0s
 => => transferring dockerfile: 32B                                                                                0.0s
 => [e2b/api:latest internal] load .dockerignore                                                                   0.0s
 => => transferring context: 35B                                                                                   0.0s
 => [e2b/app:latest internal] load metadata for docker.io/library/node:lts-slim                                    0.5s
 => [e2b/api:latest internal] load metadata for docker.io/nikolaik/python-nodejs:python3.10-nodejs18-slim          0.4s
 => [e2b/api:latest builder 1/7] FROM docker.io/library/node:lts-slim@sha256:b8a9ad50d8833a2aede22170a517e64c7977  0.0s
 => [e2b/app:latest internal] load build context                                                                   0.0s
 => => transferring context: 7.45kB                                                                                0.0s
 => [e2b/api:latest internal] load build context                                                                   0.0s
 => => transferring context: 8.43kB                                                                                0.0s
 => [e2b/api:latest stage-1  1/11] FROM docker.io/nikolaik/python-nodejs:python3.10-nodejs18-slim@sha256:40646fa2  0.0s
 => CACHED [e2b/app:latest builder 2/7] WORKDIR /app                                                               0.0s
 => CACHED [e2b/app:latest builder 3/7] COPY package.json package-lock.json* ./                                    0.0s
 => CACHED [e2b/app:latest builder 4/7] COPY prisma/schema.prisma ./prisma/schema.prisma                           0.0s
 => CACHED [e2b/app:latest builder 5/7] RUN npm ci                                                                 0.0s
 => CACHED [e2b/app:latest builder 6/7] COPY . .                                                                   0.0s
 => CACHED [e2b/app:latest builder 7/7] RUN npm run build                                                          0.0s
 => CACHED [e2b/app:latest runner 3/5] COPY --from=builder /app/public ./public                                    0.0s
 => CACHED [e2b/app:latest runner 4/5] COPY --from=builder /app/.next/standalone ./                                0.0s
 => CACHED [e2b/app:latest runner 5/5] COPY --from=builder /app/.next/static ./.next/static                        0.0s
 => [e2b/api:latest] exporting to image                                                                            0.1s
 => => exporting layers                                                                                            0.0s
 => => writing image sha256:082eca97c6339310a63806af752f88f40e5cde4333d4aa66e425fd63d7adc47f                       0.0s
 => => naming to docker.io/e2b/app:latest                                                                          0.0s
 => => writing image sha256:0709a99a52a1ea07b0964560b4c85239ed22fa76e895e4038947df4eeccb7141                       0.0s
 => => naming to docker.io/e2b/api:latest                                                                          0.0s
 => CACHED [e2b/api:latest stage-1  2/11] RUN poetry config virtualenvs.in-project true                            0.0s
 => CACHED [e2b/api:latest stage-1  3/11] WORKDIR /app                                                             0.0s
 => CACHED [e2b/api:latest stage-1  4/11] COPY pyproject.toml poetry.lock ./                                       0.0s
 => CACHED [e2b/api:latest stage-1  5/11] RUN --mount=type=cache,target=/home/.cache/pypoetry/cache     --mount=t  0.0s
 => CACHED [e2b/api:latest stage-1  6/11] COPY . ./                                                                0.0s
 => CACHED [e2b/api:latest stage-1  7/11] RUN rm -rf ./playground                                                  0.0s
 => CACHED [e2b/api:latest stage-1  8/11] WORKDIR /playground                                                      0.0s
 => CACHED [e2b/api:latest playground 2/9] WORKDIR /playground                                                     0.0s
 => CACHED [e2b/api:latest playground 3/9] COPY playground/package.json playground/package-lock.json ./            0.0s
 => CACHED [e2b/api:latest playground 4/9] RUN npm ci                                                              0.0s
 => CACHED [e2b/api:latest playground 5/9] COPY playground/tsconfig.json ./                                        0.0s
 => CACHED [e2b/api:latest playground 6/9] COPY playground/tsoa.json ./                                            0.0s
 => CACHED [e2b/api:latest playground 7/9] COPY playground/scripts/build.js ./scripts/build.js                     0.0s
 => CACHED [e2b/api:latest playground 8/9] COPY playground/src ./src                                               0.0s
 => CACHED [e2b/api:latest playground 9/9] RUN npm run build                                                       0.0s
 => CACHED [e2b/api:latest stage-1  9/11] COPY --from=playground ./playground/node_modules ./node_modules          0.0s
 => CACHED [e2b/api:latest stage-1 10/11] COPY --from=playground ./playground/lib ./lib                            0.0s
 => CACHED [e2b/api:latest stage-1 11/11] WORKDIR /app                                                             0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

> [email protected] db:reset
> npx --yes supabase db reset ; npm run db:start

Error: supabase start is not running.
Try rerunning the command with --debug to troubleshoot the error.

There's no additional debug information given using npm start --debug or npm run db:reset --debug

Found this stackexchange https://stackoverflow.com/questions/75710971/supabase-start-on-windows-failing, but no joy there either.

industriaditat avatar Apr 25 '23 21:04 industriaditat

If you are running npm start for the first time the error should be there but immediately after that the Supabase should be starting. The ; between the commands should make it so the error in this one command doesn't cancel the whole command chain.

Did you cancel the npm start immediately after you saw the error or was it somehow (Windows?) canceled automatically?

The --debug is also referring to the supabase db reset command not to our npm start.

ValentaTomas avatar Apr 25 '23 22:04 ValentaTomas

Interesting... it definitely sounds like a Windows-specific error then -- command prompt and terminal are both exiting after the error, I'm not manually cancelling the process.

Curious to see if others have similar issues. I'll keep at it and report back. Thanks again @ValentaTomas !

industriaditat avatar Apr 26 '23 19:04 industriaditat

That would be great! You can probably try:

docker compose build && (npm run db:reset || true && npm run db:start && docker compose up)

instead of the npm start command.

ValentaTomas avatar Apr 26 '23 19:04 ValentaTomas

That would be great! You can probably try:

docker compose build && (npm run db:reset || true && npm run db:start && docker compose up)

instead of the npm start command.

Same issue here, running on Windows 10. Same exact result when trying to directly execute docker compose build && (npm run db:reset || true && npm run db:start && docker compose up)

However, a simple npx supabase start updated supabase packages to their latest versions and following that, successfully started. Then, running npm start was able to create the container as intended.

@industriaditat ;)

ghost avatar May 02 '23 14:05 ghost

Great find @voxitme! Can you please try if using npx [email protected] start (you may need to stop the db first with npx supabase stop first) works on Windows? We may be able to fix it for everybody this way.

ValentaTomas avatar May 02 '23 16:05 ValentaTomas

Great find @voxitme! Can you please try if using npx [email protected] start (you may need to stop the db first with npx supabase stop first) works on Windows? We may be able to fix it for everybody this way.

Sorry for the delay. I'm sorry though as I can't event manage to start the right version :/

C:\Users\user\Downloads\e2b-main>npx [email protected] start
Applying migration 1680452567_name.sql...
                                         Seeding data supabase\seed.sql...
Started supabase local development setup.

         API URL: http://localhost:54321
          DB URL: postgresql://postgres:postgres@localhost:54322/postgres
      Studio URL: http://localhost:54323
    Inbucket URL: http://localhost:54324
.
.
.

C:\Users\user\Downloads\e2b-main>npx supabase -v
1.57.3

ghost avatar May 09 '23 13:05 ghost

@voxitme I pushed an update to main with the Supabase version already changed in package.json scripts.

Can you pull the changes abd do:

npm run stop

then

npm start

and check if everything works?

ValentaTomas avatar May 09 '23 14:05 ValentaTomas

Yeah everything works out of the box running the latest main branch. Good job!

ghost avatar May 09 '23 15:05 ghost