Fail the build if the build arg is wrong

This commit is contained in:
2026-07-16 01:45:23 +03:00
Unverified
parent 5be4bb9b2c
commit bd733a2ae6
+8 -4
View File
@@ -14,12 +14,16 @@ COPY . .
WORKDIR /app
ARG NODE_ENV=production
# Overridable at build time. Must be a real http(s) URL — never a compose ${...} stub.
ARG VITE_API_BASE_URL=https://api.fromchat.ru
ENV NODE_ENV=production
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
# 1.3. Build production assets
RUN npm run frontend:build
# Fail the build if the arg is not a real URL (e.g. unexpanded Compose ${...}).
RUN if ! printf "%s" "${VITE_API_BASE_URL}" | grep -Eq '^https?://'; then \
echo "ERROR: VITE_API_BASE_URL must be an http(s) URL, got: ${VITE_API_BASE_URL}" >&2; \
exit 1; \
fi && \
export NODE_ENV=production VITE_API_BASE_URL && \
npm run frontend:build
# 2. Production web static server