I do have one Flutter web app, but because of our workflow we use multiple Firebase projects (dev, stage, prod) for hosting. This wouldn't be a big deal, if I don't need different index.html file.
Sadly we use Google SignIn and this will need a meta google-signin-client_id key. This differs between the projects.
What's the best practice to setup this project, so a CI/CD can deploy it without any changes to the index.html before upload? Is this even possible yet?
My own solution, that I found somewhere:
create flavor folders (eg. /web_flavors/dev and /web_flavors/prod)
create a script, which copy the index.html from that flavor folders into /web before the compile
This way you will always have the right configuration within you build pipeline.
My only "problem" is, that I have to maintain the two files, if I need more HTML/JScript code in the index.html.
Related
I am using Nuxt.js for my web applications but never used the full static generator until now. My CI/CD pipeline builds and deploys a docker image containing of an nginx image with the static generated Nuxt.js app. My problem now is that I can not figure out how to use and load an app configuration file. Of course I could define all environment variables (like API_URL) during the build process but then i would have to separate images for each environment which would be unfortune.
My approach that I have in mind would be creating a config.json file and maybe having nginx deal with that but how can I tell my web application where he should look for the settings file?
My guess is that maybe people using webpack have come around this problem and know how to deal with it.
I have tried to look into this before.
The TLDR is that you cannot have on-runtime variables for the target: static build, especially with the way how some modules are made.
More info on this Github issue: https://github.com/nuxt/nuxt.js/issues/5100
So yeah, it comes down to have some dynamic webpack configs via your CI/CD, this is how my team handles it at least.
I have 2 different projects that I'm working on concurrently. I worked on the 1st project and have a native index.js file for that project. Then, I wanted to write Cloud Functions' code for the 2nd project. So, when I typed 'firebase init functions', it is saying that there's a default project that's selected (even after typing "firebase use project-id"). How do I rectify this?
PS: I completed the whole sequence once and the index.js file got overwritten. Luckily for me, I had a back up for the 1st project.
Edit 2: I changed directories and created a project but it overwrote the index.js file once again in the 'functions' folder. How to fix this? Should I navigate out of the home directory itself?
Configure Multiple Projects
The Web and Admin SDKs are configured by directly passing values to
their initialization functions. For these SDK, you can use a runtime
check to select development or production configuration variables.
On your development machine / project build out each app under a unique folder.
I am not 100% sure to understand the problem but here are two possible scenarios:
1/ You are working in a specific project, writing Cloud Functions (i.e. modifying the index.js file) and you want to work on another totally different project. Just create a new directory (outside of the current project) and initialize a new project there, as explained in the doc here: "https://firebase.google.com/docs/cli/#initializing_a_project_directory"
2/ You are working in a specific project, writing Cloud Functions (i.e. modifying the index.js file) and you want to deploy the same code to another Firebase project. Just do firebase use <alias_or_project_id> as you have mentioned and then firebase deploy (or firebase deploy --only functions). Of course, in this scenario, you may need to adapt some other parts of your code when swapping from one project to the other, like for example the JavaScript config object.
If this answer does not answer your problem, please give some more details.
I have a newbie question concerning the architecture of my app and what practice is better.
I have a Vue project, lets call it frontendProject (it does not really matter as my problem would have been the same with another framework) with all my file for the frontend of my website.
I recently discover all hidden feature of firebase (like function, deploy etc).
My question is simple, should i use Firebase CLI to install all functionnality like deploy, back end function etc IN the folder frontendProject OR should i create a new project dedicated for firebase and the backend, lets call it backendProject.
What is making me hesitate is the fact that i can deploy wathever is in a folder (which i pointed on dist from vue) in the firebase project, and i don't know if there will be new feature by the futur that need the firebase project to be mix with the frontend. But i'm not sure if this can mess up the project. The front end build only take the "src" folder to build if i'm right ? Which mean i'm not building useless file from firebas project when i build with vue.
If i'm not clear on any point don't hesitate to tell me.
Thanks in advance from the community
Answer from #MichaelBleigh
In root of the project set up firebase,and then put VueJs project in a web folder, then in the firebase.json, point the dist folder of vuejs so that you can deploy easily your project on firebase host
I have a solution with a fair few projects, 3 of them web-based (WCF in IIS / MVC site). When the solution builds, it dumps each of the components of this distributed system in a 'Build' folder. Running the 'configurator' part of the whole output will set up the system in the cloud automatically. It's very neat :) However, the Web Deploy Projects are a major pain. They "build" (i.e. deploy) every, single, time I build - even when no changes have been made to their respective projects.
Changed a single line of code? Look forward to waiting around a minute for the 3 web projects to redeploy.
[These projects are VERY straightforward at the moment - two have a single .svc and one .ashx file - the other is an MVC app with ~5 views]
I realise I can change solution configurations to not 'build' them, but I've been doing that and it's very easy to log on the next day and forget about it, and spend a couple of hours tracking down bugs in distributed systems due to something simply having not been built.
Why I use Web Deploy Projects? Well, because I need all pages + binaries from the web project. The build output for the project itself is the 'bin' folder, so no pages. The entire project folder? It has .cs, .csproj and other files I don't want included.
This will be building on build servers eventually, but it's local at the moment. But I want a quick way of getting the actual output files from the web project to my target folder. Any ideas?
Not sure if this will help in your situation, (plug for own project coming up), but I am working on a project to help ease IIS deployments:
https://github.com/twistedtwig/AutomatedDeployments
The idea being you can use config files for IIS (app Pool, applications and websites) to automate the creation and update of sites locally (dev machines) or remotely (test and production machines).
It is still a work in progress but is ready to be used in production systems.
using the package creation as a post build step might get you closer to what you want, (don't believe it includes all the extra files), but that would still build it each time, (although if code hasn't changed it should not rebuild unless you choose rebuild all projects).
In the end I created a utility/tool which, given a project file, XCOPYies the project folder for the web project to a target location, then looks in said project file and deletes anything that doesn't have Build Action set to Content. Very quick and effective.
I know it is still in RC but VS2012 does have a neat feature when doing publish that it detects the changes and publishes only those. Might be something a little deeper down in the build where it does an automatic publish too.
You can take a look to the Octopus project: http://octopusdeploy.com/
Deployment based on nuget packages.
I currently have my resources (images) in ...
C:\inetpub\wwwroot\images
I also have the images in the same location on my production server. How can I set it up so that I don't have to constantly sync up the folders? Seems like an easy thing but I'm not sure...
Any other information let me know and I will provide. Thanks!
Why don't you include them in your web project? That way when you deploy the web project the images are included by default :)
You can also use one of SCM's such as SVN or GIT to keep files in sync, if you don't want each time redeploy your application. But you should "checkout" to synchronize files or make a .bat file which will do that automatically.