Skip to content

Commit 9433609

Browse files
Merge pull request #69 from clearfunction/fix/docker-build
feat: convert to Bun and fix the Docker build
2 parents af8ae1b + bce46e5 commit 9433609

File tree

11 files changed

+72
-5789
lines changed

11 files changed

+72
-5789
lines changed

.eslintrc.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/main.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v3
10+
uses: actions/checkout@v4
1111

12-
- name: Setup Node.js
13-
uses: actions/setup-node@v3
14-
with:
15-
node-version: '18.x'
12+
- name: Setup Bun
13+
uses: oven-sh/setup-bun@v2
1614

1715
- name: Install dependencies
18-
run: npm install
16+
run: bun install
1917

2018
- name: Unit Tests
2119
run: npm run test
20+
21+
- name: Build
22+
run: npm run build:prod

Dockerfile

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
FROM node:14-alpine as builder
1+
FROM oven/bun:1 AS base
2+
WORKDIR /usr/src/app
23

3-
ARG NODE_ENV=development
4-
ENV NODE_ENV=${NODE_ENV}
4+
FROM base AS install
5+
RUN mkdir -p /temp/dev
6+
COPY package.json bun.lockb /temp/dev/
7+
RUN cd /temp/dev && bun install --frozen-lockfile
58

6-
WORKDIR /usr/src/app
9+
RUN mkdir -p /temp/prod
10+
COPY package.json bun.lockb /temp/prod/
11+
RUN cd /temp/prod && bun install --frozen-lockfile --production
712

8-
COPY package.json package-lock.json tsconfig.json ./
9-
RUN npm install
10-
COPY src ./
11-
RUN npm run tsc
13+
FROM base AS prerelease
14+
COPY --from=install /temp/dev/node_modules node_modules
15+
COPY . .
1216

13-
FROM node:14-alpine
17+
ENV NODE_ENV=production
18+
RUN bun test
19+
RUN bun run build:prod
1420

15-
WORKDIR /usr/src/app
16-
COPY --from=builder /usr/src/app/package.json package.json
17-
COPY --from=builder /usr/src/app/node_modules node_modules
18-
COPY --from=builder /usr/src/app/build build
21+
FROM base AS release
22+
COPY --from=install /temp/prod/node_modules node_modules
23+
COPY --from=prerelease /usr/src/app/build/* build/
24+
COPY --from=prerelease /usr/src/app/package.json .
1925

20-
CMD [ "npm", "run", "start:prod" ]
26+
# run the app
27+
USER bun
28+
EXPOSE 3000/tcp
29+
ENTRYPOINT [ "bun", "run", "start:prod" ]

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@ sequenceDiagram
1818

1919
## Requirements
2020

21-
- NPM
22-
- Node
23-
- Bun (for running locally, so we can run TypeScript directly)
21+
- Bun
2422

2523
## Running Locally
2624

2725
The easiest way to test is to set this up in a standalone Slack instance and
2826
then use a local proxy like [ngrok](https://ngrok.com/).
2927

3028
- Create a Slack application (see Slack Bolt API link below)
31-
- Run `npm run dev` (it defaults to port 3000)
29+
- Run `bun install` to install dependencies
30+
- Run `bun run dev` (it defaults to port 3000)
3231
- Run ngrok to create a proxy to your Bolt app (`ngrok serve 3000`)
3332
- Point your Slack's event subscription to your ngrok URL
3433
- Set up [Sonos Proxy](https://github.com/clearfunction/sonos_proxy_nodejs)

bun.lockb

180 KB
Binary file not shown.

eslint.config.mjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// @ts-check
2+
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
import eslintConfigPrettier from 'eslint-config-prettier';
6+
7+
export default tseslint.config(
8+
eslint.configs.recommended,
9+
...tseslint.configs.strict,
10+
...tseslint.configs.stylistic,
11+
{
12+
rules: {
13+
'@typescript-eslint/no-empty-object-type': [
14+
'error',
15+
{ allowInterfaces: 'always' },
16+
],
17+
},
18+
ignores: ['dist', 'node_modules'],
19+
},
20+
eslintConfigPrettier
21+
);

0 commit comments

Comments
 (0)