/ opencodehub / Dockerfile.worker
swadhinbiswas feat: optimize Docker CI/CD builds, refine site-wide UI aesthetic, and remediate secrets · 8/19/2026
c3e5c18
50 lines · 2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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"]