kentcdodds / kentcdodds.com

My personal website
https://kentcdodds.com
Other
2.29k stars 617 forks source link

Local Docker Build Failing #392

Closed benbjohnson closed 1 year ago

benbjohnson commented 1 year ago

I'm trying to build a local copy of the Dockerfile and pushing that to a Fly app for testing. It seems to work when I have it build remotely on Fly.io's build servers but it's failing when I run a local docker build .

I'm digging into the issue but I figured I'd post it here too in case you've seen the issue as well:

$ docker build .
[+] Building 55.0s (20/41)                                                                                                                                 
 => [internal] load build definition from Dockerfile                                                                                                  0.0s
 => => transferring dockerfile: 2.45kB                                                                                                                0.0s
 => [internal] load .dockerignore                                                                                                                     0.0s
 => => transferring context: 63B                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/node:18-bullseye-slim                                                                              1.0s
 => [auth] sharing credentials for registry-1.docker.io                                                                                               0.0s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                           0.0s
 => CACHED FROM docker.io/library/litefs-local:latest                                                                                                 0.0s
 => [internal] load build context                                                                                                                     0.9s
 => => transferring context: 51.62MB                                                                                                                  0.8s
 => [base 1/2] FROM docker.io/library/node:18-bullseye-slim@sha256:b9c3c98eb7cf4a45daceac4cb12880f4529889f6f39a59edc0661aea0bb0880b                   0.0s
 => CACHED [base 2/2] RUN apt-get update && apt-get install -y fuse openssl ffmpeg sqlite3 ca-certificates procps                                     0.0s
 => CACHED [production-deps 1/5] RUN mkdir /app/                                                                                                      0.0s
 => CACHED [production-deps 2/5] WORKDIR /app/                                                                                                        0.0s
 => CACHED [build 1/8] RUN mkdir /app/                                                                                                                0.0s
 => CACHED [build 2/8] WORKDIR /app/                                                                                                                  0.0s
 => CACHED [stage-4  1/16] RUN echo "#!/bin/sh\nset -x\nsqlite3 $DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli  0.0s
 => CACHED [stage-4  2/16] RUN echo "#!/bin/sh\nset -x\nsqlite3 $CACHE_DATABASE_PATH" > /usr/local/bin/cache-database-cli && chmod +x /usr/local/bin  0.0s
 => CACHED [stage-4  3/16] RUN mkdir /app/                                                                                                            0.0s
 => CACHED [stage-4  4/16] WORKDIR /app/                                                                                                              0.0s
 => CACHED [deps 3/5] ADD package.json .npmrc package-lock.json ./                                                                                    0.0s
 => CACHED [deps 4/5] ADD other/patches ./other/patches                                                                                               0.0s
 => ERROR [deps 5/5] RUN npm install                                                                                                                 53.0s
------                                                                                                                                                     
 > [deps 5/5] RUN npm install:                                                                                                                             
#17 8.925 npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated                                                             
#17 9.845 npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility                          
#17 9.957 npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated                                                
#17 10.09 npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
#17 10.27 npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
#17 10.37 npm WARN deprecated rollup-plugin-virtual@1.0.1: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-virtual.
#17 10.41 npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
#17 10.67 npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
#17 14.14 npm WARN deprecated hast@1.0.0: Renamed to rehype
#17 19.06 npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
#17 23.10 npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
#17 26.06 npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
#17 26.08 npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
#17 52.79 npm notice 
#17 52.79 npm notice New major version of npm available! 8.19.2 -> 9.1.3
#17 52.79 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.1.3>
#17 52.79 npm notice Run `npm install -g npm@9.1.3` to update!
#17 52.79 npm notice 
#17 52.79 npm ERR! code 1
#17 52.79 npm ERR! path /app/node_modules/@prisma/engines
#17 52.79 npm ERR! command failed
#17 52.79 npm ERR! command sh -c -- node scripts/postinstall.js
#17 52.79 npm ERR! node:internal/process/promises:288
#17 52.79 npm ERR!             triggerUncaughtException(err, true /* fromPromise */);
#17 52.79 npm ERR!             ^
#17 52.79 npm ERR! 
#17 52.79 npm ERR! Error: invalid code lengths set
#17 52.79 npm ERR!     at Zlib.zlibOnError [as onerror] (node:zlib:189:17) {
#17 52.79 npm ERR!   errno: -3,
#17 52.79 npm ERR!   code: 'Z_DATA_ERROR',
#17 52.79 npm ERR!   attemptNumber: 1,
#17 52.79 npm ERR!   retriesLeft: 2
#17 52.79 npm ERR! }
#17 52.79 npm ERR! 
#17 52.79 npm ERR! Node.js v18.12.1
#17 52.79 
#17 52.79 npm ERR! A complete log of this run can be found in:
#17 52.79 npm ERR!     /root/.npm/_logs/2022-12-04T19_33_56_343Z-debug-0.log
------
executor failed running [/bin/sh -c npm install]: exit code: 1
kentcdodds commented 1 year ago

Yep, I've noticed this as well and I just decided to ignore it πŸ™ƒ I never build locally myself.

benbjohnson commented 1 year ago

I think I got it working although I'm not sure how. It may be that I cleared out all my node_modules install from macOS and re-did it in Linux using Vagrant. Maybe there are files copied in from there?

kentcdodds commented 1 year ago

That shouldn't affect it should it? Isn't the container isolated from the host machine?

benbjohnson commented 1 year ago

Yeah, typically. You can use ADD to add files from the host machine. I was just taking a stab in the dark as to what fixed it. I have no idea. :)

kentcdodds commented 1 year ago

Well I'm glad you got it working πŸ˜…

kentcdodds commented 1 year ago

@benbjohnson ChatGPT helped me fix this πŸ˜‚

benbjohnson commented 1 year ago

ahahaha πŸ˜‚