Skip to content

Commit 8369243

Browse files
authored
feat: add docker prod build stages and publish prod builds (#4)
1 parent 914d49a commit 8369243

File tree

15 files changed

+77
-44
lines changed

15 files changed

+77
-44
lines changed

.changeset/good-scissors-promise.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
IMAGE_NAME=ghcr.io/hyperdxio/hyperdx
2-
IMAGE_VERSION=1.0.3
2+
IMAGE_VERSION=1.1.0

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ ci-int:
4242

4343
.PHONY: build-and-push-ghcr
4444
build-and-push-ghcr:
45-
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/hostmetrics -t ${IMAGE_NAME}:${LATEST_VERSION}-hostmetrics --target dev --push &
46-
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/ingestor -t ${IMAGE_NAME}:${LATEST_VERSION}-ingestor --target dev --push &
47-
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/otel-collector -t ${IMAGE_NAME}:${LATEST_VERSION}-otel-collector --target dev --push &
48-
docker buildx build --platform ${BUILD_PLATFORMS} . -f ./packages/miner/Dockerfile -t ${IMAGE_NAME}:${LATEST_VERSION}-miner --target dev --push &
49-
docker buildx build --platform ${BUILD_PLATFORMS} . -f ./packages/api/Dockerfile -t ${IMAGE_NAME}:${LATEST_VERSION}-api --target dev --push &
50-
docker buildx build --platform ${BUILD_PLATFORMS} . -f ./packages/app/Dockerfile -t ${IMAGE_NAME}:${LATEST_VERSION}-app --target prod --push
45+
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/hostmetrics -t ${IMAGE_NAME}:${LATEST_VERSION}-hostmetrics --target prod --push &
46+
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/ingestor -t ${IMAGE_NAME}:${LATEST_VERSION}-ingestor --target prod --push &
47+
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/otel-collector -t ${IMAGE_NAME}:${LATEST_VERSION}-otel-collector --target prod --push &
48+
docker buildx build --build-arg CODE_VERSION=${LATEST_VERSION} --platform ${BUILD_PLATFORMS} . -f ./packages/miner/Dockerfile -t ${IMAGE_NAME}:${LATEST_VERSION}-miner --target prod --push &
49+
docker buildx build --build-arg CODE_VERSION=${LATEST_VERSION} --platform ${BUILD_PLATFORMS} . -f ./packages/api/Dockerfile -t ${IMAGE_NAME}:${LATEST_VERSION}-api --target prod --push &
50+
docker buildx build --build-arg CODE_VERSION=${LATEST_VERSION} --platform ${BUILD_PLATFORMS} . -f ./packages/app/Dockerfile -t ${IMAGE_NAME}:${LATEST_VERSION}-app --target prod --push
5151

5252

docker-compose.yml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@ services:
99
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
1010
OTEL_LOG_LEVEL: ERROR
1111
OTEL_SERVICE_NAME: hdx-oss-miner
12-
volumes:
13-
- ./packages/miner/src:/app/src
1412
ports:
1513
- 5123:5123
1614
networks:
1715
- internal
1816
hostmetrics:
1917
image: ${IMAGE_NAME}:${IMAGE_VERSION}-hostmetrics
2018
container_name: hdx-oss-hostmetrics
21-
volumes:
22-
- ./docker/hostmetrics/config.dev.yaml:/etc/otelcol-contrib/config.yaml
2319
environment:
2420
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
2521
OTEL_SERVICE_NAME: hostmetrics
@@ -30,7 +26,6 @@ services:
3026
image: ${IMAGE_NAME}:${IMAGE_VERSION}-ingestor
3127
container_name: hdx-oss-ingestor
3228
volumes:
33-
- ./docker/ingestor:/app
3429
- .volumes/ingestor_data:/var/lib/vector
3530
ports:
3631
- 8002:8002 # http-generic
@@ -63,8 +58,6 @@ services:
6358
otel-collector:
6459
image: ${IMAGE_NAME}:${IMAGE_VERSION}-otel-collector
6560
container_name: hdx-oss-otel-collector
66-
volumes:
67-
- ./docker/otel-collector/config.yaml:/etc/otelcol-contrib/config.yaml
6861
ports:
6962
- '13133:13133' # health_check extension
7063
- '1888:1888' # pprof extension
@@ -93,8 +86,6 @@ services:
9386
PORT: 8001
9487
REDIS_URL: redis://redis:6379
9588
SERVER_URL: 'http://localhost:8000'
96-
volumes:
97-
- ./packages/api/src:/app/src
9889
networks:
9990
- internal
10091
depends_on:
@@ -104,8 +95,8 @@ services:
10495
task-check-alerts:
10596
image: ${IMAGE_NAME}:${IMAGE_VERSION}-api
10697
container_name: hdx-oss-task-check-alerts
107-
entrypoint: 'yarn'
108-
command: 'dev:task check-alerts'
98+
entrypoint: 'node'
99+
command: './build/tasks/index.js check-alerts'
109100
environment:
110101
APP_TYPE: 'scheduled-task'
111102
CLICKHOUSE_HOST: http://ch-server:8123
@@ -124,8 +115,6 @@ services:
124115
OTEL_EXPORTER_OTLP_ENDPOINT: 'http://otel-collector:4318'
125116
OTEL_SERVICE_NAME: 'hdx-oss-task-check-alerts'
126117
REDIS_URL: redis://redis:6379
127-
volumes:
128-
- ./packages/api/src:/app/src
129118
restart: always
130119
networks:
131120
- internal
@@ -161,8 +150,6 @@ services:
161150
REDIS_URL: redis://redis:6379
162151
SERVER_URL: 'http://localhost:8000'
163152
USAGE_STATS_ENABLED: ${USAGE_STATS_ENABLED:-true}
164-
volumes:
165-
- ./packages/api/src:/app/src
166153
networks:
167154
- internal
168155
depends_on:
@@ -181,14 +168,6 @@ services:
181168
NEXT_PUBLIC_HDX_SERVICE_NAME: 'hdx-oss-app'
182169
NODE_ENV: development
183170
PORT: 8080
184-
volumes:
185-
- ./packages/app/pages:/app/pages
186-
- ./packages/app/public:/app/public
187-
- ./packages/app/src:/app/src
188-
- ./packages/app/styles:/app/styles
189-
- ./packages/app/mdx.d.ts:/app/mdx.d.ts
190-
- ./packages/app/next-env.d.ts:/app/next-env.d.ts
191-
- ./packages/app/next.config.js:/app/next.config.js
192171
networks:
193172
- internal
194173
depends_on:

docker/hostmetrics/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ FROM otel/opentelemetry-collector-contrib:0.83.0 AS base
66
FROM base as dev
77

88
COPY ./config.dev.yaml /etc/otelcol-contrib/config.yaml
9+
10+
11+
## prod #############################################################################################
12+
FROM base as prod
13+
14+
COPY ./config.dev.yaml /etc/otelcol-contrib/config.yaml

docker/ingestor/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,10 @@ EXPOSE 8002 8686
1616

1717
ENTRYPOINT ["vector", "-c", "http-server.core.toml", "-c", "http-server.sinks.toml", "--require-healthy", "true"]
1818

19+
20+
## prod #############################################################################################
21+
FROM base as prod
22+
23+
EXPOSE 8002 8686
24+
25+
ENTRYPOINT ["vector", "-c", "http-server.core.toml", "-c", "http-server.sinks.toml", "--require-healthy", "true"]

docker/otel-collector/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
FROM otel/opentelemetry-collector-contrib:0.83.0 AS base
33

44

5-
## dev #############################################################################################
5+
## dev ##############################################################################################
66
FROM base as dev
77

88
COPY ./config.yaml /etc/otelcol-contrib/config.yaml
99

1010
EXPOSE 1888 4317 4318 55679 13133
11+
12+
13+
## prod #############################################################################################
14+
FROM base as prod
15+
16+
COPY ./config.yaml /etc/otelcol-contrib/config.yaml
17+
18+
EXPOSE 1888 4317 4318 55679 13133

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"version": "1.0.3",
3+
"version": "1.1.0",
44
"license": "MIT",
55
"workspaces": [
66
"packages/*"

packages/api/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# @hyperdx/api
2+
3+
## 1.1.0
4+
5+
### Minor Changes
6+
7+
- 914d49a: feat: introduce usage-stats service

packages/api/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,31 @@ EXPOSE 8000
1616

1717
ENTRYPOINT ["yarn"]
1818
CMD ["dev"]
19+
20+
21+
## builder #########################################################################################
22+
23+
FROM base AS builder
24+
25+
COPY ./packages/api/src ./src
26+
RUN yarn run build
27+
28+
29+
## prod ############################################################################################
30+
31+
FROM node:18.15.0-alpine AS prod
32+
33+
ARG CODE_VERSION
34+
35+
ENV CODE_VERSION=$CODE_VERSION
36+
37+
EXPOSE 8000
38+
39+
USER node
40+
41+
WORKDIR /app
42+
43+
COPY --chown=node:node --from=builder /app/build ./build
44+
COPY --chown=node:node --from=base /app/node_modules ./node_modules
45+
46+
ENTRYPOINT ["node", "-r", "@hyperdx/node-opentelemetry/build/src/tracing", "./build/index.js"]

0 commit comments

Comments
 (0)