FROM oven/bun:1-slim AS base WORKDIR /app LABEL org.opencontainers.image.title="OpenCodeHub Worker" \ org.opencontainers.image.description="Background task worker for OpenCodeHub (queues, webhooks, notifications)." \ org.opencontainers.image.url="https://github.com/swadhinbiswas/OpencodeHub" \ org.opencontainers.image.source="https://github.com/swadhinbiswas/OpencodeHub" \ org.opencontainers.image.licenses="MIT" # ── Dependencies ─────────────────────────────────────────────── FROM base AS prod-deps RUN apt-get update && apt-get install -y --no-install-recommends \ python3 make g++ gcc libc6-dev \ && rm -rf /var/lib/apt/lists/* COPY package.json bun.lock ./ COPY cli/package.json ./cli/package.json RUN bun install --frozen-lockfile --production \ && find /app/node_modules -type d \( -name "test" -o -name "tests" -o -name "docs" -o -name "example" -o -name "examples" \) -prune -exec rm -rf {} + 2>/dev/null || true \ && find /app/node_modules -type f \( -name "*.map" -o -name "*.md" -o -name "*.markdown" \) -delete 2>/dev/null || true # ── Production Worker Runner ─────────────────────────────────── FROM oven/bun:1-slim AS runner WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends \ git \ bash \ ca-certificates \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN mkdir -p /data/repositories /data/storage /data/cache /data/logs && \ chown -R bun:bun /data /app COPY --from=prod-deps --chown=bun:bun /app/node_modules ./node_modules COPY --chown=bun:bun package.json tsconfig.json ./ COPY --chown=bun:bun drizzle.config.ts ./ COPY --chown=bun:bun drizzle ./drizzle COPY --chown=bun:bun src ./src COPY --chown=bun:bun scripts ./scripts COPY --chown=bun:bun docker-entrypoint.sh ./ ENV NODE_ENV=production ENV PROCESS_TYPE=worker ENV DATA_DIR=/data USER bun ENTRYPOINT ["bash", "./docker-entrypoint.sh"]