I'm new to phoenix and elixier but the framework looks very interesting.
Currently i'm searching for an equivalent of Rails environment helpers.
Rails.env.production?
Rails.env.staging?
is there a similar implementation in phoenix ?
Best Regards
Eric
This function is not a part of the PhoenixFramework. Elixir's Mix supports three types of environment
Mix.env hold the current stage and give a result of :dev, :test, or :prod.
The develop option is used by default. On tests (mix test) the test environment will be automatically used.
This console call MIX_ENV=prod mix compile will compile the files in production environment.
See Introduction to mix for more information.
In addition to what Fabi755 said you may also interact with the different environments through the Application module. There are functions like Application.get_env/2 which can fetch the same configuration based on the environment you are currently in (like let's say have a config for sending SMS to false in dev, but you have it to true in prod).
Ultimately the environments are not from Phoenix but from Elixir and the Mix tool.
Related
For our Airflow Projects (running Airflow 2.0.1) I have implemented some general test that verify the DAG validity, check if each DAG has an owner/email, check for parsing time and so on ..
Now I am trying to set up some CI/CD pipeline that runs these tests and then pushes the DAGs to the Cloud Composer bucket. This test however will obviously fail if I use any Airflow Connection or Variable as these have not been created yet on the runners.
What I do not want to do is using mocking, as I have to specify each connection/variable which is a bit too much work for general tests. How do you deal with connections/variables for testing on different environments (development/testing/production)
Since you're using Airflow 2 you can use the stable API to create or update variables in the desired environment. You just need to call that API from the CI/CD pipeline.
Check the official documentation for create a variable and update a variable.
There is no official support of Act on Heroku, however the Maven buildpack seems to do almost everything the app needs, except start it properly. Any recommended settings and/or Profiles to start the app properly?
The main two things to figure out were how to bind to the dynamically assigned port, and how to load from a different profile. This Procfile handles both of those things:
web: export act_env_http_port=$PORT && java $JAVA_OPTS -Dprofile=heroku -cp target/classes:target/dependency/* com.larvalabs.gifmsgbot.AppEntry
The environment variable that specifies the port is in a special (mostly undocumented format) that allows you to automatically override configuration settings. A tiny bit more info is the bug that contains the relevant changes: https://github.com/actframework/actframework/issues/636
Also note that I'm using a profile named heroku here, this is because I don't totally understand how the prod profile works yet, but I couldn't load settings from it when specifying -Dprofile=prod
On Jelastic, I created a node for building an application (maven), there are several identical environments (NGINX + Spring Boot), the difference is in binding to its database and configured SSL.
The task is to ensure that after building the application (* .jar), deploy at the same time go to these several environments, how to implement it?
When editing a project, it is possible to specify only one environment, multi-selection is not provided.
it`s allowed to specify just one environment
We suggest creating a few environments using one Repository branch, and run updates by API https://docs.jelastic.com/api/#!/api/environment.Vcs-method-Update pushing whole code to VCS.
It's possible to use CloudScripting technology for attaching custom logic to onAfterBuildProject event and deploying the project to additional environments after build is complete. Please check this JPS as an example of the code syntax. Most likely you will need to use DeployProject API method.
I need to remove a few files when in development environment (for example when using Vagrant) but not in production. I want to disable firewalld when in development, but not in production. I would like to disable selinux whenon development, but not on production.
What is the best practice for doing these? I would like to use my puppet scripts both on development environments (with Vagrant) and on production.
It is not a good practice to have scripts specific to an environment. Instead you should have scripts which will behave differently based on environment. Let me show you how; there are two steps you will need to do for this to work:
Define environments
You will have to define environments - I would suggest directory based environments (Because config based environment support will be dropped eventually). How to setup environments is an intimate topic and I suggest you check out the documentation
Use environments in your code
Let's say you have defined environments such as dev, qa, uat, prod etc. You can get the name of current environment by using $environment variable. Your manifests should leverage the environment variable to decide weather a firewall should be enabled/disabled etc. For example:
(Modified based on Felix's comment, thanks #Felix)
include profile::webserver
if $environment != 'dev'
include profile::firewall
In above piece of code if the $environment does not match to "dev" only then the firewall role is applied!
I'm trying to create two different environments on Heroku with my RoR application, i will try to explain myself easily:
my machine -> development environment (A)
a free plan Heroku instance -> test environment (B)
subscripted Heroku instance -> production environment (C)
But I can't push to (B), telling to Heroku "hey, load the "test" environment".
Surfing the net i find this: https://devcenter.heroku.com/articles/multiple-environments but I don't understand why in that guide they talked about "staging" environment. I would be happy to use the 3 default ruby on rails environment: development/test/production
Do you have some suggestions?
Thanks and sorry, but I'm new about Ruby on Rails and Heroku :)
Have a nice day.
Because test is a special environment in the Ruby on Rails world, I'd strongly recommend avoiding using test as an environment name.
I've seen QA used (per another SO question about this topic)... But it's still outside of the convention. So, opposed to test, Heroku's standard is staging, but you could use anything you want (like QA) - I'd just avoid test.