Why does the .env file get added to build/web/assets? - flutter

I'm using flutter_dotenv to manage some API keys - https://pub.dev/packages/flutter_dotenv
According to the instructions I should add the .env file to assets in pubspec.yaml but when I run flutter build web it adds the .env file to the build for deployment. This doesn't seem correct to me because the .env file should not get deployed anywhere publicly from what I understand.

I had the same issue, and solved it by renaming .env.* files to env.*.
https://pub.dev/packages/flutter_dotenv#usage
Note: If deploying to web server, ensure that the config file is uploaded and not ignored. (Whitelist the config file on the server, or name the config file without a leading .)

Related

Flutter optional Assets

I'm building an app in Flutter, and I'm using the flutter-dotenv package so we can change things around on development time or testing time without changing the code.
I can see that for it to work I must include a .env asset in the pubspec YAML file, however, that .env file may or may not be there. Currently I'm just using an empty .env file, but I don't think this is ideal.
Is there any way to instruct the flutter build process to copy a file only if it exists?
Thanks!!

Failed to load asset at "assets/dotenv.develop" in flutter web

I am using .env file in flutter web.
Everything is OK when I run my project, locally on chrome and build apk.
But when I run my project in azure pipeline to deploy my flutter web, I get these errors:
GET https://***.net/assets/fonts/MaterialIcons-Regular.otf 404 (Not Found)
GET https://***.net/assets/.env.develop 404 (Not Found)
I tried running my project without .env file and everything was OK.
Also, I removed dot from the start of file name, from ".env" to "dotenv".
I added the file into the assets directory and include the file in the pubspec.yaml.
But didn't solve my issue.
Don't use .env as name for config file, use a name without "." Eg: dotenv
Here is the issue https://github.com/java-james/flutter_dotenv/issues/28

Why is the gcloud sdk's deploy command looking at my home directory for files?

I'm attempting to deploy a python server to Google App Engine.
I'm trying to use the gcloud sdk to do so.
It appears the command I need to use is gcloud app deploy.
I get the following error:
me#mymachine:~/development/some-app/backend$ gcloud app deploy
ERROR: (gcloud.app.deploy) Error Response: [3] The directory [~/.config/google-chrome/Default/Cache] has too many files (greater than 1000).
I had to add ~/.config to my .gcloudignore to get past this error.
Why was it looking there at all?
The full repo of my project is public but I believe I've included the relevant portion.
I looked at your linked repo and there aren't any yaml files. As far as I know, a GAE project needs an app.yaml file because that file tells GAE what your runtime is so that GAE knows how to deploy/run your code. In fact, according to the gcloud app deploy documentation, if you don't specify any yaml files to be deployed, it will default to app.yaml in the current directory. If it can't find any in the current directory, it will try to build one.
Your repo also shows you have a Dockerfile. GAE documentation for custom runtimes says ...Custom runtimes let you build apps that run in an environment defined by a Dockerfile... In the app.yaml file for custom runtimes, you will have the following entry
runtime: custom
env: flex
Since you don't have an app.yaml file and you have a Docker file in which you are downloading and installing Chrome, it seems to me that gcloud app deploy is trying to infer your runtime and this has led to it executing some or all of the contents of the Dockerfile before it attempts to then push it to Production. This is what is making it take a peek at the config file on your local machine till you explicitly tell it to ignore it. To be clear, I'm not 100% sure of this, just trying to see if I can draw a logical conclusion.
My suggestion would be to create an app.yaml file and specify a custom runtime. Or just use the python runtime with flex

Node.js app: "Disk quota exceeded" when installing npm module with lots of files

When adding https://www.npmjs.com/package/material-design-icons as a dependency to my Node application, cf push fails with Disk quota exceeded when running npm install. Since the complete application including node_modules has about 100 MB (way below the limit of 1 GB), I assume it might have to do with the fact that material-design-icons has about 86'000 files (for whatever reason).
Is there any workaround for this?
Another solution is to ignore the node_modules directory using the .cfignore file (the same concept as the .gitignore file). The files described in the .cfignore aren't uploaded to Cloud Foundry when you push your app.
You can find more about .cfignore here: https://docs.developer.swisscom.com/apps/deploy-apps/prepare-to-deploy.html#exclude
The solution is to delete the directory node_modules from your app directory before to push it. The description of the needed modules must be in the file package.json under dependencies. I tested a simple express app adding the material-design-icons module. Pushing the application without the content of the directory node_modules works, since in staging the modules are downloaded and added to the application.
The solution is to delete the directory node_modules from your app directory before to push it. The description of the needed modules must be in the file package.json under dependencies. I tested a simple express app adding the material-design-icons module. Pushing the application without the content of the directory node_modules works, since in staging the modules are downloaded and added to the application.
The solution with .cfignore should work. You might need to delete and re-push your app though, since Cloud Foundry caches some files and the container might be filled with these cached files. If you delete and re-push the app, you're getting a clean container from scratch which might solve your problem.
I have faced the same problem. I solved it by doing the following:
Using .cfignore
Specifying the update nodejs in package.json
Using the latest buildpack

Configuration and content management with automated deployment tools for ZF based app

I am trying to automate deployments of a particular project and a bit lost as to who to handle config file as well as user assets.
(Application is based on Zend Framework based btw).
Main application folder is structured as follows:
./app
./config.ini <----- config file
./modules
./controllers
./models
./views
./libs
./public
That config file is where all the configs are stored.
So 'app' folder contains whole bunch of code in PHP and 'public' contains whole bunch of code in JavaScript, HTML/CSS and stuff like that(web accessible basically).
If I follow Capistrano's model, where each package is expanded into it's own folder that is then symlinked to, how do I handle that config.ini file?
What about all the user content that is uploaded into ./public folder?
Thanks!
The Capistrano approach to this is to have a structure like this on your remote server:
releases/
20100901172311/
20101001101232/
[...]
current/ (symlink to current release)
shared/
in the shared directory you include your config file and any user generated content (e.g. shared/files). Then on each deployment, once you've checked out the code you automatically create symlinks from the checkout into your relevant shared directories. E.g.:
releases/20101001101232/public/files -> shared/files
releases/20101001101232/application/configs/config.ini -> shared/config.ini
that way, when a user uploads a file to public/files it is actually being stored in shared/files.