withastro / docs

Astro documentation
https://docs.astro.build/
MIT License
1.34k stars 1.5k forks source link

⚠️ When I try to use Astro DB with Turso (libsql) as db, I am unable to deploy in combination with Firebase Hosting as I cannot set --remote flag #9451

Closed javdl closed 1 month ago

javdl commented 1 month ago

https://docs.astro.build/en/guides/astro-db/#libsql

When I try to use Astro DB with Turso (libsql) as db, I am unable to deploy in combination with Firebase Hosting as described here: https://docs.astro.build/en/guides/deploy/google-firebase/

This, because I need to set the --remote flag on the astro build command, however, the deployment as described in https://docs.astro.build/en/guides/deploy/google-firebase/ does not accept extra flags for the build.

For context; This Astro site can be deployed to Firebase Hosting perfectly fine without using Astro DB & libsql with Turso. I understand this is a fairly new scenario since the discontinuing of Astro studio. My suggestion would be to also be able to trigger the --remote by using an ENV variable, as that does work with the firebase hosting deploy. (you can set a local sqlite file via ENV var, that does get picked up by the firebase build)

delucis commented 1 month ago

I believe you should be able to customize the build command in the firebase.json configuration file to add --remote, but I’ve never actually done this, so someone else might need to provide further context or perhaps that’s enough of a hint for you to figure something out!

javdl commented 1 month ago

That's correct, with predeploy you can like so:.

"hosting": {
  "predeploy": "npm run build --remote",

However, that does not work when you enable the web frameworks experiment to deploy Astro in SSR mode:npx firebase experiments:enable webframeworks as described here: https://docs.astro.build/en/guides/deploy/google-firebase/ The web frameworks mode does not accept any flags. I could of course deploy everything in a Cloud Run container, but still, this should be made to work too as it is the recommended way of deploying from the Astro docs, right?

sarah11918 commented 1 month ago

I will tag @Fryuni in here to see whether there is some more general advice/guidance we can give re: when flags are not accepted. If this is an issue with Firebase, maybe other platforms are affected, too? Is there something we can better do here to surface when this might be a problem?

Fryuni commented 1 month ago

You indeed can't configure arguments on Firebase's own config when using the web frameworks experiment. Firebase will just use the scripts from package.json, you can set them there:

{
  "scripts": {
-    "build": "astro build",
+    "build": "astro build --remote",
  }
}

If you want to build things for local use as well you can have an extra command:

{
  "scripts": {
    "build": "astro build --remote",
+    "build:local": "astro build"
  }
}
javdl commented 1 month ago

@Fryuni I think with the experiments on, Firebase doesn't do that, I tried to put it there but it didn't work.

sarah11918 commented 1 month ago

i'm going to close this as a docs issue, since docs do already recommend adding the build script that Fryuni mentioned above and I believe that is going to be our suggestion in general for most setups.

To continue troubleshooting a problem in your project, please do join our Discord https://astro.build/chat where people can offer support and look at your specific project with you, or you can provide feedback on the implementation in our feedback channel. If you believe there's a bug in Astro, you can also file an issue on the main Astro repo. But, I don't think there's anything about documentation that we would change here right now until we know what works with Firebase.

We are rewriting the Astro DB page to both remove the Studio content and make sure directions for connecting to your database are clear, and not contained in a Studio section. We will welcome feedback there once we have a PR open in case our instructions there don't work!