conditional build
Browse files- Dockerfile +11 -2
Dockerfile
CHANGED
|
@@ -3,6 +3,9 @@
|
|
| 3 |
# =======================
|
| 4 |
FROM node:22-slim AS frontend-builder
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
# Install pnpm globally
|
| 7 |
RUN corepack enable && corepack prepare pnpm@latest --activate
|
| 8 |
|
|
@@ -18,9 +21,15 @@ RUN pnpm install --frozen-lockfile
|
|
| 18 |
# Copy the rest of the frontend source
|
| 19 |
COPY frontend/ ./
|
| 20 |
|
| 21 |
-
# Build frontend
|
| 22 |
ENV VITE_APP_ENV=production
|
| 23 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
# =======================
|
|
|
|
| 3 |
# =======================
|
| 4 |
FROM node:22-slim AS frontend-builder
|
| 5 |
|
| 6 |
+
# Accept SPACE_HOST as build argument
|
| 7 |
+
ARG SPACE_HOST
|
| 8 |
+
|
| 9 |
# Install pnpm globally
|
| 10 |
RUN corepack enable && corepack prepare pnpm@latest --activate
|
| 11 |
|
|
|
|
| 21 |
# Copy the rest of the frontend source
|
| 22 |
COPY frontend/ ./
|
| 23 |
|
| 24 |
+
# Build frontend with SPACE_HOST as VITE_BACKEND_URL if provided
|
| 25 |
ENV VITE_APP_ENV=production
|
| 26 |
+
RUN if [ -n "$SPACE_HOST" ]; then \
|
| 27 |
+
echo "Building with SPACE_HOST: $SPACE_HOST"; \
|
| 28 |
+
VITE_BACKEND_URL="$SPACE_HOST" pnpm build; \
|
| 29 |
+
else \
|
| 30 |
+
echo "Building without SPACE_HOST"; \
|
| 31 |
+
pnpm build; \
|
| 32 |
+
fi
|
| 33 |
|
| 34 |
|
| 35 |
# =======================
|