Skip to content

Commit 3804b6e

Browse files
authored
Merge branch 'main' into dan/hdx-2622-refactor-tasks
2 parents fae2a8f + 131a1c1 commit 3804b6e

File tree

19 files changed

+240
-283
lines changed

19 files changed

+240
-283
lines changed

.changeset/feat-subpath-config.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@hyperdx/app': minor
3+
---
4+
5+
feat: Add subpath configuration support
6+
7+
This change allows the HyperDX frontend to be served from a subpath (e.g.,
8+
`/hyperdx`). It includes updated Next.js, NGINX, and Traefik configurations,
9+
along with documentation for the new setup.

.changeset/polite-dots-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/api": patch
3+
---
4+
5+
revert: api esbuild

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ HYPERDX_APP_PORT=8080
2020
HYPERDX_APP_URL=http://localhost
2121
HYPERDX_LOG_LEVEL=debug
2222
HYPERDX_OPAMP_PORT=4320
23+
HYPERDX_BASE_PATH=
2324

2425
# Otel/Clickhouse config
2526
HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE=default

docker-compose.dev.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,29 @@ services:
8383
interval: 1s
8484
timeout: 1s
8585
retries: 60
86+
87+
# nginx:
88+
# image: nginx:alpine
89+
# ports:
90+
# - '4040:4040'
91+
# volumes:
92+
# - ./proxy/nginx/nginx.conf.template:/etc/nginx/templates/default.conf.template:ro
93+
# environment:
94+
# HYPERDX_BASE_PATH: ${HYPERDX_BASE_PATH:-/}
95+
# network_mode: host
96+
# restart: always
97+
98+
# traefik:
99+
# image: traefik:latest
100+
# ports:
101+
# - '4040:4040'
102+
# volumes:
103+
# - ./proxy/traefik/traefik.yml:/etc/traefik/traefik.yml:ro
104+
# - ./proxy/traefik/config.yml:/etc/traefik/dynamic/config.yml:ro
105+
# environment:
106+
# HYPERDX_BASE_PATH: ${HYPERDX_BASE_PATH:-/}
107+
# network_mode: host
108+
# restart: always
109+
86110
networks:
87111
internal:

docker/hyperdx/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ ENV NEXT_OUTPUT_STANDALONE true
5050
ENV NEXT_PUBLIC_IS_LOCAL_MODE false
5151
ENV NX_DAEMON=false
5252
RUN npx nx run-many --target=build --projects=@hyperdx/common-utils,@hyperdx/api,@hyperdx/app
53+
RUN rm -rf node_modules && yarn workspaces focus @hyperdx/api --production
54+
5355

5456
# prod ############################################################################################
5557
FROM node:${NODE_VERSION}-alpine AS prod
@@ -66,7 +68,10 @@ USER node
6668

6769
# Set up API and App
6870
WORKDIR /app
69-
COPY --chown=node:node --from=builder /app/packages/api/dist ./packages/api
71+
COPY --chown=node:node --from=builder /app/node_modules ./node_modules
72+
COPY --chown=node:node --from=builder /app/packages/api/build ./packages/api/build
73+
COPY --chown=node:node --from=builder /app/packages/common-utils/dist ./packages/common-utils/dist
74+
COPY --chown=node:node --from=node_base /app/packages/common-utils/node_modules ./packages/common-utils/node_modules
7075
COPY --chown=node:node --from=builder /app/packages/app/.next/standalone ./packages/app
7176
COPY --chown=node:node --from=builder /app/packages/app/.next/static ./packages/app/packages/app/.next/static
7277
COPY --chown=node:node --from=builder /app/packages/app/public ./packages/app/packages/app/public

docker/hyperdx/entry.local.base.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ echo "ClickHouse is ready!"
6767
npx concurrently \
6868
"--kill-others-on-fail" \
6969
"--names=API,APP,ALERT-TASK" \
70-
"PORT=${HYPERDX_API_PORT:-8000} HYPERDX_APP_PORT=${HYPERDX_APP_PORT:-8080} node -r ./packages/api/tracing ./packages/api/index" \
70+
"PORT=${HYPERDX_API_PORT:-8000} HYPERDX_APP_PORT=${HYPERDX_APP_PORT:-8080} node -r ./node_modules/@hyperdx/node-opentelemetry/build/src/tracing ./packages/api/build/index.js" \
7171
"cd ./packages/app/packages/app && HOSTNAME='0.0.0.0' HYPERDX_API_PORT=${HYPERDX_API_PORT:-8000} PORT=${HYPERDX_APP_PORT:-8080} node server.js" \
72-
"node -r ./packages/api/tracing ./packages/api/tasks/index check-alerts" \
72+
"node -r ./node_modules/@hyperdx/node-opentelemetry/build/src/tracing ./packages/api/build/tasks/index.js check-alerts" \
7373
> /var/log/app.log 2>&1 &
7474

7575
echo ""

docker/hyperdx/entry.prod.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ echo ""
1616
npx concurrently \
1717
"--kill-others-on-fail" \
1818
"--names=API,APP,ALERT-TASK" \
19-
"PORT=${HYPERDX_API_PORT:-8000} HYPERDX_APP_PORT=${HYPERDX_APP_PORT:-8080} node -r ./packages/api/tracing ./packages/api/index" \
19+
"PORT=${HYPERDX_API_PORT:-8000} HYPERDX_APP_PORT=${HYPERDX_APP_PORT:-8080} node -r ./node_modules/@hyperdx/node-opentelemetry/build/src/tracing ./packages/api/build/index.js" \
2020
"cd ./packages/app/packages/app && HOSTNAME='0.0.0.0' HYPERDX_API_PORT=${HYPERDX_API_PORT:-8000} PORT=${HYPERDX_APP_PORT:-8080} node server.js" \
21-
"node -r ./packages/api/tracing ./packages/api/tasks/index check-alerts"
21+
"node -r ./node_modules/@hyperdx/node-opentelemetry/build/src/tracing ./packages/api/build/tasks/index.js check-alerts"

packages/api/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ USER node
4949

5050
WORKDIR /app
5151

52-
COPY --chown=node:node --from=builder /app/packages/api/dist ./
52+
COPY --chown=node:node --from=builder /app/node_modules ./node_modules
53+
COPY --chown=node:node --from=builder /app/packages/api/build ./packages/api/build
54+
COPY --chown=node:node --from=builder /app/packages/common-utils/dist ./packages/common-utils/dist
5355

54-
ENTRYPOINT ["node", "-r", "./tracing", "./index"]
56+
ENTRYPOINT ["node", "-r", "@hyperdx/node-opentelemetry/build/src/tracing", "./packages/api/build/index.js"]

packages/api/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"@types/supertest": "^2.0.12",
6464
"@types/swagger-jsdoc": "^6",
6565
"@types/uuid": "^8.3.4",
66-
"esbuild": "^0.25.5",
6766
"jest": "^28.1.3",
6867
"migrate-mongo": "^11.0.0",
6968
"nodemon": "^2.0.20",
@@ -79,10 +78,10 @@
7978
"typescript": "5.9.3"
8079
},
8180
"scripts": {
82-
"start": "node ./dist/index.js",
81+
"start": "node ./build/index.js",
8382
"dev": "DOTENV_CONFIG_PATH=.env.development nodemon --signal SIGTERM -e ts,json --exec 'ts-node' --transpile-only -r tsconfig-paths/register -r dotenv-expand/config -r '@hyperdx/node-opentelemetry/build/src/tracing' ./src/index.ts",
8483
"dev-task": "DOTENV_CONFIG_PATH=.env.development nodemon --signal SIGTERM -e ts,json --exec 'ts-node' --transpile-only -r tsconfig-paths/register -r dotenv-expand/config -r '@hyperdx/node-opentelemetry/build/src/tracing' ./src/tasks/index.ts",
85-
"build": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json && esbuild ../../node_modules/@hyperdx/node-opentelemetry/build/src/tracing --bundle --minify --platform=node --outfile=dist/tracing.js && esbuild ./build/src/index.js ./build/src/tasks/index.js --bundle --minify --platform=node --target=node22 --outdir=dist --alias:@='./src' && mkdir -p dist/opamp && cp -r src/opamp/proto dist/opamp/proto && rimraf ./build",
84+
"build": "rimraf ./build && tsc && tsc-alias && cp -r ./src/opamp/proto ./build/opamp/",
8685
"lint": "npx eslint --quiet . --ext .ts",
8786
"lint:fix": "npx eslint . --ext .ts --fix",
8887
"ci:lint": "yarn lint && yarn tsc --noEmit",

packages/api/src/opamp/utils/protobuf.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ import * as fs from 'fs';
33
import * as path from 'path';
44
import * as protobuf from 'protobufjs';
55

6-
import { IS_PROD } from '@/config';
76
import logger from '@/utils/logger';
87

98
// Define the root path of the proto file
10-
const PROTO_PATH = path.resolve(
11-
__dirname,
12-
`${IS_PROD ? 'opamp' : '..'}/proto/opamp.proto`,
13-
);
9+
const PROTO_PATH = path.resolve(__dirname, '../proto/opamp.proto');
1410

1511
// Load the OpAMP proto definition
1612
let root: protobuf.Root;

0 commit comments

Comments
 (0)