Skip to content

Commit 2676321

Browse files
committed
Changed how docker container runs. Runtime env is now injected as base64 encoded data URI.
1 parent 0c37ae3 commit 2676321

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM nginx:stable-alpine
22

3+
RUN apk add --update coreutils
4+
35
RUN apk add --no-cache nodejs yarn
46

57
RUN yarn global add @beam-australia/react-env

entrypoint.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ echo "Serializing environment:"
66

77
react-env --dest .
88

9-
# save content of env.js as it will be removed.
10-
subs=$(cat env.js)
9+
envs=$(cat env.js)
1110

12-
rm env.js
11+
echo "$envs"
12+
13+
# save content of env.js as it will be removed.
14+
subs="data:text/javascript;base64,$(base64 -w 0 env.js)"
1315

1416
echo "$subs"
1517

18+
rm env.js
19+
1620
# cat /var/www/index.html
1721

1822
# Substitute the script with src by an equivalent inline script.
19-
sed -i "s~<script src=\"/env.js\"></script>~<script>${subs}</script>~" /var/www/index.html
23+
sed -i "s|<script src=\"/env.js\"></script>|<script src=\"${subs}\"></script>|" /var/www/index.html
2024

2125
# echo 'After substitution'
2226
# cat /var/www/index.html

src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<title>TypeScript React Starter</title>
6-
<script src="env.js"></script>
6+
<script src="/env.js"></script>
77
</head>
88
<body></body>
99
</html>

0 commit comments

Comments
 (0)