diff --git a/server/Dockerfile b/server/Dockerfile index 0753861..ee2a3bd 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -6,18 +6,23 @@ RUN corepack enable COPY package.json pnpm-lock.yaml /app/ WORKDIR /app -FROM base AS prod-deps -RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile - -# install dev dependencies which are needed for building, such as typescript: -FROM base AS build RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile COPY tsconfig.json /app/ COPY src /app/src -RUN pnpm run build +CMD [ "pnpm", "tsx", "src/index.ts" ] + +# FROM base AS prod-deps +# RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile + +# # install dev dependencies which are needed for building, such as typescript: +# FROM base AS build +# RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile +# COPY tsconfig.json /app/ +# COPY src /app/src +# RUN pnpm run build -FROM base -COPY --from=prod-deps /app/node_modules /app/node_modules -COPY --from=build /app/dist /app/dist -WORKDIR /app/dist -CMD [ "node", "index.js" ] \ No newline at end of file +# FROM base +# COPY --from=prod-deps /app/node_modules /app/node_modules +# COPY --from=build /app/dist /app/dist +# WORKDIR /app/dist +# CMD [ "node", "index.js" ] \ No newline at end of file diff --git a/server/package.json b/server/package.json index 0c4d91e..808875d 100644 --- a/server/package.json +++ b/server/package.json @@ -9,11 +9,12 @@ "cli": "tsx src/cli.tsx" }, "dependencies": { - "@clickhouse/client": "^0.2.7", + "@clickhouse/client": "^1.4.1", "@humanwhocodes/env": "^3.0.5", "@sinclair/typebox": "^0.32.5", "@trpc/server": "^10.45.0", "cors": "^2.8.5", + "date-fns": "^3.6.0", "execa": "^9.3.0", "ink": "^4.1.0", "ink-text-input": "^5.0.1", diff --git a/server/pnpm-lock.yaml b/server/pnpm-lock.yaml index 327a778..6c5e6f7 100644 --- a/server/pnpm-lock.yaml +++ b/server/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@clickhouse/client': - specifier: ^0.2.7 - version: 0.2.7 + specifier: ^1.4.1 + version: 1.4.1 '@humanwhocodes/env': specifier: ^3.0.5 version: 3.0.5 @@ -23,6 +23,9 @@ importers: cors: specifier: ^2.8.5 version: 2.8.5 + date-fns: + specifier: ^3.6.0 + version: 3.6.0 execa: specifier: ^9.3.0 version: 9.3.0 @@ -88,11 +91,11 @@ packages: resolution: {integrity: sha512-3yWxPTq3UQ/FY9p1ErPxIyfT64elWaMvM9lIHnaqpyft63tkxodF5aUElYHrdisWve5cETkh1+KBw1yJuW0aRw==} engines: {node: '>=14.13.1'} - '@clickhouse/client-common@0.2.7': - resolution: {integrity: sha512-vgZm+8c5Cu1toIx1/xplF5dEHlCPw+7pJDOOEtLv2CIUVZ0Bl6nGVZ43EWxRdHeah9ivTfoRWhN1zI1PxjH0xQ==} + '@clickhouse/client-common@1.4.1': + resolution: {integrity: sha512-f5eoTrUSDplrMoi3ddeZ0MzGTn0iGMByEQ8j63eVMoBSOI2+F6jEIPcW2tWofT79Rvnn3RRlveYcShiaIiCJyw==} - '@clickhouse/client@0.2.7': - resolution: {integrity: sha512-ZiyarrGngHc+f5AjZSA7mkQfvnE/71jgXk304B0ps8V+aBpE2CsFB6AQmE/Mk2YkP5j+8r/JfG+m0AZWmE27ig==} + '@clickhouse/client@1.4.1': + resolution: {integrity: sha512-12iV+MeykxdQySRFHwaVU+hKUv3JP6kdwOI+z3zzyfPVYHynTlV8emJjjGZR0+VfRaj3PCMuQfryfsJ82nh9WQ==} engines: {node: '>=16'} '@esbuild/aix-ppc64@0.19.11': @@ -610,6 +613,9 @@ packages: csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} + date-fns@3.6.0: + resolution: {integrity: sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==} + debug@4.3.5: resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} engines: {node: '>=6.0'} @@ -1626,11 +1632,11 @@ snapshots: ansi-styles: 6.2.1 is-fullwidth-code-point: 4.0.0 - '@clickhouse/client-common@0.2.7': {} + '@clickhouse/client-common@1.4.1': {} - '@clickhouse/client@0.2.7': + '@clickhouse/client@1.4.1': dependencies: - '@clickhouse/client-common': 0.2.7 + '@clickhouse/client-common': 1.4.1 '@esbuild/aix-ppc64@0.19.11': optional: true @@ -2021,6 +2027,8 @@ snapshots: csstype@3.1.3: {} + date-fns@3.6.0: {} + debug@4.3.5: dependencies: ms: 2.1.2 diff --git a/server/src/lib/clickhouse.ts b/server/src/lib/clickhouse.ts index e1ba563..b959246 100644 --- a/server/src/lib/clickhouse.ts +++ b/server/src/lib/clickhouse.ts @@ -9,18 +9,18 @@ const { CLICKHOUSE_USER, CLICKHOUSE_PASS } = env.required; const CLICKHOUSE_HOST = env.get("CLICKHOUSE_HOST", "http://localhost:8123"); export const clickhouse = createClickhouseClient({ - host: CLICKHOUSE_HOST, + url: CLICKHOUSE_HOST, username: CLICKHOUSE_USER, password: CLICKHOUSE_PASS, keep_alive: { enabled: true, - socket_ttl: 2500, + // socket_ttl: 2500, }, }); export async function query( queryString: string, - format: DataFormat = "JSONEachRow", + format: DataFormat = "JSONEachRow" ): Promise> { return await retry( async () => { @@ -33,6 +33,6 @@ export async function query( }); return await result.json(); }, - { maxRetries: 5 }, + { maxRetries: 5 } ); }