Giter Site home page Giter Site logo

paketo-buildpacks / environment-variables Goto Github PK

View Code? Open in Web Editor NEW
22.0 7.0 6.0 316 KB

A Cloud Native Buildpack that embeds environment variables into an image

License: Apache License 2.0

Go 59.80% Shell 40.20%
cnb environment-variables all-applications utilities

environment-variables's Introduction

gcr.io/paketo-buildpacks/environment-variables

The Paketo Buildpack for Environment Variables is a Cloud Native Buildpack that embeds environment variables into an image.

Behavior

This buildpack will participate all the following conditions are met

  • Any environment variable matching $BPE_* is set

The buildpack will do the following:

  • Modify the launch environment using the $BPE_* envrionment variables, as described in the Configuration section below

Configuration

Environment Variable Description
$BPE_<NAME> set $NAME to value (same as override)
$BPE_APPEND_<NAME> append value to $NAME
$BPE_DEFAULT_<NAME> set default value for $NAME
$BPE_DELIM_<NAME> set delimeter to use when appending or prepending to $NAME
$BPE_OVERRIDE_<NAME> set $NAME to value
$BPE_PREPEND_<NAME> prepend value to $NAME

The default delimiter is an empty string, i.e. there is no default delimiter.

License

This buildpack is released under version 2.0 of the Apache License.

environment-variables's People

Contributors

dependabot[bot] avatar dmikusa avatar ekcasey avatar foresteckhardt avatar nebhale avatar paketo-bot avatar pivotal-david-osullivan avatar sophiewigmore avatar thitch97 avatar twoseat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

environment-variables's Issues

Built image has no env variables

Using builder: paketobuildpacks/builder-jammy-base:0.4.274 I'm passing the following two env variables into buildpack task:

- 'BPE_ENVIRONMENT=prod'
- 'BPE_LEGACY_DEV=true'

I can see that the buildpack environment-variables picks them up

[build-buildpack : build] Paketo Buildpack for Environment Variables 4.5.6
[build-buildpack : build]   https://github.com/paketo-buildpacks/environment-variables
[build-buildpack : build]   Launch Configuration:
[build-buildpack : build]     $BPE_<NAME>         	 prepend value to $NAME, delimiting with OS path list separator
[build-buildpack : build]     $BPE_APPEND_<NAME>  	 append value to $NAME
[build-buildpack : build]     $BPE_DEFAULT_<NAME> 	 set default value for $NAME
[build-buildpack : build]     $BPE_DELIM_<NAME>   	 set delimeter to use when appending or prepending to $NAME
[build-buildpack : build]     $BPE_OVERRIDE_<NAME>	 set $NAME to value
[build-buildpack : build]     $BPE_PREPEND_<NAME> 	 prepend value to $NAME
[build-buildpack : build]   Environment Variables: Contributing to layer
[build-buildpack : build]     Writing env.launch/ENVIRONMENT
[build-buildpack : build]     Writing env.launch/LEGACY_DEV

However these 2 variables are not present in the final image, once the container started:

โœ—  k exec -ti -n prod project-f7f5cd999-jn945 -- bash
I have no name!@project-f7f5cd999-jn945:/workspace/source/app$ env | grep LEGACY_DEV
I have no name!@project-f7f5cd999-jn945:/workspace/source/app$ env | grep ENVIRONMENT
I have no name!@project-f7f5cd999-jn945:/workspace/source/app$ env
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_SERVICE_PORT=443
HOSTNAME=project-f7f5cd999-jn945
BACKEND_PORT_8080_TCP_ADDR=172.20.23.87
CNB_PLATFORM_API=0.9
CNB_LAYERS_DIR=/layers
CNB_APP_DIR=/workspace/source/app
project_SERVICE_HOST=172.20.156.60
PWD=/workspace/source/app
BACKEND_SERVICE_PORT=8080
PORT=8080
project_SERVICE_PORT=8080
HOME=/
project_PORT_8080_TCP_ADDR=172.20.156.60
KUBERNETES_PORT_443_TCP=tcp://172.20.0.1:443
project_PORT_8080_TCP=tcp://172.20.156.60:8080
BACKEND_PORT_8080_TCP=tcp://172.20.23.87:8080
project_SERVICE_PORT_HTTP=8080
TERM=xterm
BACKEND_PORT_8080_TCP_PORT=8080
BACKEND_SERVICE_HOST=172.20.23.87
SHLVL=1
project_PORT_8080_TCP_PORT=8080
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_PORT_443_TCP_ADDR=172.20.0.1
CNB_DEPRECATION_MODE=quiet
BACKEND_SERVICE_PORT_HTTP=8080
KUBERNETES_SERVICE_HOST=172.20.0.1
KUBERNETES_PORT=tcp://172.20.0.1:443
KUBERNETES_PORT_443_TCP_PORT=443
BACKEND_PORT_8080_TCP_PROTO=tcp
PATH=/cnb/process:/cnb/lifecycle:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
project_PORT=tcp://172.20.156.60:8080
project_PORT_8080_TCP_PROTO=tcp
BACKEND_PORT=tcp://172.20.23.87:8080
_=/usr/bin/env
I have no name!@project-f7f5cd999-jn945:/workspace/source/app$ 

Expected Behavior

Env vars to be available inside the container.

Current Behavior

Env vars are missed.

Steps to Reproduce

I'm building react app with nginx web-server webpack, but initially it install node deps and then run npm run build:dev script
that I set via BP_NODE_RUN_SCRIPTS=build:dev var.

Warning: No cached data will be used, no cache specified.
===> ANALYZING
Image with name "[1111.dkr.ecr.us-east-1.amazonaws.com/project/prod/project:1f512dc](http://1111.dkr.ecr.us-east-1.amazonaws.com/project/prod/project:1f512dc)" not found
===> DETECTING
8 of 10 buildpacks participating
paketo-buildpacks/ca-certificates       3.6.7
paketo-buildpacks/node-engine           3.2.0
paketo-buildpacks/npm-install           1.3.1
paketo-buildpacks/node-run-script       1.0.15
paketo-buildpacks/nginx                 0.15.10
paketo-buildpacks/environment-variables 4.5.6
paketo-buildpacks/image-labels          4.5.5
paketo-buildpacks/source-removal        0.2.1
===> RESTORING
===> BUILDING
Paketo Buildpack for CA Certificates 3.6.7
  https://github.com/paketo-buildpacks/ca-certificates
  Launch Helper: Contributing to layer
    Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
Paketo Buildpack for Node Engine 3.2.0
  Resolving Node Engine version
    Candidate version sources (in priority order):
      package.json -> "18.19.0"
      <unknown>    -> ""

    Selected Node Engine version (using package.json): 18.19.0

  Executing build process
    Installing Node Engine 18.19.0
      Completed in 5.83s

  Generating SBOM for /layers/paketo-buildpacks_node-engine/node
      Completed in 0s

  Configuring build environment
    NODE_ENV     -> "production"
    NODE_HOME    -> "/layers/paketo-buildpacks_node-engine/node"
    NODE_OPTIONS -> "--use-openssl-ca"
    NODE_VERBOSE -> "false"

  Configuring launch environment
    NODE_ENV     -> "production"
    NODE_HOME    -> "/layers/paketo-buildpacks_node-engine/node"
    NODE_OPTIONS -> "--use-openssl-ca"
    NODE_VERBOSE -> "false"

    Writing exec.d/0-optimize-memory
      Calculates available memory based on container limits at launch time.
      Made available in the MEMORY_AVAILABLE environment variable.
    Writing exec.d/1-inspector

Paketo Buildpack for NPM Install 1.3.1
  Resolving installation process
    Process inputs:
      node_modules      -> "Not found"
      npm-cache         -> "Not found"
      package-lock.json -> "Found"

    Selected NPM build process: 'npm ci'

  Executing build environment install process
    Running 'npm ci --unsafe-perm --cache /layers/paketo-buildpacks_npm-install/npm-cache'
      
      added 948 packages, and audited 949 packages in 49s
      
      201 packages are looking for funding
        run `npm fund` for details
      
      2 high severity vulnerabilities
      
      To address all issues (including breaking changes), run:
        npm audit fix --force
      
      Run `npm audit` for details.
      npm notice 
      npm notice New minor version of npm available! 10.2.3 -> 10.4.0
      npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.4.0>
      npm notice Run `npm install -g [email protected]` to update!
      npm notice 
      Completed in 57.917s

  Configuring build environment
    NODE_ENV -> "development"
    PATH     -> "$PATH:/layers/paketo-buildpacks_npm-install/build-modules/node_modules/.bin"

  Generating SBOM for /layers/paketo-buildpacks_npm-install/build-modules
      Completed in 6.994s


Paketo Buildpack for Node Run Script 1.0.15
  Executing build process
    Running 'npm run build:dev'
      
      > [email protected] build:dev
      > NODE_ENV=production npm run build
      
      
      > [email protected] build
      > tsc && vite build --sourcemap=true

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.