Skip to content

Commit

Permalink
Added Dockerfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martynas Zilinskas committed Aug 2, 2024
1 parent 581a2eb commit 284d33c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 10 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 284d33c

Please sign in to comment.