Skip to content

Commit

Permalink
feat: add docker prod build stages and publish prod builds (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
wrn14897 authored Sep 16, 2023
1 parent 914d49a commit 8369243
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 44 deletions.
6 changes: 0 additions & 6 deletions .changeset/good-scissors-promise.md

This file was deleted.

2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
IMAGE_NAME=ghcr.io/hyperdxio/hyperdx
IMAGE_VERSION=1.0.3
IMAGE_VERSION=1.1.0
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ ci-int:

.PHONY: build-and-push-ghcr
build-and-push-ghcr:
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/hostmetrics -t ${IMAGE_NAME}:${LATEST_VERSION}-hostmetrics --target dev --push &
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/ingestor -t ${IMAGE_NAME}:${LATEST_VERSION}-ingestor --target dev --push &
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/otel-collector -t ${IMAGE_NAME}:${LATEST_VERSION}-otel-collector --target dev --push &
docker buildx build --platform ${BUILD_PLATFORMS} . -f ./packages/miner/Dockerfile -t ${IMAGE_NAME}:${LATEST_VERSION}-miner --target dev --push &
docker buildx build --platform ${BUILD_PLATFORMS} . -f ./packages/api/Dockerfile -t ${IMAGE_NAME}:${LATEST_VERSION}-api --target dev --push &
docker buildx build --platform ${BUILD_PLATFORMS} . -f ./packages/app/Dockerfile -t ${IMAGE_NAME}:${LATEST_VERSION}-app --target prod --push
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/hostmetrics -t ${IMAGE_NAME}:${LATEST_VERSION}-hostmetrics --target prod --push &
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/ingestor -t ${IMAGE_NAME}:${LATEST_VERSION}-ingestor --target prod --push &
docker buildx build --platform ${BUILD_PLATFORMS} ./docker/otel-collector -t ${IMAGE_NAME}:${LATEST_VERSION}-otel-collector --target prod --push &
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 &
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 &
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


25 changes: 2 additions & 23 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ services:
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
OTEL_LOG_LEVEL: ERROR
OTEL_SERVICE_NAME: hdx-oss-miner
volumes:
- ./packages/miner/src:/app/src
ports:
- 5123:5123
networks:
- internal
hostmetrics:
image: ${IMAGE_NAME}:${IMAGE_VERSION}-hostmetrics
container_name: hdx-oss-hostmetrics
volumes:
- ./docker/hostmetrics/config.dev.yaml:/etc/otelcol-contrib/config.yaml
environment:
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
OTEL_SERVICE_NAME: hostmetrics
Expand All @@ -30,7 +26,6 @@ services:
image: ${IMAGE_NAME}:${IMAGE_VERSION}-ingestor
container_name: hdx-oss-ingestor
volumes:
- ./docker/ingestor:/app
- .volumes/ingestor_data:/var/lib/vector
ports:
- 8002:8002 # http-generic
Expand Down Expand Up @@ -63,8 +58,6 @@ services:
otel-collector:
image: ${IMAGE_NAME}:${IMAGE_VERSION}-otel-collector
container_name: hdx-oss-otel-collector
volumes:
- ./docker/otel-collector/config.yaml:/etc/otelcol-contrib/config.yaml
ports:
- '13133:13133' # health_check extension
- '1888:1888' # pprof extension
Expand Down Expand Up @@ -93,8 +86,6 @@ services:
PORT: 8001
REDIS_URL: redis://redis:6379
SERVER_URL: 'http://localhost:8000'
volumes:
- ./packages/api/src:/app/src
networks:
- internal
depends_on:
Expand All @@ -104,8 +95,8 @@ services:
task-check-alerts:
image: ${IMAGE_NAME}:${IMAGE_VERSION}-api
container_name: hdx-oss-task-check-alerts
entrypoint: 'yarn'
command: 'dev:task check-alerts'
entrypoint: 'node'
command: './build/tasks/index.js check-alerts'
environment:
APP_TYPE: 'scheduled-task'
CLICKHOUSE_HOST: http://ch-server:8123
Expand All @@ -124,8 +115,6 @@ services:
OTEL_EXPORTER_OTLP_ENDPOINT: 'http://otel-collector:4318'
OTEL_SERVICE_NAME: 'hdx-oss-task-check-alerts'
REDIS_URL: redis://redis:6379
volumes:
- ./packages/api/src:/app/src
restart: always
networks:
- internal
Expand Down Expand Up @@ -161,8 +150,6 @@ services:
REDIS_URL: redis://redis:6379
SERVER_URL: 'http://localhost:8000'
USAGE_STATS_ENABLED: ${USAGE_STATS_ENABLED:-true}
volumes:
- ./packages/api/src:/app/src
networks:
- internal
depends_on:
Expand All @@ -181,14 +168,6 @@ services:
NEXT_PUBLIC_HDX_SERVICE_NAME: 'hdx-oss-app'
NODE_ENV: development
PORT: 8080
volumes:
- ./packages/app/pages:/app/pages
- ./packages/app/public:/app/public
- ./packages/app/src:/app/src
- ./packages/app/styles:/app/styles
- ./packages/app/mdx.d.ts:/app/mdx.d.ts
- ./packages/app/next-env.d.ts:/app/next-env.d.ts
- ./packages/app/next.config.js:/app/next.config.js
networks:
- internal
depends_on:
Expand Down
6 changes: 6 additions & 0 deletions docker/hostmetrics/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ FROM otel/opentelemetry-collector-contrib:0.83.0 AS base
FROM base as dev

COPY ./config.dev.yaml /etc/otelcol-contrib/config.yaml


## prod #############################################################################################
FROM base as prod

COPY ./config.dev.yaml /etc/otelcol-contrib/config.yaml
7 changes: 7 additions & 0 deletions docker/ingestor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ EXPOSE 8002 8686

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


## prod #############################################################################################
FROM base as prod

EXPOSE 8002 8686

ENTRYPOINT ["vector", "-c", "http-server.core.toml", "-c", "http-server.sinks.toml", "--require-healthy", "true"]
10 changes: 9 additions & 1 deletion docker/otel-collector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
FROM otel/opentelemetry-collector-contrib:0.83.0 AS base


## dev #############################################################################################
## dev ##############################################################################################
FROM base as dev

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

EXPOSE 1888 4317 4318 55679 13133


## prod #############################################################################################
FROM base as prod

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

EXPOSE 1888 4317 4318 55679 13133
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "1.0.3",
"version": "1.1.0",
"license": "MIT",
"workspaces": [
"packages/*"
Expand Down
7 changes: 7 additions & 0 deletions packages/api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @hyperdx/api

## 1.1.0

### Minor Changes

- 914d49a: feat: introduce usage-stats service
28 changes: 28 additions & 0 deletions packages/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,31 @@ EXPOSE 8000

ENTRYPOINT ["yarn"]
CMD ["dev"]


## builder #########################################################################################

FROM base AS builder

COPY ./packages/api/src ./src
RUN yarn run build


## prod ############################################################################################

FROM node:18.15.0-alpine AS prod

ARG CODE_VERSION

ENV CODE_VERSION=$CODE_VERSION

EXPOSE 8000

USER node

WORKDIR /app

COPY --chown=node:node --from=builder /app/build ./build
COPY --chown=node:node --from=base /app/node_modules ./node_modules

ENTRYPOINT ["node", "-r", "@hyperdx/node-opentelemetry/build/src/tracing", "./build/index.js"]
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperdx/api",
"version": "1.0.3",
"version": "1.1.0",
"license": "MIT",
"private": true,
"engines": {
Expand Down
4 changes: 1 addition & 3 deletions packages/api/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { version } from '../package.json';

const env = process.env;
export const NODE_ENV = env.NODE_ENV as string;

Expand All @@ -8,7 +6,7 @@ export const APP_TYPE = env.APP_TYPE as 'api' | 'aggregator' | 'scheduled-task';
export const CLICKHOUSE_HOST = env.CLICKHOUSE_HOST as string;
export const CLICKHOUSE_PASSWORD = env.CLICKHOUSE_PASSWORD as string;
export const CLICKHOUSE_USER = env.CLICKHOUSE_USER as string;
export const CODE_VERSION = version;
export const CODE_VERSION = env.CODE_VERSION as string;
export const COOKIE_DOMAIN = env.COOKIE_DOMAIN as string; // prod ONLY
export const EXPRESS_SESSION_SECRET = env.EXPRESS_SESSION_SECRET as string;
export const FRONTEND_URL = env.FRONTEND_URL as string;
Expand Down
1 change: 0 additions & 1 deletion packages/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"noUnusedLocals": false,
"noUnusedParameters": false,
"outDir": "build",
"resolveJsonModule": true,
"skipLibCheck": false,
"sourceMap": true,
"strict": true,
Expand Down
7 changes: 7 additions & 0 deletions packages/app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @hyperdx/app

## 1.1.0

### Minor Changes

- 914d49a: feat: introduce usage-stats service
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperdx/app",
"version": "1.0.3",
"version": "1.1.0",
"private": true,
"license": "MIT",
"engines": {
Expand Down

0 comments on commit 8369243

Please sign in to comment.