[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Changing Environment in STI Builds



It seems to pick up the changes that I made to the template.json file after I cleaned up the whole setup and re-tried it. 

I think my only query now is how do I refresh the json file. If I make any changes to it i.e. add new environment variables or change them, how do I make those be used by the build process. I tried oc edit and oc process but they both did not seem to update the json file. Sorry if I missed this in the docs but couldnt find it as far as I can see.

Thanks
Raja


On Tue, Aug 11, 2015 at 4:50 PM, Raja <rajasaur gmail com> wrote:
Hi,
Sorry still dont get it right. I updated my application-template-stibuild.json to add the following:
"sourceStrategy": {
            "from": {
              "kind": "ImageStreamTag",
              "name": "ruby-20-centos7:latest"
            },
            "env": [
                {
                        "Name": "RACK_ENV",
                        "Value": "development"
                },
                {
                        "Name": "TESTNAME",
                        "Value": "TESTVALUE"
                },
                {
                        "Name": "BUILD_LOG_LEVEL",
                        "Value": "5"
                }
            ]

I was hoping that when an image is built using this, all of these will be available as environment variables in the image as per https://docs.openshift.org/latest/dev_guide/builds.html#buildconfig-environment. But once I do a build with this and try to inspect the container or try to view its environment variables, I dont see any of these. I can see RACK_ENV=production, which is in .sti/environment, but none of the above variables.

Sorry for newbie questions, still trying to figure out  how this works.

Thanks
raja


On Tue, Aug 11, 2015 at 3:25 PM, Raja <rajasaur gmail com> wrote:
Thanks a lot. Thats very helpful.

On Tue, Aug 11, 2015 at 3:06 PM, Rodolfo Carvalho <rcarvalh redhat com> wrote:
Here is the relevant page in the documentation:


Worth noting that both .sti/environment and BuildConfig.sourceStrategy.env apply to build time and run time of the image.

HTH,

On Tue, Aug 11, 2015 at 11:31 AM, Rodolfo Carvalho <rcarvalh redhat com> wrote:
Hi Raja,

The source build strategy supports passing in additional env vars to the builder image.
All you have to do is edit the sample-app template:

"strategy": {
  "type": "Source",
  "sourceStrategy": {
    "from": {
      "kind": "ImageStreamTag",
      "name": "ruby-20-centos7:latest"
    }
  }
},


Becomes:

"strategy": {
  "type": "Source",
  "sourceStrategy": {
    "from": {
      "kind": "ImageStreamTag",
      "name": "ruby-20-centos7:latest"
    },
    "env": [
      {
        "name": "FOO",
        "value": "BAR"
      },
      {
        "name": "RACK_ENV",
        "value": "TEST"
      }
    ]
  }
},



On Tue, Aug 11, 2015 at 9:24 AM, Raja <rajasaur gmail com> wrote:
Hi Vincent
That seems to work for environment variables used inside the application but not for building the image itself.

Im trying to see if I can change RACK_ENV from production to test in the sample-app by changing the JSON file, and if I add
"spec": {
            "containers": [
              { 
                "name": "ruby-helloworld",
                "image": "origin-ruby-sample",
                "ports": [
                  { 
                    "containerPort": 8080,
                    "protocol": "TCP"
                  }
                ],
                "env": [
                  { 
                    "name": "RACK_ENV",
                    "value": "test"
                  }, 

it still doesnt effect this and uses the value in .sti/environment in the repository. i.e. if I login to the docker container and see the environment variables it shows RACK_ENV=production as thats whats in https://github.com/openshift/ruby-hello-world/blob/master/.sti/environment 

On Tue, Aug 11, 2015 at 12:22 PM, Vincent Behar <v behar free fr> wrote:
Hi,

You can use the “env” array of environment variables in your container definition : https://docs.openshift.org/latest/rest_api/openshift_v1.html#v1-container

Something like :

- kind: DeploymentConfig
  apiVersion: v1
  spec:
    template:
      spec:
        containers:
        - name: ...
          image: ...
          env:
          - name: PORT
            value: "8080"

Vincent

> On 11 Aug 2015, at 08:40, Raja <rajasaur gmail com> wrote:
>
> Hi
>
> Im new to STI and trying to find out how to setup/change environment in STI Builds. The .sti/environment file seems to be the one thats read in the scripts and used for the environment. Is there another way of dynamically setting up what the environment is (Test/Stage/Prod).
>
> Im trying to workout a usecase where a build needs to be promoted from dev to stage and doing a commit right now to change .sti/environment seems to be the way to do it. Is there any other way ?
>
> Thanks
> Raja
>
> --
> Raja
> rajasaur at gmail.com
> _______________________________________________
> users mailing list
> users lists openshift redhat com
> http://lists.openshift.redhat.com/openshiftmm/listinfo/users




--
Raja
rajasaur at gmail.com

_______________________________________________
users mailing list
users lists openshift redhat com
http://lists.openshift.redhat.com/openshiftmm/listinfo/users




--
Rodolfo Carvalho

OpenShift Developer Experience



--
Rodolfo Carvalho

OpenShift Developer Experience



--
Raja
rajasaur at gmail.com



--
Raja
rajasaur at gmail.com



--
Raja
rajasaur at gmail.com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]