Skip to content

Commit

Permalink
Merge pull request #69 from clearfunction/fix/docker-build
Browse files Browse the repository at this point in the history
feat: convert to Bun and fix the Docker build
  • Loading branch information
brianlankford1 authored Dec 3, 2024
2 parents af8ae1b + bce46e5 commit 9433609
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 5,789 deletions.
33 changes: 0 additions & 33 deletions .eslintrc.js

This file was deleted.

13 changes: 7 additions & 6 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

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

- name: Install dependencies
run: npm install
run: bun install

- name: Unit Tests
run: npm run test

- name: Build
run: npm run build:prod
37 changes: 23 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
FROM node:14-alpine as builder
FROM oven/bun:1 AS base
WORKDIR /usr/src/app

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

WORKDIR /usr/src/app
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

COPY package.json package-lock.json tsconfig.json ./
RUN npm install
COPY src ./
RUN npm run tsc
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

FROM node:14-alpine
ENV NODE_ENV=production
RUN bun test
RUN bun run build:prod

WORKDIR /usr/src/app
COPY --from=builder /usr/src/app/package.json package.json
COPY --from=builder /usr/src/app/node_modules node_modules
COPY --from=builder /usr/src/app/build build
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/build/* build/
COPY --from=prerelease /usr/src/app/package.json .

CMD [ "npm", "run", "start:prod" ]
# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "start:prod" ]
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ sequenceDiagram

## Requirements

- NPM
- Node
- Bun (for running locally, so we can run TypeScript directly)
- Bun

## Running Locally

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

- Create a Slack application (see Slack Bolt API link below)
- Run `npm run dev` (it defaults to port 3000)
- Run `bun install` to install dependencies
- Run `bun run dev` (it defaults to port 3000)
- Run ngrok to create a proxy to your Bolt app (`ngrok serve 3000`)
- Point your Slack's event subscription to your ngrok URL
- Set up [Sonos Proxy](https://github.com/clearfunction/sonos_proxy_nodejs)
Expand Down
Binary file added bun.lockb
Binary file not shown.
21 changes: 21 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
{
rules: {
'@typescript-eslint/no-empty-object-type': [
'error',
{ allowInterfaces: 'always' },
],
},
ignores: ['dist', 'node_modules'],
},
eslintConfigPrettier
);
Loading

0 comments on commit 9433609

Please sign in to comment.