# Dockerfile for a Bun + Hono + SQLite application

# --- Base Image ---
FROM oven/bun:1-alpine

# --- Environment Variables ---
ENV NODE_ENV=production

# --- Working Directory ---
WORKDIR /app

# --- Copy package.json and bun.lockb to leverage Docker cache ---
COPY package.json bun.lock ./

# --- Install Dependencies ---
# Do not install devDependencies to keep the image small
RUN bun install --frozen-lockfile --production

# --- Copy application source code ---
COPY . .

# --- Create dedicated directory for SQLite database ---
# Declare a VOLUME for the database directory so data persists after container restarts.
RUN mkdir -p /app/data
VOLUME /app/data

# --- Expose Port ---
EXPOSE 3000

# --- Command to run the application ---
# Ensure the Hono app listens on 0.0.0.0
CMD ["bun", "run", "src/index.ts"]
