hyperdx/packages/api/Dockerfile
Warren Lee 470b2c2992
ci: Replace QEMU with native ARM64 runners for release builds (#1952)
## Summary

- **Replace QEMU-emulated multi-platform builds with native ARM64 runners** for both `release.yml` and `release-nightly.yml`, significantly speeding up CI build times
- Each architecture (amd64/arm64) now builds in parallel on native hardware, then a manifest-merge job combines them into a multi-arch Docker tag using `docker buildx imagetools create`
- Migrate from raw Makefile `docker buildx build` commands to `docker/build-push-action@v6` for better GHA integration

## Changes

### `.github/workflows/release.yml`
- Removed QEMU setup entirely
- Replaced single `release` matrix job with per-image build+publish job pairs:
  - `build-otel-collector` / `publish-otel-collector` (runners: `ubuntu-latest` / `ubuntu-latest-arm64`)
  - `build-app` / `publish-app` (runners: `Large-Runner-x64-32` / `Large-Runner-ARM64-32`)
  - `build-local` / `publish-local` (runners: `Large-Runner-x64-32` / `Large-Runner-ARM64-32`)
  - `build-all-in-one` / `publish-all-in-one` (runners: `Large-Runner-x64-32` / `Large-Runner-ARM64-32`)
- Added `check_version` job to centralize skip-if-exists logic (replaces per-image `docker manifest inspect` in Makefile)
- Removed `check_release_app_pushed` artifact upload/download — `publish-app` now outputs `app_was_pushed` directly
- Scoped GHA build cache per image+arch (e.g. `scope=app-amd64`) to avoid collisions
- All 4 images build in parallel (8 build jobs total), then 4 manifest-merge jobs, then downstream notifications

### `.github/workflows/release-nightly.yml`
- Same native runner pattern (no skip logic since nightly always rebuilds)
- 8 build + 4 publish jobs running in parallel
- Slack failure notification and OTel trace export now depend on publish jobs

### `Makefile`
- Removed `release-*` and `release-*-nightly` targets (lines 203-361) — build logic moved into workflow YAML
- Local `build-*` targets preserved for developer use

## Architecture

Follows the same pattern as `release-ee.yml` in the EE repo:

```
check_changesets → check_version
                        │
    ┌───────────────────┼───────────────────┬───────────────────┐
    v                   v                   v                   v
build-app(x2)   build-otel(x2)    build-local(x2)    build-aio(x2)
    │                   │                   │                   │
publish-app      publish-otel       publish-local      publish-aio
    │                   │                   │                   │
    └─────────┬─────────┴───────────────────┴───────────────────┘
              v
     notify_helm_charts / notify_clickhouse_clickstack
              │
     otel-cicd-action
```

## Notes

- `--squash` flag dropped — it's an experimental Docker feature incompatible with `build-push-action` in multi-platform mode. `sbom` and `provenance` are preserved via action params.
- Per-arch intermediate tags (e.g. `hyperdx/hyperdx:2.21.0-amd64`) remain visible on DockerHub — this is standard practice.
- Dual DockerHub namespace tagging (`hyperdx/*` + `clickhouse/clickstack-*`) preserved.


## Sample Run
https://github.com/hyperdxio/hyperdx/actions/runs/23362835749
2026-03-20 23:04:49 +00:00

86 lines
3.2 KiB
Docker

## base #############################################################################################
FROM node:22.16.0-alpine AS base
WORKDIR /app
COPY .yarn ./.yarn
COPY .yarnrc.yml yarn.lock package.json nx.json .prettierrc .prettierignore ./tsconfig.base.json ./
# Only copy package.json for workspace resolution during yarn install;
# full source is copied in the build stages that need it.
COPY ./packages/common-utils/package.json ./packages/common-utils/package.json
COPY ./packages/api/jest.config.js ./packages/api/tsconfig.json ./packages/api/tsconfig.build.json ./packages/api/package.json ./packages/api/
COPY ./packages/api/bin ./packages/api/bin
# Use BuildKit cache mount to persist Yarn download cache across builds,
# so unchanged packages aren't re-downloaded even when yarn.lock changes.
RUN --mount=type=cache,target=/root/.yarn/berry/cache,id=yarn-cache \
yarn install --mode=skip-build && yarn cache clean
## dev #############################################################################################
FROM base AS dev
COPY ./packages/common-utils ./packages/common-utils
EXPOSE 8000
ENTRYPOINT ["npx", "nx", "run", "@hyperdx/api:dev"]
## common-utils-builder ############################################################################
# Separate stage so common-utils build is cached independently of API source changes.
FROM base AS common-utils-builder
COPY ./packages/common-utils ./packages/common-utils
RUN yarn workspace @hyperdx/common-utils run build
## builder #########################################################################################
FROM base AS builder
# Copy pre-built common-utils from its dedicated build stage
COPY --from=common-utils-builder /app/packages/common-utils ./packages/common-utils
COPY ./packages/api/src ./packages/api/src
RUN yarn workspace @hyperdx/api run build
RUN --mount=type=cache,target=/root/.yarn/berry/cache,id=yarn-cache \
rm -rf node_modules && yarn workspaces focus @hyperdx/api --production
## prod ############################################################################################
FROM node:22.16.0-alpine AS prod
LABEL org.opencontainers.image.vendor="HyperDX" \
org.opencontainers.image.title="HyperDX API" \
org.opencontainers.image.description="HyperDX API service for observability platform" \
org.opencontainers.image.source="https://github.com/hyperdxio/hyperdx" \
org.opencontainers.image.licenses="MIT"
ARG CODE_VERSION
ENV CODE_VERSION=$CODE_VERSION
ENV OTEL_RESOURCE_ATTRIBUTES="service.version=$CODE_VERSION"
ENV NODE_ENV production
ARG PORT
ENV PORT=$PORT
EXPOSE ${PORT}
USER node
WORKDIR /app
COPY --chown=node:node --from=builder /app/node_modules ./node_modules
COPY --chown=node:node --from=builder /app/packages/api/build ./packages/api/build
COPY --chown=node:node --from=builder /app/packages/api/bin ./packages/api/bin
COPY --chown=node:node --from=builder /app/packages/common-utils/dist ./packages/common-utils/dist
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD node -e "require('http').get('http://localhost:'+(process.env.PORT||8000)+'/health',r=>r.statusCode===200?process.exit(0):process.exit(1)).on('error',()=>process.exit(1))"
ENTRYPOINT ["./packages/api/bin/hyperdx", "api"]