You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not quite common to use a Node image for production deployment.
yarn start clearly is using the debug build.
To support a commonly used base image such as nginx, which does not have Node installed, the challenge is how to generate __ENV.js on the fly without Node.
I attached a shell script below that works in a similar way,
#!/bin/sh# react-env.sh
scriptname="./__ENV.js"
sourcename="$1"if [ -z"$sourcename" ];then
current=$(eval "echo \"\$ENVIRONMENT\"")if [ -z"$current" ];then
sourcename=".env"else
sourcename=".env.$current"fifi# Recreate config file
rm -rf "$scriptname"
touch "$scriptname"# Add assignment echo"window.__ENV = {">>"$scriptname"# Read each line in .env file# Each line represents key=value pairswhileread -r line || [ -n"$line" ];doifprintf'%s\n'"$line"| grep -q -e '^#.*';thencontinuefi
[ -z"$line" ] &&continue# Split env variables by character `=`ifprintf'%s\n'"$line"| grep -q -e '=';then
varname=$(printf '%s\n'"$line"| sed -e 's/=.*//')
varvalue=$(printf '%s\n'"$line"| sed -e 's/^[^=]*=//')fi# Read value of current variable if exists as Environment variable
env=$(eval "echo \"\$$varname\"")
value=$(printf '%s\n'"$env")# Otherwise use value from .env file
[ -z"$value" ] && value=${varvalue}# Append configuration property to JS fileecho"$varname: \"$value\",">>"$scriptname"done<"$sourcename"echo"}">>"$scriptname"
It is written in POSIX sh syntax, as many base images don't have bash.
The text was updated successfully, but these errors were encountered:
Currently the steps documented for Docker support do not quite match real world setup,
yarn start
clearly is using the debug build.To support a commonly used base image such as
nginx
, which does not have Node installed, the challenge is how to generate__ENV.js
on the fly without Node.I attached a shell script below that works in a similar way,
It is written in POSIX sh syntax, as many base images don't have bash.
The text was updated successfully, but these errors were encountered: