epicweb-dev / epic-stack

This is a Full Stack app starter with the foundational things setup and configured for you to hit the ground running on your next EPIC idea.
https://www.epicweb.dev/epic-stack
MIT License
4.22k stars 348 forks source link

Error in direct deployment of new epic-stack - as well as deployment through Github actions #544

Closed bjornbrasse closed 7 months ago

bjornbrasse commented 7 months ago

Hi, When setting up a new project with npx create-epic-app@latest I get an error when doing a direct deploy on fly. I'm logged in already, so don't expect a problem there. Looks like the problem occurs during build:icons. And a little before that the RUN npm prune --omit=dev gets canceled.

Trying deployment again later with Gihub actions - FLY_API_TOKEN set - results in the same errors.

Could you find out what's happening here?? Greatly appreciated!

Grtz. B.

These are the logs:

? Would you like to setup deployment right now? Yes
? You're logged in as *****@***.nl. Proceed? Yes
πŸ”Ž Determining the best region for you...
? Which region would you like to deploy to? The closest to you is ams. Amsterdam, Netherlands (ams)
πŸ₯ͺ Creating app test-2-80e0 and test-2-80e0-staging...
? Select Organization: ***** (personal)
New app created: test-2-80e0-staging
? Select Organization: *****(personal)
New app created: test-2-80e0
🀫 Setting secrets in apps
Secrets are staged for the first deployment
Secrets are staged for the first deployment
πŸ”Š Creating volumes. Answer "yes" when it warns you about downtime. You can add more volumes later (when you actually start getting paying customers οΏ½).
Warning! Every volume is pinned to a specific physical host. You should create two or more volumes per application to avoid downtime. Learn more at https://fly.io/docs/reference/volumes/
? Do you still want to use the volumes feature? No
Warning! Every volume is pinned to a specific physical host. You should create two or more volumes per application to avoid downtime. Learn more at https://fly.io/docs/reference/volumes/
? Do you still want to use the volumes feature? No
πŸ”— Attaching consul
Secrets are staged for the first deployment
Secrets are staged for the first deployment
? Would you like to deploy right now? (This will take a while, and you can always wait until you push to GitHub 
instead). Yes
πŸš€ Deploying apps...
  Moving Dockerfile and .dockerignore to root (temporarily)
  Starting with staging
==> Verifying app config
Validating /Users/bjorn/Documents/Coding/test-2/fly.toml
Platform: machines
βœ“ Configuration is valid
--> Verified app config
==> Building image
Remote builder fly-builder-ancient-dew-5946 ready
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 68.7s (19/31)                                                                                        
 => [internal] load build definition from Dockerfile                                                         0.0s
 => => transferring dockerfile: 2.17kB                                                                       0.0s
 => [internal] load .dockerignore                                                                            0.0s
 => => transferring context: 176B                                                                            0.0s
 => [internal] load metadata for docker.io/library/node:18-bookworm-slim                                     0.6s
 => [internal] load build context                                                                            3.9s
 => => transferring context: 33.09MB                                                                         3.9s
 => FROM docker.io/flyio/litefs:0.5.8                                                                        0.7s
 => => resolve docker.io/flyio/litefs:0.5.8                                                                  0.3s
 => => sha256:de0072dbb9be4207da2793f26c17a0fb46797e5aa4550928e954dfbd2d94ca56 5.01MB / 5.01MB               0.1s
 => => sha256:5cb2cf42ff707049ab9384c4241086c48ed899ded86076b166ddf9c05c701887 2.38kB / 2.38kB               0.0s
 => => sha256:1f778922b62f0968f52fc14ebb55a8d8a34f998d0b19d3d49c1ba4c7d510306d 481B / 481B                   0.0s
 => => sha256:88d125d4ee7debac7a3f63cf305ddc42f3acf956180a253a937712d9169e7616 1.36kB / 1.36kB               0.0s
 => => extracting sha256:de0072dbb9be4207da2793f26c17a0fb46797e5aa4550928e954dfbd2d94ca56                    0.3s
 => [base 1/2] FROM docker.io/library/node:18-bookworm-slim@sha256:4e5a6919eb5d4633ec1ce1c470e74d428c36931a  3.4s
 => => resolve docker.io/library/node:18-bookworm-slim@sha256:4e5a6919eb5d4633ec1ce1c470e74d428c36931ae3243  0.0s
 => => sha256:be65943961fdd577b5591ede55df88e0e41da7e6bd48cd860eeed42601271dcb 3.36kB / 3.36kB               0.1s
 => => sha256:9e2f83459c51bda8326ca2abebabc10a5571f13ed565eb5aae8bbe2df181ce23 38.57MB / 38.57MB             0.8s
 => => sha256:f9411d9c44a992fd488fe6d0c5b15aaa80d5e69f45df9d822a55b2520e14b351 2.68MB / 2.68MB               0.2s
 => => sha256:1fe9161939c7971686011d4f1599370866bb2ea33d237f9aa2a06c1b2502f1bd 453B / 453B                   0.0s
 => => sha256:4e5a6919eb5d4633ec1ce1c470e74d428c36931ae3243d1e02748a939ee4ab42 1.21kB / 1.21kB               0.0s
 => => sha256:28b1bfae5e6454793e89934c79ebf9c18dc844da8d6af3617c80bb2d2ccc6d53 1.37kB / 1.37kB               0.0s
 => => sha256:5c0278530100ca02882fb51a9c56c360ac55e40cdaf892138aef243478157dfa 7.62kB / 7.62kB               0.0s
 => => sha256:1f7ce2fa46ab3942feabee654933948821303a5a821789dddab2d8c3df59e227 29.15MB / 29.15MB             0.5s
 => => extracting sha256:1f7ce2fa46ab3942feabee654933948821303a5a821789dddab2d8c3df59e227                    1.1s
 => => extracting sha256:be65943961fdd577b5591ede55df88e0e41da7e6bd48cd860eeed42601271dcb                    0.0s
 => => extracting sha256:9e2f83459c51bda8326ca2abebabc10a5571f13ed565eb5aae8bbe2df181ce23                    1.3s
 => => extracting sha256:f9411d9c44a992fd488fe6d0c5b15aaa80d5e69f45df9d822a55b2520e14b351                    0.1s
 => => extracting sha256:1fe9161939c7971686011d4f1599370866bb2ea33d237f9aa2a06c1b2502f1bd                    0.0s
 => [base 2/2] RUN apt-get update && apt-get install -y fuse3 openssl sqlite3 ca-certificates                6.4s
 => [stage-4  1/14] RUN echo "#!/bin/sh\nset -x\nsqlite3 $DATABASE_URL" > /usr/local/bin/database-cli && ch  0.4s
 => [build 1/6] WORKDIR /myapp                                                                               0.0s
 => [deps 2/3] ADD package.json package-lock.json .npmrc ./                                                  0.0s
 => [deps 3/3] RUN npm install --include=dev                                                                43.2s
 => [stage-4  2/14] WORKDIR /myapp                                                                           0.0s
 => [build 2/6] COPY --from=deps /myapp/node_modules /myapp/node_modules                                     6.0s
 => [build 3/6] ADD prisma .                                                                                 0.0s
 => [production-deps 3/4] ADD package.json package-lock.json .npmrc ./                                       0.0s
 => CANCELED [production-deps 4/4] RUN npm prune --omit=dev                                                  5.0s
 => [build 4/6] RUN npx prisma generate                                                                      2.6s
 => [build 5/6] ADD . .                                                                                      0.6s
 => ERROR [build 6/6] RUN npm run build                                                                      1.6s
------
 > [build 6/6] RUN npm run build:
#0 0.658 
#0 0.658 > build
#0 0.658 > run-s build:*
#0 0.658 
#0 1.201 
#0 1.201 > build:icons
#0 1.201 > tsx ./other/build-icons.ts
#0 1.201 
#0 1.550 
#0 1.550 node:internal/process/esm_loader:40
#0 1.550       internalBinding('errors').triggerUncaughtException(
#0 1.550                                 ^
#0 1.550 Error: tsx must be loaded with --import instead of --loader
#0 1.550 The --loader flag was deprecated in Node v20.6.0
#0 1.550     at Q (file:///myapp/node_modules/tsx/dist/esm/index.mjs:1:1793)
#0 1.550     at Hooks.addCustomLoader (node:internal/modules/esm/hooks:202:24)
#0 1.550     at Hooks.register (node:internal/modules/esm/hooks:168:16)
#0 1.550     at async initializeHooks (node:internal/modules/esm/utils:167:5)
#0 1.550     at async customizedModuleWorker (node:internal/modules/esm/worker:104:24)
#0 1.550 
#0 1.550 Node.js v18.19.0
#0 1.570 ERROR: "build:icons" exited with 1.
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 1
Error: Command failed with exit code 1: fly deploy --app test-2-80e0-staging
    at makeError (file:///Users/bjorn/Documents/Coding/test-2/remix.init/node_modules/execa/lib/error.js:59:11)
    at handlePromise (file:///Users/bjorn/Documents/Coding/test-2/remix.init/node_modules/execa/index.js:124:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async setupDeployment (file:///Users/bjorn/Documents/Coding/test-2/remix.init/index.mjs:202:3)
    at async main (file:///Users/bjorn/Documents/Coding/test-2/remix.init/index.mjs:91:3)
    at async module.exports (/Users/bjorn/Documents/Coding/test-2/remix.init/index.js:3:2)
    at async runInitScriptStep (/Users/bjorn/.npm/_npx/5164864a48bff686/node_modules/create-remix/dist/index.js:475:5)
    at async Object.createRemix (/Users/bjorn/.npm/_npx/5164864a48bff686/node_modules/create-remix/dist/index.js:77:7) {
  shortMessage: 'Command failed with exit code 1: fly deploy --app test-2-80e0-staging',
  command: 'fly deploy --app test-2-80e0-staging',
  escapedCommand: 'fly deploy --app test-2-80e0-staging',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
Looks like something went wrong setting up deployment. Sorry about that. Check the docs for instructions on how to get deployment setup yourself (https://github.com/epicweb-dev/epic-stack/blob/main/docs/deployment.md).
Setup is complete. You're now ready to rock and roll 🐨

What's next?

- Start development with `npm run dev`
- Run tests with `npm run test` and `npm run test:e2e`

      βœ”  Template's remix.init script complete 

  done   That's it!

         Enter your project directory using cd ./test-2
         Check out README.md for development and deploy instructions.

         Join the community at https://rmx.as/discord
bjornbrasse commented 7 months ago

Running locally with npm run dev now results in the same error... The problem is in using "tsx" in the scripts. It also happens when running build:server.

Where is Node v20.6.0 coming from? I'm using nvm and my node is 18.19.0... ???

running command with prefix "de."

> predev
> npm run build:icons --silent

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^
Error: tsx must be loaded with --import instead of --loader
The --loader flag was deprecated in Node v20.6.0
    at Q (file:///Users/bjorn/Documents/Coding/kwestjan/node_modules/tsx/dist/esm/index.mjs:1:1793)
    at Hooks.addCustomLoader (node:internal/modules/esm/hooks:202:24)
    at Hooks.register (node:internal/modules/esm/hooks:168:16)
    at async initializeHooks (node:internal/modules/esm/utils:167:5)
    at async customizedModuleWorker (node:internal/modules/esm/worker:104:24)

Node.js v18.19.0
NPM command npm run dev -- failed with code 1
bjornbrasse commented 7 months ago

Could it have to do with this merge? https://github.com/epicweb-dev/epic-stack/pull/498 @xHomu ?

xHomu commented 7 months ago

I think this is actually a sly-cli issue, since i didn't end up bumping node to 20 in my pr. @jacobparis might be more informed with how sly uses tsx under the hood.

fcablik commented 7 months ago

Lol I was getting a little skeptical as I started getting this error on deploy of my already running app, where I just made some frontend edits since the previous day's successful deploy. Before that, I was getting ready to update my app's remix from 2.1 to 2.3 (but didn't as this issue appeared). Then I tried to get up and running a completely new epic-stack app, but the issue remained. So I guess this issue is happening somewhere between our apps and fly's services and not from any change in our apps..?

Edit: I am also using Node v18 (18.16.1), so I didn't understand where it gets the Node v20.6.0's deprecated reference.

YuriiF commented 7 months ago

I get the same error today when trying do deploy staging and production. I was able to fix it with bellow steps:

  1. change all node-version: 18 to node-version: 20 in .github/workflows/deploy.yml file.
  2. change package.json image
  3. remove node_modules and package-lock.json
  4. as i use .nvmrc i change my version of node to lts/hydrogen also
  5. run npm install
  6. git push origin dev - dev branch for staging build
  7. git push origin main - main branch for production build

Hope this helps

bjornbrasse commented 7 months ago

Worked for me, thanks @YuriiF !! Still obscure where this error came from, but perhaps it's time to up the node version. That's up to Kent of course...

kentcdodds commented 7 months ago

Yes. I think it's about time to upgrade. Thanks! Will do this soon. PR welcome!

thadtayo commented 7 months ago

I get the same error today when trying do deploy staging and production. I was able to fix it with bellow steps:

  1. change all node-version: 18 to node-version: 20 in .github/workflows/deploy.yml file.
  2. change package.json image
  3. remove node_modules and package-lock.json
  4. as i use .nvmrc i change my version of node to lts/hydrogen also
  5. run npm install
  6. git push origin dev - dev branch for staging build
  7. git push origin main - main branch for production build

Hope this helps

This alone did not work until I also updated the Dockerfile to pull in Node 20 as base. i.e.

from node:20-bookworm-slim as base
fcablik commented 7 months ago

@ all - Issue resolved in #545. Upgraded to node v20.