payload icon indicating copy to clipboard operation
payload copied to clipboard

Build fail with copyfiles

Open sctgraham opened this issue 10 months ago • 4 comments

Link to reproduction

No response

Describe the Bug

My build on payload cloud is failing due to the copyfiles command. However, the dependency is installed and the yarn command is running fine locally.

Thanks for any help on this ...

To Reproduce

This happened after upgrading my package dependencies. This is the payload cloud log output :

[2024-04-26T17:05:00] │ Running custom build command: yarn build
[2024-04-26T17:05:00] │ yarn run v1.22.22
[2024-04-26T17:05:00] │ $ yarn copyfiles && yarn build:payload && yarn build:server
[2024-04-26T17:05:00] │ $ copyfiles -u 1 "src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}" dist/
[2024-04-26T17:05:00] │ /bin/sh: 1: copyfiles: not found
[2024-04-26T17:05:00] │ error Command failed with exit code 127.
[2024-04-26T17:05:00] │ info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[2024-04-26T17:05:00] │ error Command failed with exit code 127.
[2024-04-26T17:05:00] │ info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[2024-04-26T17:05:00] │ building: exit status 127
[2024-04-26T17:05:00] │ ERROR: failed to build: exit status 1

Here are my package dependencies and scripts :

  "scripts": {
    "dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
    "build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
    "build:server": "tsc",
    "build": "yarn copyfiles && yarn build:payload && yarn build:server",
    "serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
    "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
    "generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
    "generate:graphQLSchema": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema",
    "generate": "yarn generate:graphQLSchema && yarn generate:types",
    "payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload"
  },
  "dependencies": {
    "@payloadcms/bundler-webpack": "^1.0.6",
    "@payloadcms/db-mongodb": "^1.3.2",
    "@payloadcms/plugin-cloud": "^3.0.0",
    "@payloadcms/plugin-redirects": "^1.0.1",
    "@payloadcms/plugin-seo": "^2.3.1",
    "@payloadcms/richtext-lexical": "^0.9.1",
    "@swc/core": "^1.3.103",
    "add": "^2.0.6",
    "cross-env": "^7.0.3",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "payload": "^2.14.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-i18next": "^14.1.1",
    "readline": "^1.3.0",
    "short-unique-id": "^5.0.3",
    "slugify": "^1.6.6",
    "util": "^0.12.5",
    "uuid": "^9.0.1",
    "yarn": "^1.22.21",
    "yjs": "^13.6.10"
  },
  "devDependencies": {
    "@types/express": "^4.17.9",
    "copyfiles": "^2.4.1",
    "nodemon": "^2.0.6",
    "ts-node": "^9.1.1",
    "typescript": "^4.8.4"
  },

Payload Version

2.14.1

Adapters and Plugins

bundler-webpack, db-mongodb, plugin-cloud, plugin-redirects, plugin-seo, richtext-lexical

sctgraham avatar Apr 26 '24 17:04 sctgraham

I am running into this today too.

aaronmarkle avatar Apr 26 '24 20:04 aaronmarkle

@sctgraham @aaronmarkle Are these brand new projects created from the interface or pre-existing projects just now seeing issues on recent deployments?

denolfe avatar Apr 26 '24 22:04 denolfe

@denolfe the latter : It was a local install that was configured and then pushed to the payload cloud. However, I was happily pushing changes without issue until today.

sctgraham avatar Apr 26 '24 22:04 sctgraham

Looks like there may have been some behavior changes in DO's platform: https://docs.digitalocean.com/products/app-platform/reference/buildpacks/nodejs/#specifying-devdependencies

You might need to follow these steps and change your build command in your Payload Cloud Dashboard to be the one defined.

This is just a workaround, we are actively working with them on a long-term solution.

denolfe avatar Apr 26 '24 23:04 denolfe

I swapped out 'copyfiles' with 'rsync' temporarily and named the npm command 'syncfiles'. Rsync comes pre-installed on most Linux distributions, simplifying the process.

"syncfiles": "rsync -ru --include='*/' --include='*.html' --include='*.css' --include='*.scss' --include='*.ttf' --include='*.woff' --include='*.woff2' --include='*.eot' --include='*.svg' --include='*.jpg' --include='*.png' --include='*.js' --exclude='*' src/ dist/",

The build script needs to be updated:

"build": "cross-env NODE_ENV=production yarn build:payload && yarn build:server && yarn syncfiles && yarn build:next",

kaptankorkut avatar Apr 30 '24 19:04 kaptankorkut

@denolfe yup that's it ! Thanks for that. This worked like a charm @kaptankorkut, many thanks. I'm now running into the issue described in #6062 and unfortunately the solution described there isn't working for me, bummer !

I swapped out 'copyfiles' with 'rsync' temporarily and named the npm command 'syncfiles'. Rsync comes pre-installed on most Linux distributions, simplifying the process.

"syncfiles": "rsync -ru --include='*/' --include='*.html' --include='*.css' --include='*.scss' --include='*.ttf' --include='*.woff' --include='*.woff2' --include='*.eot' --include='*.svg' --include='*.jpg' --include='*.png' --include='*.js' --exclude='*' src/ dist/",

The build script needs to be updated:

"build": "cross-env NODE_ENV=production yarn build:payload && yarn build:server && yarn syncfiles && yarn build:next",

sctgraham avatar May 01 '24 14:05 sctgraham

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Sep 07 '24 04:09 github-actions[bot]