|
| 1 | +# syntax=docker/dockerfile:1.20 |
| 2 | +FROM node:24-slim AS base |
| 3 | + |
| 4 | +WORKDIR /app |
| 5 | + |
| 6 | +ENV NEXT_TELEMETRY_DISABLED=1 \ |
| 7 | + TURBO_TELEMETRY_DISABLED=1 \ |
| 8 | + PNPM_HOME="/pnpm" \ |
| 9 | + PATH="/pnpm:$PATH" |
| 10 | + |
| 11 | +RUN npm install -g corepack@0.31.0 && \ |
| 12 | + corepack enable |
| 13 | + |
| 14 | +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./ |
| 15 | +COPY patches/ ./patches/ |
| 16 | + |
| 17 | +RUN PNPM_VERSION=$(node -p "require('./package.json').packageManager.split('@')[1]") && \ |
| 18 | + corepack prepare "pnpm@${PNPM_VERSION}" --activate |
| 19 | + |
| 20 | + |
| 21 | +FROM base AS builder |
| 22 | + |
| 23 | +ENV NODE_OPTIONS="--max_old_space_size=4096" |
| 24 | +ENV TURBO_CACHE_DIR="/app/.turbo" |
| 25 | + |
| 26 | +COPY docker/run-turbo-build.sh /usr/local/bin/run-turbo-build.sh |
| 27 | + |
| 28 | +RUN chmod +x /usr/local/bin/run-turbo-build.sh |
| 29 | + |
| 30 | +# Manifests first (change less often than source). @agenta/mobile has no |
| 31 | +# workspace package deps in WP1; add packages/*/package.json copies here when |
| 32 | +# WP2+ introduces @agenta/* imports. |
| 33 | +COPY mobile/package.json ./mobile/package.json |
| 34 | + |
| 35 | +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ |
| 36 | + pnpm fetch --frozen-lockfile |
| 37 | + |
| 38 | +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ |
| 39 | + pnpm install --frozen-lockfile --offline |
| 40 | + |
| 41 | +COPY mobile/ ./mobile/ |
| 42 | + |
| 43 | +RUN --mount=type=cache,id=turbo-mobile,target=/app/.turbo \ |
| 44 | + --mount=type=cache,id=nextjs-mobile,target=/app/mobile/.next/cache \ |
| 45 | + --mount=type=secret,id=turbo_team,required=false \ |
| 46 | + --mount=type=secret,id=turbo_token,required=false \ |
| 47 | + /usr/local/bin/run-turbo-build.sh @agenta/mobile |
| 48 | + |
| 49 | + |
| 50 | +FROM node:24-slim AS runner |
| 51 | + |
| 52 | +ARG BUILD_DATE |
| 53 | +ARG VCS_REF |
| 54 | +ARG VERSION=0.0.0 |
| 55 | + |
| 56 | +WORKDIR /app |
| 57 | + |
| 58 | +ENV NEXT_TELEMETRY_DISABLED=1 \ |
| 59 | + NODE_ENV=production |
| 60 | + |
| 61 | +RUN groupadd --gid 10001 agenta && \ |
| 62 | + useradd --uid 10001 --gid 10001 --shell /bin/false --create-home agenta |
| 63 | + |
| 64 | +# web/entrypoint.sh (set -e) does `mkdir -p /app/<license>/public` before |
| 65 | +# writing __env.js and mirroring it into mobile/public. This image ships only |
| 66 | +# mobile/ and /app is root-owned, so pre-create both license dirs writable |
| 67 | +# for the runtime user or the container exits at startup. |
| 68 | +RUN mkdir -p /app/oss/public /app/ee/public && \ |
| 69 | + chown -R agenta:agenta /app/oss /app/ee |
| 70 | + |
| 71 | +COPY --chown=agenta:agenta --from=builder /app/mobile/.next/standalone /app |
| 72 | +COPY --chown=agenta:agenta --from=builder /app/mobile/.next/static /app/mobile/.next/static |
| 73 | +COPY --chown=agenta:agenta --from=builder /app/mobile/public /app/mobile/public |
| 74 | +COPY --chown=agenta:agenta ./entrypoint.sh /app/entrypoint.sh |
| 75 | + |
| 76 | +USER 10001 |
| 77 | + |
| 78 | +LABEL org.opencontainers.image.title="agenta-web-mobile" \ |
| 79 | + org.opencontainers.image.description="Agenta Mobile Web GH runtime image" \ |
| 80 | + org.opencontainers.image.version="${VERSION}" \ |
| 81 | + org.opencontainers.image.revision="${VCS_REF}" \ |
| 82 | + org.opencontainers.image.created="${BUILD_DATE}" |
| 83 | + |
| 84 | +ENTRYPOINT ["/app/entrypoint.sh"] |
| 85 | +CMD ["node", "mobile/server.js"] |
| 86 | +EXPOSE 3000 |
0 commit comments