Within Pivitoal Cloud Foundary is there a way to set SPRING_PROFILES_ACTIVE per each space?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















For each space within an org using Pivotal Cloud Foundry (PCF) is there a way to set SPRING_PROFILES_ACTIVE for each space?




  • space1: SPRING_PROFILES_ACTIVE: development

  • space2: SPRING_PROFILES_ACTIVE: performance

  • space3: SPRING_PROFILES_ACTIVE: production

  • etc...


Thanks,
Brian










share|improve this question























  • PCF is a polyglot system. That means you can run apps built in multiple languages in PCF. PCF orgs or spaces are logical constructs for user management and deploying apps. They are not runtime constructs. Orgs and Spaces are agnostic.

    – K.AJ
    Jan 3 at 21:53











  • That said, by default, in cloud environment, the cloud profile is active for Spring based applications. If you need any other profile to be active, it is up to the settings of that application.

    – K.AJ
    Jan 3 at 21:54


















0















For each space within an org using Pivotal Cloud Foundry (PCF) is there a way to set SPRING_PROFILES_ACTIVE for each space?




  • space1: SPRING_PROFILES_ACTIVE: development

  • space2: SPRING_PROFILES_ACTIVE: performance

  • space3: SPRING_PROFILES_ACTIVE: production

  • etc...


Thanks,
Brian










share|improve this question























  • PCF is a polyglot system. That means you can run apps built in multiple languages in PCF. PCF orgs or spaces are logical constructs for user management and deploying apps. They are not runtime constructs. Orgs and Spaces are agnostic.

    – K.AJ
    Jan 3 at 21:53











  • That said, by default, in cloud environment, the cloud profile is active for Spring based applications. If you need any other profile to be active, it is up to the settings of that application.

    – K.AJ
    Jan 3 at 21:54














0












0








0








For each space within an org using Pivotal Cloud Foundry (PCF) is there a way to set SPRING_PROFILES_ACTIVE for each space?




  • space1: SPRING_PROFILES_ACTIVE: development

  • space2: SPRING_PROFILES_ACTIVE: performance

  • space3: SPRING_PROFILES_ACTIVE: production

  • etc...


Thanks,
Brian










share|improve this question














For each space within an org using Pivotal Cloud Foundry (PCF) is there a way to set SPRING_PROFILES_ACTIVE for each space?




  • space1: SPRING_PROFILES_ACTIVE: development

  • space2: SPRING_PROFILES_ACTIVE: performance

  • space3: SPRING_PROFILES_ACTIVE: production

  • etc...


Thanks,
Brian







spring-boot pivotal-cloud-foundry






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 2:05









BrianBrian

396




396













  • PCF is a polyglot system. That means you can run apps built in multiple languages in PCF. PCF orgs or spaces are logical constructs for user management and deploying apps. They are not runtime constructs. Orgs and Spaces are agnostic.

    – K.AJ
    Jan 3 at 21:53











  • That said, by default, in cloud environment, the cloud profile is active for Spring based applications. If you need any other profile to be active, it is up to the settings of that application.

    – K.AJ
    Jan 3 at 21:54



















  • PCF is a polyglot system. That means you can run apps built in multiple languages in PCF. PCF orgs or spaces are logical constructs for user management and deploying apps. They are not runtime constructs. Orgs and Spaces are agnostic.

    – K.AJ
    Jan 3 at 21:53











  • That said, by default, in cloud environment, the cloud profile is active for Spring based applications. If you need any other profile to be active, it is up to the settings of that application.

    – K.AJ
    Jan 3 at 21:54

















PCF is a polyglot system. That means you can run apps built in multiple languages in PCF. PCF orgs or spaces are logical constructs for user management and deploying apps. They are not runtime constructs. Orgs and Spaces are agnostic.

– K.AJ
Jan 3 at 21:53





PCF is a polyglot system. That means you can run apps built in multiple languages in PCF. PCF orgs or spaces are logical constructs for user management and deploying apps. They are not runtime constructs. Orgs and Spaces are agnostic.

– K.AJ
Jan 3 at 21:53













That said, by default, in cloud environment, the cloud profile is active for Spring based applications. If you need any other profile to be active, it is up to the settings of that application.

– K.AJ
Jan 3 at 21:54





That said, by default, in cloud environment, the cloud profile is active for Spring based applications. If you need any other profile to be active, it is up to the settings of that application.

– K.AJ
Jan 3 at 21:54












1 Answer
1






active

oldest

votes


















1














The primary way that you would set Spring profiles on Cloud Foundry is via environment variables.



Cloud Foundry does not provide a way to set environment variable groups per org or space. You can only set a staging and a running environment variable group which applies to all staging or all running apps. That's in addition to the standard facilities for setting environment variables on an application.





I think you might be able to get this to work, but it'll take a little effort. Here's the idea.





  1. Create a custom buildpack (don't panic, this isn't that difficult). The buildpack's only responsibility would be to create a .profile.d/ script (just a regular Bash script) that contains export SPRING_PROFILES_ACTIVE=<some-profile>.



    Any buildpack can create .profile.d/ scripts which are primarily used to configure environment variables. These scripts are automatically sourced by the environment before any application starts. Thus if the buildpack sets SPRING_PROFILES_ACTIVE here, it would be available to your app and take effect.



    https://docs.cloudfoundry.org/buildpacks/custom.html#contract



    You would just need to create the bin/supply and bin/detect scripts as defined at the link below. The bin/supply is where you'd put your logic to create the .profile.d/ script and bin/detect could be as simple as exit 0 which would just tell it to run always.



    https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts




  2. Your custom buildpack could be as simple as hard coding profiles to use or it could be fancy and look at the VCAP_APPLICATION environment which contains the space name.



    Ex: echo $VCAP_APPLICATION | jq .space_name.



    The buildpack could then apply logic to set the correct profile given the space name. I don't think the org name is available to the app at staging/runtime, at least not through environment variables, so it would be harder to apply logic based on that.




  3. The last step is using CF's multi-buildpack support. Your custom buildpack would be a supply buildpack so it would be first, then you'd list the actual buildpack to use second as you push your application.



    Ex: cf push -b https://github.com/your-profile/your-custom-buildpack -b java_buildpack your-cool-app.



    https://docs.cloudfoundry.org/buildpacks/use-multiple-buildpacks.html




Hope that helps!






share|improve this answer
























  • I guess we can also create an user-provided-service with spring.profile.active stuff and have that service bound to the Apps when it is being pushed

    – Arun
    Jan 23 at 16:56











  • @Arun That's an option, but it requires developer interaction to make it work, so it's really not that much different than setting an env variable for each app.

    – Daniel Mikusa
    Jan 23 at 18:01












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015467%2fwithin-pivitoal-cloud-foundary-is-there-a-way-to-set-spring-profiles-active-per%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The primary way that you would set Spring profiles on Cloud Foundry is via environment variables.



Cloud Foundry does not provide a way to set environment variable groups per org or space. You can only set a staging and a running environment variable group which applies to all staging or all running apps. That's in addition to the standard facilities for setting environment variables on an application.





I think you might be able to get this to work, but it'll take a little effort. Here's the idea.





  1. Create a custom buildpack (don't panic, this isn't that difficult). The buildpack's only responsibility would be to create a .profile.d/ script (just a regular Bash script) that contains export SPRING_PROFILES_ACTIVE=<some-profile>.



    Any buildpack can create .profile.d/ scripts which are primarily used to configure environment variables. These scripts are automatically sourced by the environment before any application starts. Thus if the buildpack sets SPRING_PROFILES_ACTIVE here, it would be available to your app and take effect.



    https://docs.cloudfoundry.org/buildpacks/custom.html#contract



    You would just need to create the bin/supply and bin/detect scripts as defined at the link below. The bin/supply is where you'd put your logic to create the .profile.d/ script and bin/detect could be as simple as exit 0 which would just tell it to run always.



    https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts




  2. Your custom buildpack could be as simple as hard coding profiles to use or it could be fancy and look at the VCAP_APPLICATION environment which contains the space name.



    Ex: echo $VCAP_APPLICATION | jq .space_name.



    The buildpack could then apply logic to set the correct profile given the space name. I don't think the org name is available to the app at staging/runtime, at least not through environment variables, so it would be harder to apply logic based on that.




  3. The last step is using CF's multi-buildpack support. Your custom buildpack would be a supply buildpack so it would be first, then you'd list the actual buildpack to use second as you push your application.



    Ex: cf push -b https://github.com/your-profile/your-custom-buildpack -b java_buildpack your-cool-app.



    https://docs.cloudfoundry.org/buildpacks/use-multiple-buildpacks.html




Hope that helps!






share|improve this answer
























  • I guess we can also create an user-provided-service with spring.profile.active stuff and have that service bound to the Apps when it is being pushed

    – Arun
    Jan 23 at 16:56











  • @Arun That's an option, but it requires developer interaction to make it work, so it's really not that much different than setting an env variable for each app.

    – Daniel Mikusa
    Jan 23 at 18:01
















1














The primary way that you would set Spring profiles on Cloud Foundry is via environment variables.



Cloud Foundry does not provide a way to set environment variable groups per org or space. You can only set a staging and a running environment variable group which applies to all staging or all running apps. That's in addition to the standard facilities for setting environment variables on an application.





I think you might be able to get this to work, but it'll take a little effort. Here's the idea.





  1. Create a custom buildpack (don't panic, this isn't that difficult). The buildpack's only responsibility would be to create a .profile.d/ script (just a regular Bash script) that contains export SPRING_PROFILES_ACTIVE=<some-profile>.



    Any buildpack can create .profile.d/ scripts which are primarily used to configure environment variables. These scripts are automatically sourced by the environment before any application starts. Thus if the buildpack sets SPRING_PROFILES_ACTIVE here, it would be available to your app and take effect.



    https://docs.cloudfoundry.org/buildpacks/custom.html#contract



    You would just need to create the bin/supply and bin/detect scripts as defined at the link below. The bin/supply is where you'd put your logic to create the .profile.d/ script and bin/detect could be as simple as exit 0 which would just tell it to run always.



    https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts




  2. Your custom buildpack could be as simple as hard coding profiles to use or it could be fancy and look at the VCAP_APPLICATION environment which contains the space name.



    Ex: echo $VCAP_APPLICATION | jq .space_name.



    The buildpack could then apply logic to set the correct profile given the space name. I don't think the org name is available to the app at staging/runtime, at least not through environment variables, so it would be harder to apply logic based on that.




  3. The last step is using CF's multi-buildpack support. Your custom buildpack would be a supply buildpack so it would be first, then you'd list the actual buildpack to use second as you push your application.



    Ex: cf push -b https://github.com/your-profile/your-custom-buildpack -b java_buildpack your-cool-app.



    https://docs.cloudfoundry.org/buildpacks/use-multiple-buildpacks.html




Hope that helps!






share|improve this answer
























  • I guess we can also create an user-provided-service with spring.profile.active stuff and have that service bound to the Apps when it is being pushed

    – Arun
    Jan 23 at 16:56











  • @Arun That's an option, but it requires developer interaction to make it work, so it's really not that much different than setting an env variable for each app.

    – Daniel Mikusa
    Jan 23 at 18:01














1












1








1







The primary way that you would set Spring profiles on Cloud Foundry is via environment variables.



Cloud Foundry does not provide a way to set environment variable groups per org or space. You can only set a staging and a running environment variable group which applies to all staging or all running apps. That's in addition to the standard facilities for setting environment variables on an application.





I think you might be able to get this to work, but it'll take a little effort. Here's the idea.





  1. Create a custom buildpack (don't panic, this isn't that difficult). The buildpack's only responsibility would be to create a .profile.d/ script (just a regular Bash script) that contains export SPRING_PROFILES_ACTIVE=<some-profile>.



    Any buildpack can create .profile.d/ scripts which are primarily used to configure environment variables. These scripts are automatically sourced by the environment before any application starts. Thus if the buildpack sets SPRING_PROFILES_ACTIVE here, it would be available to your app and take effect.



    https://docs.cloudfoundry.org/buildpacks/custom.html#contract



    You would just need to create the bin/supply and bin/detect scripts as defined at the link below. The bin/supply is where you'd put your logic to create the .profile.d/ script and bin/detect could be as simple as exit 0 which would just tell it to run always.



    https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts




  2. Your custom buildpack could be as simple as hard coding profiles to use or it could be fancy and look at the VCAP_APPLICATION environment which contains the space name.



    Ex: echo $VCAP_APPLICATION | jq .space_name.



    The buildpack could then apply logic to set the correct profile given the space name. I don't think the org name is available to the app at staging/runtime, at least not through environment variables, so it would be harder to apply logic based on that.




  3. The last step is using CF's multi-buildpack support. Your custom buildpack would be a supply buildpack so it would be first, then you'd list the actual buildpack to use second as you push your application.



    Ex: cf push -b https://github.com/your-profile/your-custom-buildpack -b java_buildpack your-cool-app.



    https://docs.cloudfoundry.org/buildpacks/use-multiple-buildpacks.html




Hope that helps!






share|improve this answer













The primary way that you would set Spring profiles on Cloud Foundry is via environment variables.



Cloud Foundry does not provide a way to set environment variable groups per org or space. You can only set a staging and a running environment variable group which applies to all staging or all running apps. That's in addition to the standard facilities for setting environment variables on an application.





I think you might be able to get this to work, but it'll take a little effort. Here's the idea.





  1. Create a custom buildpack (don't panic, this isn't that difficult). The buildpack's only responsibility would be to create a .profile.d/ script (just a regular Bash script) that contains export SPRING_PROFILES_ACTIVE=<some-profile>.



    Any buildpack can create .profile.d/ scripts which are primarily used to configure environment variables. These scripts are automatically sourced by the environment before any application starts. Thus if the buildpack sets SPRING_PROFILES_ACTIVE here, it would be available to your app and take effect.



    https://docs.cloudfoundry.org/buildpacks/custom.html#contract



    You would just need to create the bin/supply and bin/detect scripts as defined at the link below. The bin/supply is where you'd put your logic to create the .profile.d/ script and bin/detect could be as simple as exit 0 which would just tell it to run always.



    https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts




  2. Your custom buildpack could be as simple as hard coding profiles to use or it could be fancy and look at the VCAP_APPLICATION environment which contains the space name.



    Ex: echo $VCAP_APPLICATION | jq .space_name.



    The buildpack could then apply logic to set the correct profile given the space name. I don't think the org name is available to the app at staging/runtime, at least not through environment variables, so it would be harder to apply logic based on that.




  3. The last step is using CF's multi-buildpack support. Your custom buildpack would be a supply buildpack so it would be first, then you'd list the actual buildpack to use second as you push your application.



    Ex: cf push -b https://github.com/your-profile/your-custom-buildpack -b java_buildpack your-cool-app.



    https://docs.cloudfoundry.org/buildpacks/use-multiple-buildpacks.html




Hope that helps!







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 6 at 20:00









Daniel MikusaDaniel Mikusa

6,22011015




6,22011015













  • I guess we can also create an user-provided-service with spring.profile.active stuff and have that service bound to the Apps when it is being pushed

    – Arun
    Jan 23 at 16:56











  • @Arun That's an option, but it requires developer interaction to make it work, so it's really not that much different than setting an env variable for each app.

    – Daniel Mikusa
    Jan 23 at 18:01



















  • I guess we can also create an user-provided-service with spring.profile.active stuff and have that service bound to the Apps when it is being pushed

    – Arun
    Jan 23 at 16:56











  • @Arun That's an option, but it requires developer interaction to make it work, so it's really not that much different than setting an env variable for each app.

    – Daniel Mikusa
    Jan 23 at 18:01

















I guess we can also create an user-provided-service with spring.profile.active stuff and have that service bound to the Apps when it is being pushed

– Arun
Jan 23 at 16:56





I guess we can also create an user-provided-service with spring.profile.active stuff and have that service bound to the Apps when it is being pushed

– Arun
Jan 23 at 16:56













@Arun That's an option, but it requires developer interaction to make it work, so it's really not that much different than setting an env variable for each app.

– Daniel Mikusa
Jan 23 at 18:01





@Arun That's an option, but it requires developer interaction to make it work, so it's really not that much different than setting an env variable for each app.

– Daniel Mikusa
Jan 23 at 18:01




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015467%2fwithin-pivitoal-cloud-foundary-is-there-a-way-to-set-spring-profiles-active-per%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith