sangwaritaxi_website/Dockerfile

48 lines
933 B
Docker

# ------------------------
# Build stage
# ------------------------
FROM node:22-bullseye AS builder
ARG API_BASE_URL="https://navigolabs.com/api"
# 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"]