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

Fix first-time run of docker_dev.sh #11779

Merged
merged 3 commits into from
Jan 15, 2025
Merged

Conversation

AJGranowski
Copy link
Contributor

@AJGranowski AJGranowski commented Jan 9, 2025

What are these changes?

This change makes octane commands wait a bit for manifest.json to exist if it's missing.

Why are these changes being made?

The first run of bin/docker_dev.sh causes both nginx and php-dusk fail.

php:

Exception
The manifest does not exist.
at app/Singletons/AssetsManifest.php:22
   18▕     {
   19▕         $manifestPath = public_path('assets/manifest.json');
   20▕
   21▕         if (!file_exists($manifestPath)) {
➜ 22▕             throw new Exception('The manifest does not exist.');
   23▕         }
   24▕
   25▕         $this->manifest = json_decode(file_get_contents($manifestPath), true);
   26▕     }
1   app/Providers/AppServiceProvider.php:96
    App\Singletons\AssetsManifest::__construct()

php-dusk:

php-dusk exited with code 157

nginx:

[emerg] host not found in upstream "php-dusk" in /etc/nginx/conf.d/default.conf:53
nginx exited with code 1

Successive runs pass and serve the website, suggesting a race condition in docker compose up. Running docker compose run --rm assets beforehand seems to fix this.

@nanaya
Copy link
Collaborator

nanaya commented Jan 9, 2025

what should be done is adding health check on assets service, checking for existence of the manifest file.

@AJGranowski
Copy link
Contributor Author

I'll take a look into that.

@AJGranowski AJGranowski changed the title Add asset build step to docker_dev.sh Fix first-time run of docker_dev.sh Jan 9, 2025
@AJGranowski AJGranowski marked this pull request as draft January 9, 2025 10:04
@AJGranowski
Copy link
Contributor Author

Hmm, looks like things break if I just use health checks... I think assets depends on composer install?

PHP Warning:  require(/app/vendor/autoload.php): Failed to open stream: No such file or directory in /app/artisan on line 18
PHP Fatal error:  Uncaught Error: Failed opening required '/app/vendor/autoload.php' (include_path='.:/usr/share/php') in /app/artisan:18

Extracting localizations...
[webpack-cli] Error: ENOENT: no such file or directory, open '/app/resources/builds/messages.json'
    at Object.openSync (node:fs:573:18)
    at Object.readFileSync (node:fs:452:35)
    at getAllMesssages (/app/resources/js/cli/generate-localizations.js:36:22)
    at extractLanguages (/app/resources/js/cli/generate-localizations.js:20:20)
    at Object.generateLocalizations [as callback] (/app/resources/js/cli/generate-localizations.js:66:21)
    at /app/webpack.config.js:292:40
    at Array.forEach (<anonymous>)
    at configFunction (/app/webpack.config.js:292:11)
    at loadConfigByPath (/app/node_modules/webpack-cli/lib/webpack-cli.js:1445:37)
    at async WebpackCLI.loadConfig (/app/node_modules/webpack-cli/lib/webpack-cli.js:1515:38) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/app/resources/builds/messages.json'
}
error Command failed with exit code 2.

@nanaya
Copy link
Collaborator

nanaya commented Jan 9, 2025

maybe add a compose install before the yarn install in the watch command

@AJGranowski AJGranowski marked this pull request as ready for review January 9, 2025 19:47
@AJGranowski
Copy link
Contributor Author

Yep, that seems to work. Let me know if you were thinking of a different approach.

Copy link
Collaborator

@nanaya nanaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking again at how the service is actually used, maybe just monitor for the file (with a while loop) inside the octane specific entrypoint function instead

(also, moving the composer install before setting up github token for it is bad)

@AJGranowski
Copy link
Contributor Author

Were you thinking of something like this latest change?

@AJGranowski AJGranowski requested a review from nanaya January 13, 2025 04:58
app/Singletons/AssetsManifest.php Outdated Show resolved Hide resolved
@AJGranowski
Copy link
Contributor Author

Migrated the manifest check to run.sh. On my machine, the script waits between 15 and 70 seconds for the manifest file to generate.

Here's what the stderr output looks like:
stderr_log

@AJGranowski AJGranowski requested a review from nanaya January 14, 2025 23:32
docker/development/run.sh Outdated Show resolved Hide resolved
docker/development/run.sh Outdated Show resolved Hide resolved
docker/development/run.sh Outdated Show resolved Hide resolved
docker/development/run.sh Outdated Show resolved Hide resolved
docker/development/run.sh Outdated Show resolved Hide resolved
docker/development/run.sh Outdated Show resolved Hide resolved
Copy link
Collaborator

@nanaya nanaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also please squash the commits

docker/development/run.sh Outdated Show resolved Hide resolved
docker/development/run.sh Outdated Show resolved Hide resolved
@notbakaneko
Copy link
Collaborator

What's wrong with putting an empty manifest.json and letting the workers reload once the new one finishes building, instead of jumping through all the hoops checking for the file?

@nanaya
Copy link
Collaborator

nanaya commented Jan 15, 2025

that's a good point 🤔

@AJGranowski
Copy link
Contributor Author

That seems to work! I just get served some error pages until it's finished.

screenshot

@AJGranowski
Copy link
Contributor Author

Here's an alternative PR:

Either work, it just depends on the UX you're looking for when starting (either getting served nothing, or an error page during startup).

Copy link
Collaborator

@nanaya nanaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just go with this one for now (there's different problem with the other one in its current state and I would probably take a different approach)

@nanaya nanaya enabled auto-merge January 15, 2025 09:37
@AJGranowski
Copy link
Contributor Author

AJGranowski commented Jan 15, 2025

Sounds good! Thank you for being patient with me.

@nanaya nanaya merged commit a3e3e2d into ppy:master Jan 15, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants