Merge branch 'release/nicolas/v1.1' of https://git.targo.ca/Targo/targo_frontend into release/nicolas/v1.1
This commit is contained in:
commit
3156cee577
1
.env.production
Normal file
1
.env.production
Normal file
|
|
@ -0,0 +1 @@
|
|||
VITE_TARGO_BACKEND_URL=PREFIX_BACKEND_URL
|
||||
12
Dockerfile
12
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;"]
|
||||
35
env.sh
Normal file
35
env.sh
Normal file
|
|
@ -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
|
||||
Loading…
Reference in New Issue
Block a user