Skip to content

Commit 326ea42

Browse files
authored
fix: watcher image (#70)
* fix: watcher image * fix * fix
1 parent c958e1d commit 326ea42

File tree

13 files changed

+128
-35
lines changed

13 files changed

+128
-35
lines changed

apps/watcher/Dockerfile

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1-
FROM node:22-slim AS build
2-
1+
FROM node:22-slim AS base
2+
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
33
WORKDIR /app
44

5-
# Copy monorepo root files
6-
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc* ./
7-
8-
# Copy workspace package manifests
9-
COPY apps/watcher/package.json ./apps/watcher/
10-
COPY packages/shared/package.json ./packages/shared/
11-
COPY packages/backend/package.json ./packages/backend/
5+
# Prune monorepo to only watcher's dependencies
6+
FROM base AS pruner
7+
COPY . .
8+
RUN pnpm dlx turbo prune @clawe/watcher --docker
129

13-
# Install pnpm and fetch dependencies
14-
RUN corepack enable && corepack prepare pnpm@latest --activate
10+
# Install dependencies (cached unless package.json/lockfile changes)
11+
FROM base AS deps
12+
COPY --from=pruner /app/out/json/ .
1513
RUN pnpm install --frozen-lockfile
1614

17-
# Copy source and build
18-
COPY packages/shared/ ./packages/shared/
19-
COPY packages/backend/ ./packages/backend/
20-
COPY apps/watcher/ ./apps/watcher/
15+
# Build the app
16+
FROM base AS builder
17+
COPY --from=deps /app/ .
18+
COPY --from=pruner /app/out/full/ .
2119
RUN pnpm build --filter=@clawe/watcher
2220

23-
# Deploy: extract watcher with all production deps into /app/deploy
21+
# Extract watcher with production deps only
2422
RUN pnpm --filter=@clawe/watcher --prod deploy deploy
2523

26-
# --- Production image ---
24+
# Production runner
2725
FROM node:22-slim
28-
2926
WORKDIR /app
30-
31-
COPY --from=build /app/deploy .
32-
3327
ENV NODE_ENV=production
3428

29+
COPY --from=builder /app/deploy .
30+
3531
CMD ["node", "dist/index.js"]

apps/watcher/eslint.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { nodeConfig } from "@clawe/eslint-config/node";
2+
3+
/** @type {import("eslint").Linter.Config} */
4+
export default nodeConfig;

apps/watcher/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
"version": "0.1.0",
44
"private": true,
55
"type": "module",
6+
"files": [
7+
"dist"
8+
],
69
"scripts": {
710
"dev": "tsx watch src/index.ts",
811
"start": "node dist/index.js",
912
"build": "tsc",
13+
"lint": "eslint . --max-warnings 0",
14+
"lint:fix": "eslint . --fix --max-warnings 0",
1015
"check-types": "tsc --noEmit",
1116
"test": "vitest run",
1217
"test:watch": "vitest"
@@ -17,7 +22,9 @@
1722
"convex": "^1.21.0"
1823
},
1924
"devDependencies": {
25+
"@clawe/eslint-config": "workspace:*",
2026
"@clawe/typescript-config": "workspace:*",
27+
"eslint": "^9.39.1",
2128
"@types/node": "^22.0.0",
2229
"tsx": "^4.19.0",
2330
"typescript": "5.9.2",

packages/backend/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "0.1.0",
44
"private": true,
55
"type": "module",
6+
"files": [
7+
"convex"
8+
],
69
"exports": {
710
".": {
811
"types": "./convex/_generated/api.d.ts",

packages/eslint-config/node.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import globals from "globals";
2+
import nodePlugin from "eslint-plugin-n";
23
import { config as baseConfig } from "./base.js";
34

45
/**
@@ -9,11 +10,15 @@ import { config as baseConfig } from "./base.js";
910
export const nodeConfig = [
1011
...baseConfig,
1112
{
13+
plugins: { n: nodePlugin },
1214
languageOptions: {
1315
globals: {
1416
...globals.node,
1517
},
1618
},
19+
rules: {
20+
"n/file-extension-in-import": ["error", "always"],
21+
},
1722
},
1823
{
1924
ignores: ["dist/**"],

packages/eslint-config/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@next/eslint-plugin-next": "^15.5.0",
1515
"eslint": "^9.39.1",
1616
"eslint-config-prettier": "^10.1.1",
17+
"eslint-plugin-n": "^17.24.0",
1718
"eslint-plugin-only-warn": "^1.1.0",
1819
"eslint-plugin-react": "^7.37.5",
1920
"eslint-plugin-react-hooks": "^5.2.0",

packages/shared/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "0.1.0",
44
"private": true,
55
"type": "module",
6+
"files": [
7+
"dist"
8+
],
69
"exports": {
710
"./squadhub": {
811
"types": "./dist/squadhub/index.d.ts",

packages/shared/src/squadhub/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
GatewayHealthResult,
88
TelegramProbeResult,
99
PairingRequest,
10-
} from "./types";
10+
} from "./types.js";
1111

1212
export type SquadhubConnection = {
1313
squadhubUrl: string;

packages/shared/src/squadhub/gateway-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
ConnectParams,
66
HelloOkResponse,
77
ChatEvent,
8-
} from "./gateway-types";
8+
} from "./gateway-types.js";
99

1010
type PendingRequest = {
1111
resolve: (value: unknown) => void;

packages/shared/src/squadhub/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export {
1414
listPairingRequests,
1515
approvePairingCode,
1616
parseToolText,
17-
} from "./client";
17+
} from "./client.js";
1818
export type {
1919
SquadhubConnection,
2020
CronJob,
@@ -27,12 +27,12 @@ export type {
2727
CronDelivery,
2828
CronPayload,
2929
CronJobState,
30-
} from "./client";
30+
} from "./client.js";
3131

3232
// Gateway Client
33-
export { GatewayClient, createGatewayClient } from "./gateway-client";
34-
export type { GatewayClientOptions } from "./gateway-client";
35-
export { getSharedClient } from "./shared-client";
33+
export { GatewayClient, createGatewayClient } from "./gateway-client.js";
34+
export type { GatewayClientOptions } from "./gateway-client.js";
35+
export { getSharedClient } from "./shared-client.js";
3636

3737
// Types
3838
export type {
@@ -46,7 +46,7 @@ export type {
4646
GatewayHealthResult,
4747
TelegramProbeResult,
4848
PairingRequest,
49-
} from "./types";
49+
} from "./types.js";
5050

5151
// Gateway Types
5252
export type {
@@ -75,4 +75,4 @@ export type {
7575
ChatHistoryResponse,
7676
SSEEventType,
7777
SSEEvent,
78-
} from "./gateway-types";
78+
} from "./gateway-types.js";

0 commit comments

Comments
 (0)