diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1acb9c4..93869c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build and Push Multi-Platform Docker Image +name: Build Docker Image on: workflow_dispatch: diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 758bd73..e505f6f 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -1,4 +1,4 @@ -name: Build and Push Multi-Platform Docker Image +name: Build Nightly Docker Image on: push: diff --git a/Dockerfile b/Dockerfile index 6e1b20b..3f440dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,8 @@ COPY nginx.conf /etc/nginx/nginx.conf.template COPY dist /var/www/public +COPY config.js.template /var/www/public/config.js.template + COPY docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh diff --git a/config.js.template b/config.js.template new file mode 100644 index 0000000..5bfb8a9 --- /dev/null +++ b/config.js.template @@ -0,0 +1,4 @@ +window._env_ = { + API_URL: "${API_URL}", + API_OFFICE_URL: "${API_OFFICE_URL}" +}; diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 44b8c56..a945727 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,8 +1,7 @@ #!/bin/bash set -e - -# 使用envsubst命令替换nginx.conf.template文件中的环境变量 -envsubst '$API_BASE_URL $API_DRAWIO_URL $API_OFFICE_URL' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf - -# 启动Nginx +echo "API_URL: $API_URL" +echo "API_OFFICE_URL: $API_OFFICE_URL" +envsubst '${API_URL} ${API_OFFICE_URL}' < /var/www/public/config.js.template > /var/www/public/config.js +cat /var/www/public/config.js exec "$@" diff --git a/public/config.js b/public/config.js new file mode 100644 index 0000000..64157ba --- /dev/null +++ b/public/config.js @@ -0,0 +1,4 @@ +window._env_ = { + API_URL: "", + API_OFFICE_URL: "", +}; diff --git a/public/index.html b/public/index.html index 4dfaa70..23a8500 100644 --- a/public/index.html +++ b/public/index.html @@ -35,7 +35,7 @@ <%= webpackConfig.name %> - +