From dc9599a084a8ad19c9d5ff32d052a0a4b80076e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick=20Pruneau?= Date: Mon, 23 Feb 2026 12:15:22 -0500 Subject: [PATCH 1/3] added script to change env variables in docker compose --- env.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 env.sh diff --git a/env.sh b/env.sh new file mode 100644 index 0000000..e7cd7be --- /dev/null +++ b/env.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env sh +# ================================================================================ +# File: env.sh +# Description: Replaces environment variables in asset files. +# Usage: Run this script in your terminal, ensuring APP_PREFIX and ASSET_DIRS are set. +# ================================================================================ + +# Set the exit flag to exit immediately if any command fails +set -e + +# Check if APP_PREFIX is set +: "${APP_PREFIX:?APP_PREFIX must be set (e.g. APP_PREFIX='APP_PREFIX_')}" + +# Check if ASSET_DIRS is set +: "${ASSET_DIR:?Must set ASSET_DIR to one path}" + +# Check if the directory exists +if [ ! -d "$ASSET_DIR" ]; then + # If not, display a warning message and skip to the next iteration + echo "Warning: directory '$ASSET_DIR' not found, skipping." + continue +fi + +# Display the current directory being scanned +echo "Scanning directory: $ASSET_DIR" + +# Iterate through each environment variable that starts with APP_PREFIX +env | grep "^${APP_PREFIX}" | while IFS='=' read -r key value; do + # Display the variable being replaced + echo " • Replacing ${key} → ${value}" + + # Use find and sed to replace the variable in all files within the directory + find "$ASSET_DIR" -type f \ + -exec sed -i "s|${key}|${value}|g" {} + +done From 8a321cd88df055185236928a3d1622bcf3f3ff92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick=20Pruneau?= Date: Mon, 23 Feb 2026 12:17:19 -0500 Subject: [PATCH 2/3] added env file for VITE variables --- .env.production | 1 + 1 file changed, 1 insertion(+) create mode 100644 .env.production diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..61b1320 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +VITE_TARGO_BACKEND_URL=PREFIX_BACKEND_URL \ No newline at end of file From 4dac626b81012ca3e9c65d601726553bd9f58653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick=20Pruneau?= Date: Mon, 23 Feb 2026 14:00:50 -0500 Subject: [PATCH 3/3] Modified Dockerfile to add script to modify env vars --- Dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9ec98a1..fa43432 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,10 @@ FROM node:22 AS build WORKDIR /app COPY package*.json ./ -# Set environment variables -ARG BACKEND_URL -ENV VITE_TARGO_BACKEND_URL=$BACKEND_URL # Install dependencies RUN npm install -g @quasar/cli COPY . . -RUN npm install +RUN npm ci RUN npm run build # Step 2 - Move Applicatin to Nginx @@ -16,5 +13,12 @@ FROM nginx:alpine COPY --from=build /app/dist/spa /usr/share/nginx/html RUN mkdir /usr/share/nginx/html/src COPY --from=build /app/src /usr/share/nginx/html/src + +COPY env.sh /docker-entrypoint.d/env.sh +RUN dos2unix /docker-entrypoint.d/env.sh +RUN chmod +x /docker-entrypoint.d/env.sh + +ENTRYPOINT ["/docker-entrypoint.sh"] + EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file