# syntax=docker/dockerfile:1.4

FROM oven/bun:1.1.38-slim AS base

LABEL maintainer="floris@xylex.group"
LABEL org.opencontainers.image.source="https://github.com/xylex-group/athena"
LABEL org.opencontainers.image.description="WebSocket Gateway Service for Athena."

ENV NODE_ENV=production \
    TZ=UTC \
    APP_HOME=/usr/src/app

WORKDIR ${APP_HOME}

# Copy manifest and install (no deps beyond Bun stdlib, but keeps cache stable)
COPY package.json bun.lockb* ./
RUN bun install --production --ignore-scripts

# Copy source
COPY src ./src
COPY tsconfig.json ./

USER bun

EXPOSE 7070

HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
    CMD curl -sf http://localhost:7070/health || exit 1

CMD [ "bun", "run", "src/index.ts" ]