瀏覽代碼

Enable setting the API_SERVER for use with Docker

Signed-off-by: Matt Ray <github@mattray.dev>
Matt Ray 2 年之前
父節點
當前提交
195f779b74
共有 4 個文件被更改,包括 9 次插入4 次删除
  1. 1 0
      ui/Dockerfile
  2. 4 0
      ui/Dockerfile.cross
  3. 1 1
      ui/default.nginx.conf.template
  4. 3 3
      ui/docker-entrypoint.sh

+ 1 - 0
ui/Dockerfile

@@ -8,6 +8,7 @@ RUN npx parcel build src/index.html
 FROM nginx:alpine
 
 ENV API_PORT=9003
+ENV API_SERVER=0.0.0.0
 ENV UI_PORT=9090
 
 COPY --from=builder /opt/ui/dist /var/www

+ 4 - 0
ui/Dockerfile.cross

@@ -1,5 +1,9 @@
 FROM nginx:alpine
 
+ENV API_PORT=9003
+ENV API_SERVER=0.0.0.0
+ENV UI_PORT=9090
+
 COPY ./dist /var/www
 COPY default.nginx.conf /etc/nginx/conf.d/
 COPY nginx.conf /etc/nginx/

+ 1 - 1
ui/default.nginx.conf.template

@@ -35,7 +35,7 @@ gzip_types
 upstream model {
     # Update to the cost model endpoint
     # Example: host.docker.internal:9003;
-    server 0.0.0.0:${API_PORT};
+    server ${API_SERVER}:${API_PORT};
 }
 
 server {

+ 3 - 3
ui/docker-entrypoint.sh

@@ -4,12 +4,12 @@ set -e
 if [[ ! -z "$BASE_URL_OVERRIDE" ]]; then
     echo "running with BASE_URL=${BASE_URL_OVERRIDE}"
     sed -i "s^{PLACEHOLDER_BASE_URL}^$BASE_URL_OVERRIDE^g" /var/www/*.js
-else 
+else
     echo "running with BASE_URL=${BASE_URL}"
     sed -i "s^{PLACEHOLDER_BASE_URL}^$BASE_URL^g" /var/www/*.js
 fi
 
-envsubst '$API_PORT $UI_PORT' < /etc/nginx/conf.d/default.nginx.conf.template > /etc/nginx/conf.d/default.nginx.conf
+envsubst '$API_PORT $API_SERVER $UI_PORT' < /etc/nginx/conf.d/default.nginx.conf.template > /etc/nginx/conf.d/default.nginx.conf
 
 # Run the parent (nginx) container's entrypoint script
-exec /docker-entrypoint.sh "$@"
+exec /docker-entrypoint.sh "$@"