frontend-containers's People
frontend-containers's Issues
The React example does not work
This is a great article and something I have been looking for in the past. Sadly I cannot get the React example to work (I haven't tried the others.)
Steps to reproduce
- Checkout the repository
- cd into the "react-project" folder
- Execute
docker build -t front-end .
- Execute
docker run -d -p 8080:80 --rm --name front -e ENV=prod -e BASE_URL=/api frontend
- Navigate to http://localhost:8080/
Expected behavior
The values defined as environmental variables in the docker run
command are displayed.
Further remarks
When starting the container the following message is printed: cat: '/usr/share/nginx/html/static/js/*.json': No such file or directory
. The message makes sense there is no config.json
file present.
I must confess that I also don't understand how the config.json file would end up in there.
I also tried adding the config.json
file after the container was created using docker cp src/config.json front:/usr/share/nginx/html/static/js/config.json
and restarting the container. This also didn't change whats shown in the UI.
Replacing the variables works. Using a config.json file with the following content (again directly copied into the container)
{
"ENV": "$ENV",
"BASE_URL": "$BASE_URL"
}
leads to a config.json file with the values replaced. But they are still not shown in the UI.
js file content truncated
File content can be truncated to the first 65535 characters when replacing placeholders.
You should use a tmp file to read from.
#!/usr/bin/env sh
export EXISTING_VARS=$(printenv | awk -F= '{print $1}' | sed 's/^/\$/g' | paste -sd,);
for file in $JSFOLDER;
do
if [ ! -f $file.tmp ]
then
cp $file $file.tmp
fi
cat $file.tmp | envsubst $EXISTING_VARS | tee $file
done
nginx -g 'daemon off;'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.