diff --git a/Dockerfile b/Dockerfile index 03c32881..bcea4305 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,47 @@ -# Use lightweight Nginx image -FROM scratch +# ------------------------ +# Build stage +# ------------------------ +FROM node:22-bullseye AS builder -# Copy your HTML/CSS/JS files into nginx's web root -COPY . /app/build +ARG API_BASE_URL="https://navigolabs.com/api" -# Start nginx -CMD ["tail", "-f", "/dev/null"] +# Enable Corepack and Yarn 4 +RUN corepack enable && corepack prepare yarn@4.9.2 --activate + +WORKDIR /app + +# Copy Yarn 4 files +COPY package.json yarn.lock .yarnrc.yml ./ +COPY .yarn .yarn + +# Install dependencies (immutable to match lockfile) +RUN yarn install --immutable + +# Copy all source files +COPY . . + +# Pass API URL to Vite +ENV VITE_API_BASE_URL=$API_BASE_URL + +# Build the app +RUN yarn build + + +# ------------------------ +# Production stage +# ------------------------ +FROM node:22-alpine AS production + +WORKDIR /app + +# Copy built files from builder stage +COPY --from=builder /app/dist ./dist + +# Install a lightweight static server +RUN npm install -g serve@14 + +# Expose port (optional but recommended) +EXPOSE 3000 + +# Start the static server +CMD ["serve", "-s", "dist", "-l", "3000"]