Replies: 4 comments 17 replies
-
Forgive my ignorance as I've not delved into SSR yet, but does reading |
Beta Was this translation helpful? Give feedback.
-
Actually the Modern.js can also load In my understanding, both build-time injection and runtime injection need to exist. For example, to inject build information at build time like version, buildType, you need to keep SSR and CSR consistent, then we can use And if the values of RUNTIME_TYPE are different for testing, development, and A/B testing. we can use maybe I can give a demo for you tomorrow. Or is there something unsatisfactory about this approach? |
Beta Was this translation helpful? Give feedback.
-
根据我的经验,如果框架不被支持,如纯 nginx + html 或其它等等,在我以往使用 docker 以及 k8s 中,我建议这样做。 1、创建一个 json 文件,程序中读取这个 json 文件(非编译级别,基于动态加载, 如fetch等等) ```shell
#!/bin/bash
set -e
config_origin="/etc/nginx/conf.c"
config_target="/etc/nginx/conf.d"
# export RESOLVER_KUBERNETES_DNS="resolver kube-dns.kube-system valid=10s;"
mkdir -p $config_origin
mkdir -p $config_target
for conf in `ls ${config_origin} | grep .conf` ; do
cp -r ${config_origin}/${conf} ${config_target}
# envsubst '${RESOLVER_KUBERNETES_DNS}' < ${config_origin}/${conf} > ${config_target}/${conf}
# envsubst < ${config_origin}/${conf} > ${config_target}/${conf}
done
composition_origin="/etc/nginx/conf.j"
composition_target="/usr/share/nginx/scanComposition"
mkdir -p $composition_origin
mkdir -p $composition_target
for json in `ls ${composition_origin} | grep .json` ; do
envsubst < ${composition_origin}/${json} > ${composition_target}/${json}
done
system_environment=$(env | jq -nR 'def parse: capture("(?<key>[^=]*)=(?<value>.*)");reduce inputs as $line ({}; ($line | parse) as $p | .[$p.key] = ($p.value) )')
echo ${system_environment} > /usr/share/nginx/html/system.environment.json
cat > /usr/share/nginx/html/system.environment.js <<EOF
(function(win){
win.systemEnvironment=${system_environment};
})(window);
EOF
exec "$@"
|
Beta Was this translation helpful? Give feedback.
-
This problem seems difficult to solve alone from the framework, mainly need to container to work. In fact, the environment variables and String Replace in server, I think the @lanmingle provided the good method.. However, it seems that you cannot fully control the entire deployment process. It may have been possible to provide a Hook for developers to choose to pass static resources through and process them, but it is not currently available. I don't know how you host the MF Bundle, if you use modern.js to host it, you can try:
|
Beta Was this translation helpful? Give feedback.
-
I was wondering if there is a way for the SSR, since it appears to be node js to insert and build the configuration values correctly.
Basically Next JS seems to have a system to use their server to inject env variables in to the build that is serves as SSR which allows a
build once - deploy many
using the same docker image: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#runtime-environment-variables.Basically we are struggling with deployment of the application across many different lines for testing and production because the pipeline that was built seems to expect the
build once - deploy many
feature for servers. Another team handles building deployment tools and we are able to deploy and see our application but we cannot adjust values for each line using their system. It use HELM charts and values to control ENV variables and it seems to work just fine with Next JS.We decided to go with Modern JS because it handles our MFE framework with Module Federation much better. It also might make it more of an issue because we expose components instead of pages for inclusion in our other applications so not sure if this is easily handled.
Hoping I get a response from someone because right now this is a show stopper for us.
Thanks,
Brian
Beta Was this translation helpful? Give feedback.
All reactions