Files
sim/docker/realtime.Dockerfile
2026-04-24 15:59:10 -07:00

53 lines
1.3 KiB
Docker

# ========================================
# Base Stage: Alpine Linux with Bun
# ========================================
FROM oven/bun:1.3.13-alpine AS base
RUN apk add --no-cache libc6-compat curl
# ========================================
# Pruner Stage: Emit a minimal monorepo subset that @sim/realtime depends on
# ========================================
FROM base AS pruner
WORKDIR /app
RUN bun add -g turbo
COPY . .
RUN turbo prune @sim/realtime --docker
# ========================================
# Dependencies Stage: Install Dependencies
# ========================================
FROM base AS deps
WORKDIR /app
COPY --from=pruner /app/out/json/ ./
COPY --from=pruner /app/out/bun.lock ./bun.lock
RUN --mount=type=cache,id=bun-cache,target=/root/.bun/install/cache \
bun install --linker=hoisted --omit=dev --ignore-scripts
# ========================================
# Runner Stage: Run the Socket Server
# ========================================
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production \
PORT=3002 \
HOSTNAME="0.0.0.0"
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
COPY --from=deps --chown=nextjs:nodejs /app ./
COPY --from=pruner --chown=nextjs:nodejs /app/out/full/ ./
USER nextjs
EXPOSE 3002
CMD ["bun", "apps/realtime/src/index.ts"]