Initial commit
This commit is contained in:
Executable
+1
@@ -0,0 +1 @@
|
||||
docker build . -t photos-client
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#/bin/bash
|
||||
|
||||
image_name=photos-client
|
||||
container_name=photos-client
|
||||
|
||||
docker stop $container_name
|
||||
docker rm $container_name
|
||||
|
||||
docker run -d -p 3000:80 -e REACT_APP_API_URL=https://photos-api.novox.be --name $container_name $image_name
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
envConfigFile=${1:-./env-config.js}
|
||||
|
||||
|
||||
# Recreate config file
|
||||
rm -rf $envConfigFile
|
||||
touch $envConfigFile
|
||||
|
||||
# Add assignment
|
||||
echo "window._env_ = {" >> $envConfigFile
|
||||
|
||||
# Read each line in .env file
|
||||
# Each line represents key=value pairs
|
||||
while read -r line || [[ -n "$line" ]];
|
||||
do
|
||||
# Split env variables by character `=`
|
||||
if printf '%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
|
||||
value=$(printf '%s\n' "${!varname}")
|
||||
# Otherwise use value from .env file
|
||||
[[ -z $value ]] && value=${varvalue}
|
||||
|
||||
# Append configuration property to JS file
|
||||
echo " $varname: \"$value\"," >> $envConfigFile
|
||||
done < .env
|
||||
|
||||
echo "}" >> $envConfigFile
|
||||
Reference in New Issue
Block a user