How to edit pre-deploy script?

I tried deploying a new Meteor app to Galaxy, but the deploy failed because I need to run some custom build steps instead of the default meteor npm install --production command (f.e. I need to run meteor npm install && meteor npm run build && meteor npm clean-install --omit=dev to install dev dependencies, build, and finally remove dev dependencies).

I cannot figure out for the life of me where to edit the deploy script after I’ve already made the app.

Where can we edit the pre-deploy script?

I was able to create a new app deployment with a new meteorapp.com subdomain to try out a new build command, and that worked. But I cannot figure out how to modify the pre-deploy command for the original app (now I have two apps).

Hello @trusktr

What you can try is modifying the build process using npm lifecycle scripts in your package.json:

{
  "scripts": {
    "preinstall": "echo 'Running pre-installation...' && mkdir -p ./uploads ./logs",
    "postinstall": "meteor npm run build && echo '✔ Build complete!'"
}
}

The flow works like this:

preinstall → runs before npm install
install → Galaxy installs its dependencies
postinstall → runs after npm install

This way you can inject any custom build steps you need without overriding Galaxy’s fixed deployment command.
If you run into issues, you can also reach out via the Galaxy support chat, it’s usually the fastest way to get help.

Best Regards,

2 Likes

Thanks! That could be useful. The default script that Galaxy runs is with the --production flag though, so meteor npm run build may not work in that case.

I found the build command is available to edit in the app’s “Push to Deploy” section too, here:


Note for stumblers, I am using clean-install for the final step. It is better to use meteor npm clean-install than meteor npm install because the latter will update dependencies and possibly break your app during deployment.

I.e. don’t so what my screenshot shows, this is better:

meteor npm clean-install && meteor npm run build && meteor npm clean-install --omit=dev

The second clean-install with --omit=dev will re-create node_modules without any dev dependencies, so that for example you won’t publish any unnecessary build tools to production every time.

1 Like

@philippeoliveira Looks like there’s a bug in the Galaxy UI: I cannot save any edits in the Push to Deploy view. I get this error:

Invalid configuration
The app configuration is invalid. Please check your inputs: $.appConfiguration.webAppSettings.appName App name must be at least 3 characters long

The app name is not shown anywhere in the view either:

Great approach and thanks for sharing.

I’ve escalated your case to our support team. You’ll receive updates by email from our support system

1 Like