Cannot run assets:precompile due to initializers - ruby-on-rails-6

I am trying to precompile assets to a production environment with RoR 6.X.X.
in config/initializers, I have an initializer that connects to a third-party service API. When I execute bundle exec rails assets:precompile it crashes because the API key is not defined yet for that initialiser (and I don't need the initializer to build CSS and JS...). Few releases ago, the config property config.assets.initialize_on_precompile was alive but now it doesn't exist anymore.
How Am I supposed to build my assets now?

Related

Why only a part of pods in a deployment starts successfully?

I am deploying a dotnet app to AKS (Azure Kubernetes Service).
I do not know why but only a part of pods runs as expected while other pods throw a runtime exception and fail. I think the kind of exception does not really matter but in fact it is "System.IO.FileNotFoundException: Could not load file or assembly ..." thrown at program startup time. The container image is okay and all assemblies are there and running pods prove that.
What are possible reasons of such behaviour?
Okay, so it was my mistake. One of assemblies was referenced with PrivateAssets="All" in a .csproj file so this dependency was not propagated and required DLL was not copied to the output directory during the build process.

Flyway scripts not executing if class loaded via classloader

I have a project and a subproject there are apis in sub project which are accessed via main project.
First I compile the subproject into jar along with dependencies.
Next I load the jar using url classloaders
Next from main project using reflection I consume the apis in subproject.
I have configured flyway in the sub project and added the sql scripts in subproject. Flyway migration is done using an api call. Now when I hit the api directly in sub project, flyway scripts are executed. If I load the class via classloaders and then hit the api from main project the scripts are not executed.

cloud foundry dependency jars for spring boot

Suppose when I make a java spring boot application, it needs jars .
But when I deploy my app to cloud foundry will all the jars get build with my app and then go to cloud foundry or cloud foundry provides the jars dependency by seeing pom etc.
I have seen build folder but the jars are not there so how does it work.
I am new to cloud foundry so if someone can clear my doubt.
For most application types and build packs, when you push an application to Cloud Foundry you are pushing source code, and, if necessary, that source codes gets compiled during the staging process by the build pack. For example, with the Golang build pack you push your Go source code and it's compiled in staging and then run.
The two exceptions to this rule are the Java build pack and the binary build pack. These two build packs assume that you are pushing compiled bits and do not compile anything for you.
In the case of Java, this means that you're going to run Maven, Gradle or some other build system locally or on your CI system to produce a deployable artifact. This could be a WAR file or a JAR file, or a few other things (see "Standard Containers" on the Java build pack docs for other supported formats). Regardless of the format, it needs to be a complete and deployable unit, so it will need to include all dependent libraries.
As a side note, the cf cli has a nice feature that helps to speed up the cf push process and save bandwidth. It matches any files being uploaded and over 65k in size (default, operators can change this) to files cached on the Cloud Controller. If a local file already exists in the cache, it is not uploaded again. This works great for dependent JAR files which don't often change between pushes.
Spring Boot apps are typically packaged as "fat jars" using the Spring Boot maven or gradle plugin. The application code and all dependent jars are packaged into a single jar file.
Cloud Foundry will not download dependent jars when a Java application is deployed. It is the app's responsibility to bring all dependencies with it.

Replace developer persistence.xml with the production one while building a war deployment in Intellij

I am deploying a spring-mvc application which uses JPA to access MySQL database. Access information is stored in persistence.xml, while creating a deployment war file I would like to replace developer persistence with the production one.
I tried to copy the production xml directly into the deployment folder (intellij settings), but it has no effect a dev. copy is always deployed.
How do I configure IDE to do that?
If your project is mavenised, then you can use the maven-war-plugin or maven-resources-plugin to customise the resources used to build the war, and the ide should honour these plugins.

Rails custom.css not working when deployed to Heroku

Any idea why my custom.css would work perfectly in my development environment, but not work when deployed to Heroku? Things that have the property display: none; are appearing when deployed, but are appropriately hidden when in development.
Thanks!
Sounds like you are having problems with the asset pipeline. Check out:
https://devcenter.heroku.com/articles/rails-asset-pipeline
Are you letting Heroku precompile your assets? Personally, I precompile all my assets before deploying to Heroku.
RAILS_ENV=production bundle exec rake assets:precompile
This will precompile all your assets and puts it under a public/assets folder. Then you can just add them to git and push to heroku.
If you do this you will be compiling manually, and you should run the precompile line before you re-deploy or update your Heroku app to catch any changes you've made in the asset pipeline.
You can check belows
- expire browser cache.
- check assets are deploy well. (access to css url directly)
I think that case is almost come from cache.

Resources