I'll improve the docker build eventually, so I'll keep the planned improvs here. But for now it might be better to use the bigger multistage docker file.

# Use the official Bun image
FROM oven/bun:1 AS base
WORKDIR /usr/src/app

# Install dependencies for both backend and frontend
COPY backend/package.json backend/bun.lockb frontend/package.json frontend/bun.lockb /usr/src/app/
RUN bun install --production --cwd backend && \
    bun install --production --cwd frontend

# Build the frontend project
COPY frontend/ /usr/src/app/frontend
RUN bun run --cwd frontend build

# Prepare for final release
FROM oven/bun:1 AS release
WORKDIR /usr/src/app

# Copy production dependencies
COPY --from=base /usr/src/app/backend/node_modules backend/node_modules
COPY --from=base /usr/src/app/frontend/node_modules frontend/node_modules

# Copy backend source code
COPY backend/ backend/

# Copy the built frontend assets into the backend public directory
COPY --from=base /usr/src/app/frontend/dist backend/public

# Set the entrypoint to run the backend server
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "backend/src/server.ts" ]
