FROM node:18-bullseye-slim
# Set working directory for the build
WORKDIR /workspace
# Install minimal system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Use Yarn (v1) to respect the repository's yarn.lock
# Use a specific Yarn 1.x version and force install to avoid conflicts with pre-existing binaries
RUN corepack enable 2>/dev/null || true \
&& corepack prepare yarn@1.22.19 --activate 2>/dev/null || npm install -g yarn@1.22.19 --force 2>/dev/null || true
# Install project dependencies early for better Docker caching
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# Copy the rest of the repository
COPY . .
# Build the project from source (TypeScript compilation if present)
RUN yarn compile-ts || true
# Default command to indicate the image is ready and built from source
CMD ["node", "-e", "console.log('Victory Native container ready (built from source)')"]