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

Build fail with copyfiles #6066

Closed
sctgraham opened this issue Apr 26, 2024 · 6 comments
Closed

Build fail with copyfiles #6066

sctgraham opened this issue Apr 26, 2024 · 6 comments
Assignees
Labels
[possible-bug] Possible bug which hasn't been reproduced yet

Comments

@sctgraham
Copy link

sctgraham commented Apr 26, 2024

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 sctgraham added the [possible-bug] Possible bug which hasn't been reproduced yet label Apr 26, 2024
@aaronmarkle
Copy link

I am running into this today too.

@denolfe
Copy link
Member

denolfe commented Apr 26, 2024

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

@denolfe denolfe self-assigned this Apr 26, 2024
@sctgraham
Copy link
Author

@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.

@denolfe
Copy link
Member

denolfe commented Apr 26, 2024

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.

@kaptankorkut
Copy link

kaptankorkut commented Apr 30, 2024

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
Copy link
Author

sctgraham commented May 1, 2024

@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",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[possible-bug] Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

4 participants