# syntax=docker/dockerfile:1

# ---------- builder ----------
FROM node:22-slim AS builder

WORKDIR /app

# Install all deps (incl. dev) for the asset build
COPY Landing/package.json Landing/yarn.lock ./
RUN yarn install --frozen-lockfile --production=false

# Copy source and build static assets (vite -> /app/public)
COPY Landing/ ./
RUN yarn build:assets

# Re-install with prod-only deps to slim runtime
RUN rm -rf node_modules \
    && yarn install --frozen-lockfile --production --ignore-scripts \
    && yarn cache clean

# ---------- runtime ----------
FROM node:22-slim AS runtime

WORKDIR /app
ENV NODE_ENV=production

# Copy the slimmed app from builder
COPY --from=builder /app /app

# Railway sets PORT; index.js falls back to 3000 when unset
EXPOSE 8000

CMD ["node", "index.js"]
