Ver código fonte

feat: 2323 adding version and commit on opencost-ui logs (#2388)

Signed-off-by: Rafael Brito <rafa@stormforge.io>
Rafael Brito 2 anos atrás
pai
commit
f75601fd53
4 arquivos alterados com 19 adições e 0 exclusões
  1. 5 0
      ui/Dockerfile
  2. 5 0
      ui/Dockerfile.cross
  3. 2 0
      ui/docker-entrypoint.sh
  4. 7 0
      ui/justfile

+ 5 - 0
ui/Dockerfile

@@ -7,6 +7,11 @@ RUN npx parcel build src/index.html
 
 FROM nginx:alpine
 
+ARG version=dev
+ARG	commit=HEAD
+ENV VERSION=${version}
+ENV HEAD=${commit}
+
 ENV API_PORT=9003
 ENV API_SERVER=0.0.0.0
 ENV UI_PORT=9090

+ 5 - 0
ui/Dockerfile.cross

@@ -1,5 +1,10 @@
 FROM nginx:alpine
 
+ARG version=dev
+ARG	commit=HEAD
+ENV VERSION=${version}
+ENV HEAD=${commit}
+
 ENV API_PORT=9003
 ENV API_SERVER=0.0.0.0
 ENV UI_PORT=9090

+ 2 - 0
ui/docker-entrypoint.sh

@@ -11,5 +11,7 @@ fi
 
 envsubst '$API_PORT $API_SERVER $UI_PORT' < /etc/nginx/conf.d/default.nginx.conf.template > /etc/nginx/conf.d/default.nginx.conf
 
+echo "Starting ui version $VERSION ($HEAD)"
+
 # Run the parent (nginx) container's entrypoint script
 exec /docker-entrypoint.sh "$@"

+ 7 - 0
ui/justfile

@@ -1,3 +1,6 @@
+version := `../tools/image-tag`
+commit := `git rev-parse --short HEAD`
+
 default:
     just --list
 
@@ -13,6 +16,8 @@ build IMAGETAG: build-local
         -f 'Dockerfile.cross' \
         --provenance=false \
         -t {{IMAGETAG}}-amd64 \
+        --build-arg version={{version}} \
+        --build-arg commit={{commit}} \
         --push \
         .
 
@@ -22,6 +27,8 @@ build IMAGETAG: build-local
         -f 'Dockerfile.cross' \
         --provenance=false \
         -t {{IMAGETAG}}-arm64 \
+        --build-arg version={{version}} \
+        --build-arg commit={{commit}} \
         --push \
         .