diff --git a/ci.sh b/ci.sh new file mode 100755 index 0000000..1a42d16 --- /dev/null +++ b/ci.sh @@ -0,0 +1,11 @@ +#!/bin/sh +IMAGE_NAME=ingest-options-aggregates-from-polygon +VERSION=v0.0.1 + +docker login registry.sakal.us + +if [ $? -eq 0 ] +then + docker build -t "registry.sakal.us/${IMAGE_NAME}:${VERSION}" -f ingest.Dockerfile . + docker push "registry.sakal.us/${IMAGE_NAME}:${VERSION}" +fi \ No newline at end of file diff --git a/ingest-on-k8s.yaml b/ingest-on-k8s.yaml new file mode 100644 index 0000000..9c81087 --- /dev/null +++ b/ingest-on-k8s.yaml @@ -0,0 +1,35 @@ +apiVersion: v1 +kind: Pod +metadata: + name: ingest-options-aggregates-from-polygon + namespace: calendar-optimizer + labels: + name: ingest-options-aggregates-from-polygon +spec: + imagePullSecrets: + - name: registry + containers: + - name: ingest-options-aggregates-from-polygon + image: registry.sakal.us/ingest-options-aggregates-from-polygon:v0.0.1 + env: + - name: CLICKHOUSE_HOST + value: http://clickhouse.clickhouse.svc:8123 + - name: CLICKHOUSE_USER + value: avraham + - name: CLICKHOUSE_PASS + value: buginoo + resources: + limits: + memory: "128Mi" + cpu: "500m" +--- +apiVersion: v1 +kind: Secret +metadata: + name: registry + namespace: calendar-optimizer +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: | + eyJhdXRocyI6eyJyZWdpc3RyeS5zYWthbC51cyI6eyJhdXRoIjoiWVhaeVlXaGhiVHBpZFdkcGJt + OVBNU1E9In19fQo= diff --git a/ingest.Dockerfile b/ingest.Dockerfile new file mode 100644 index 0000000..027037f --- /dev/null +++ b/ingest.Dockerfile @@ -0,0 +1,10 @@ +# adapted from example on pnpm.io +FROM node:20-slim AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable +WORKDIR /app +# prod-deps +RUN pnpm add @clickhouse/client +COPY ./src /app +CMD [ "node", "ingest-options-aggregates-from-polygon.mjs" ] \ No newline at end of file diff --git a/src/ingest-options-aggregates-from-polygon.mjs b/src/ingest-options-aggregates-from-polygon.mjs index 07837e0..e54ff14 100644 --- a/src/ingest-options-aggregates-from-polygon.mjs +++ b/src/ingest-options-aggregates-from-polygon.mjs @@ -4,7 +4,11 @@ import { sleep, getPolygonApiKey } from './util.mjs'; //const polygonClient = PolygonClient(apiKey, "https://api.polygon.io", {pagination: false, trace: true,}); // automatically call `next_url` if there is one -const clickhouse = createClickhouseClient({username:'avraham', password:'buginoo'}); +const clickhouse = createClickhouseClient({ + host: process.env.CLICKHOUSE_HOST || 'http://127.0.0.1:8123', + username: process.env.CLICKHOUSE_USER || 'avraham', + password: process.env.CLICKHOUSE_PASS || 'buginoo' +}); const optionAggregatesTableName = "option_aggregates"; async function deleteClickhouseTable(){