Skip to content

Commit

Permalink
Use Task and Bun workspaces instead of nx
Browse files Browse the repository at this point in the history
  • Loading branch information
unkhz committed Aug 4, 2024
1 parent e4e7d3a commit 5cde62f
Show file tree
Hide file tree
Showing 51 changed files with 121 additions and 17,106 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ jobs:
- configurator
- gatherer-http
- gatherer-stdin
- listener
- publisher
node-version: [20]

steps:
- uses: actions/checkout@v4
- uses: arduino/setup-task@v2
with:
version: 2.x
version: 3.38.0
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.1.20
Expand All @@ -45,7 +43,7 @@ jobs:
matrix:
args:
- context: .
image: ghcr.io/unkhz/ruuvipuserrin-base-node
image: ghcr.io/unkhz/ruuvipuserrin-base-bun

uses: ./.github/workflows/build-package.yml
with:
Expand Down Expand Up @@ -96,7 +94,7 @@ jobs:
git add $file
}
update_version_tag ./packages/base-node/.khz-k3s/kustomization.yaml
update_version_tag ./packages/base-bun/.khz-k3s/kustomization.yaml
update_version_tag ./packages/archive/.khz-k3s/kustomization.yaml
update_version_tag ./packages/configurator/.khz-k3s/kustomization.yaml
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Thumbs.db
# Bun
node_modules.bun

# Nx
# Tasks
.env.local

*-secret.yaml
Expand Down
24 changes: 7 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
FROM node:lts-alpine AS buildtime
FROM oven/bun:1.1.20-alpine
WORKDIR /app
COPY package*.json nx.json /app/
COPY package.json bun.lockb /app/

# Add any node packages
# Add any bun packages
COPY packages/archive/*.json /app/packages/archive/
COPY packages/configurator/*.json /app/packages/configurator/
COPY packages/base-node/*.json /app/packages/base-node/
COPY packages/base-bun/*.json /app/packages/base-bun/
COPY packages/common-archive-client/*.json /app/packages/common-archive-client/
COPY packages/common-data/*.json /app/packages/common-data/
COPY packages/common-postgres/*.json /app/packages/common-postgres/

# Install dev deps for buildtime
RUN npm ci
# Remove dev deps for runtime
RUN bun install --frozen-lockfile --production

# Copy source code
COPY packages/archive /app/packages/archive/
COPY packages/configurator /app/packages/configurator/
COPY packages/base-node /app/packages/base-node/
COPY packages/base-bun /app/packages/base-bun/
COPY packages/common-archive-client /app/packages/common-archive-client/
COPY packages/common-data /app/packages/common-data/
COPY packages/common-postgres /app/packages/common-postgres/

# Build any node packages
RUN npx nx run-many --target=node:build --all

# Clean slate for runtime
FROM node:lts-alpine AS runtime
WORKDIR /app
COPY --link --from=buildtime /app/package*.json /app/nx.json /app/
COPY --link --from=buildtime /app/packages /app/packages

# Remove dev deps for runtime
RUN npm ci --omit=dev
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Following shiny tools are used

- [Redis Streams](https://redis.io/docs/data-types/streams/) for durable processing of measurements
- [TimescaleDb](https://www.timescale.com/) for SQL based long term storage of time series data
- [Nx (package based)](https://nx.dev) for monorepo organization and task running
- [Task](https://taskfile.dev/) for task running
- [Bun workspaces](https://bun.sh/docs/install/workspaces) for monorepo organization
- [Bun](https://bun.sh) TypeScript runtime for faster microservices (where necessary APIs are supported)
- [tRPC](https://trpc.io/) type-safe API for exposing database to serverless functions and apps
- [ruuvitag-listener](https://github.com/lautis/ruuvitag-listener) fast readings from Ruuvitag devices, written in Rust
Expand All @@ -28,27 +29,28 @@ Following shiny tools are used
Ensure you have installed following tools in your gateway box (e.g. raspberry pi).

- [Rust](https://rustup.rs/)
- [Node](https://nodejs.org/en/download/)
- [Bun](https://bun.sh/)
- [Redis](https://redis.io/docs/getting-started/installation/install-redis-on-linux/)

Install monorepo dependencies

```
npm install
bun install
```

Run package specific setup scripts

```
npm run setup
task common-data:setup
task infra-redis:setup
```

### Running

Run gateway functionality in gateway box

```
npm run start-gateway
task start-gateway
```

## Architecture
Expand Down
1 change: 1 addition & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tasks:
- task: run_parallel
vars:
TASKS: >
listener:start
gatherer-stdin:start
gatherer-http:start
publisher:start
Expand Down
Binary file added bun.lockb
Binary file not shown.
31 changes: 0 additions & 31 deletions nx.json

This file was deleted.

Loading

0 comments on commit 5cde62f

Please sign in to comment.