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;
}
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
add a comment |
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
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, thecloud
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
add a comment |
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
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
spring-boot pivotal-cloud-foundry
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, thecloud
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
add a comment |
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, thecloud
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
add a comment |
1 Answer
1
active
oldest
votes
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.
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 containsexport 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 setsSPRING_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
andbin/detect
scripts as defined at the link below. Thebin/supply
is where you'd put your logic to create the.profile.d/
script andbin/detect
could be as simple asexit 0
which would just tell it to run always.
https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts
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.
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!
I guess we can also create anuser-provided-service
withspring.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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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 containsexport 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 setsSPRING_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
andbin/detect
scripts as defined at the link below. Thebin/supply
is where you'd put your logic to create the.profile.d/
script andbin/detect
could be as simple asexit 0
which would just tell it to run always.
https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts
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.
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!
I guess we can also create anuser-provided-service
withspring.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
add a comment |
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.
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 containsexport 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 setsSPRING_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
andbin/detect
scripts as defined at the link below. Thebin/supply
is where you'd put your logic to create the.profile.d/
script andbin/detect
could be as simple asexit 0
which would just tell it to run always.
https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts
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.
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!
I guess we can also create anuser-provided-service
withspring.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
add a comment |
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.
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 containsexport 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 setsSPRING_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
andbin/detect
scripts as defined at the link below. Thebin/supply
is where you'd put your logic to create the.profile.d/
script andbin/detect
could be as simple asexit 0
which would just tell it to run always.
https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts
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.
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!
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.
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 containsexport 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 setsSPRING_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
andbin/detect
scripts as defined at the link below. Thebin/supply
is where you'd put your logic to create the.profile.d/
script andbin/detect
could be as simple asexit 0
which would just tell it to run always.
https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html#buildpack-scripts
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.
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!
answered Jan 6 at 20:00
Daniel MikusaDaniel Mikusa
6,22011015
6,22011015
I guess we can also create anuser-provided-service
withspring.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
add a comment |
I guess we can also create anuser-provided-service
withspring.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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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