diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f965aed --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +node_modules +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +README.md +LICENSE +.vscode +Makefile +helm-charts +.env +.editorconfig +.idea +coverage* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e6c598a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM oven/bun:1 AS base +WORKDIR /app + +COPY package.json bun.lockb ./ +RUN bun install --frozen-lockfile + +COPY . . + +ENV NODE_ENV=production +RUN bun run check-types + +RUN bun build --compile --minify --sourcemap ./src/index.ts --outfile app + +FROM base AS release +USER bun +EXPOSE 3000/tcp +COPY --from=base /app/app . +ENTRYPOINT ["./app"] diff --git a/package.json b/package.json index 33a01bb..23cbbd7 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "module": "src/index.ts", "type": "module", "scripts": { - "start": "bun run src/index.ts" + "start": "bun run src/index.ts", + "check-types": "tsc --noEmit" }, "devDependencies": { "@types/bun": "latest", diff --git a/src/index.ts b/src/index.ts index 26492d7..fc99f84 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,18 +15,16 @@ const program = Effect.gen(function* () { const mainScope = yield* Scope.make(); const client = yield* pipe(mqttService.connect(), Scope.extend(mainScope)); - yield* Stream.zipLatest( - temperatureSensorsService.averageTemperatureStream(client), - faikinAcService.targetTemperatureStream(client), - ).pipe( - Stream.tap(([temperature, target]) => - Console.log(`Temperature: ${temperature}, Target: ${target}`), - ), - Stream.mapEffect(([temperature, target]) => - faikinAcService.sendControlCommand(client, { env: temperature, target }), - ), - Stream.runDrain, - ); + + yield* temperatureSensorsService + .averageTemperatureStream(client) + .pipe( + Stream.tap((temperature) => Console.log(`Temperature: ${temperature}`)), + Stream.mapEffect((temperature) => + faikinAcService.sendControlCommand(client, { env: temperature }), + ), + Stream.runDrain, + ); yield* Scope.close(mainScope, Exit.void); });