Skip to content
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.

Cannot run in development during image creation, then in production for deployment #94

Closed
lincolnthree opened this issue May 18, 2018 · 8 comments

Comments

@lincolnthree
Copy link

lincolnthree commented May 18, 2018

So, it currently seems like there is no way to run in "development" NODE_ENV during a build, then to run in "production" NODE_ENV when the image is actually deployed.

The BuildConfig NODE_ENV doesn't seem to get picked up.

@lincolnthree lincolnthree changed the title Cannot run in development during image creation, then run production after deployment Cannot run in development during image creation, then run production for deployment May 18, 2018
@lincolnthree lincolnthree changed the title Cannot run in development during image creation, then run production for deployment Cannot run in development during image creation, then in production for deployment May 18, 2018
@lincolnthree
Copy link
Author

lincolnthree commented May 18, 2018

      strategy:
        type: Source
        sourceStrategy:
          from:
            kind: ImageStreamTag
            name: 'runtime:latest'
          incremental: true
        env:
        - name: "NODE_ENV"
          value: "development"
        - name: "DEV_MODE"
          value: "true"

@lincolnthree
Copy link
Author

I can't seem to get this to use development:

---> Installing dependencies
--
  | ---> Using 'npm install -s --only=production'

Seems like it should work according to --> https://github.com/bucharest-gold/centos7-s2i-nodejs/blob/master/s2i/env

@lincolnthree
Copy link
Author

This is what I've tried:

snowdrop/snowdrop-site-angular@521a89d

@lholmquist
Copy link
Contributor

Not to long ago i added something to nodeshift to add env vars to your build config,

This is what my build config looks like(edited down)

apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  labels:
    project: nodejs-rest-http
    provider: nodeshift
    version: 2.0.0
  name: nodejs-rest-http-s2i
  namespace: build-thing
  resourceVersion: '86013'
spec:
  nodeSelector: null
  output:
    to:
      kind: ImageStreamTag
      name: 'nodejs-rest-http:latest'
  runPolicy: Serial
  source:
    binary: {}
    type: Binary
  strategy:
    sourceStrategy:
      env:
        - name: NODE_ENV
          value: debug
      from:
        kind: DockerImage
        name: 'bucharestgold/centos7-s2i-nodejs:10.x'
    type: Source
  triggers: []

That makes the build phase install dev dependencies. Looking at where you have your env vars in your build config, i think they might be in the wrong spot?

I haven't actually tried to do development mode for builds, prod for deploy. it might work?

@lholmquist
Copy link
Contributor

continuing the other comment,

to do developemnt build, production deploy, i guess you would need env vars set for both the build Config and deployment config, but i haven't actually tried that yet.

(looks like i need to also add something to nodeshift to do this, if this is a workflow people need)

@lincolnthree
Copy link
Author

Looks like yaml is screweing me up.... indentation. Let me try something.

@lincolnthree
Copy link
Author

Okay, yes, my DC and BC YAML indentation was botched. Adding env: vars here to DeploymentConfig and BuildConfig works as it should. Closing.

@lincolnthree
Copy link
Author

lincolnthree commented May 18, 2018

objects:
  - apiVersion: v1
    kind: ImageStream
    ...
    spec:
      tags:
        - name: latest
          from:
            kind: DockerImage
            name: 'bucharestgold/centos7-s2i-nodejs:10.x'
  - apiVersion: v1
    kind: BuildConfig
    ...
    spec:
      ...
      strategy:
        type: Source
        sourceStrategy:
          ...
          env:
            - name: "NODE_ENV"
              value: 'development'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants