Skip to content

Commit

Permalink
bun change to node, svelte 5, some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 committed Jun 19, 2024
1 parent 7fcef25 commit 91b8cd8
Show file tree
Hide file tree
Showing 52 changed files with 9,252 additions and 491 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ README.md
build
package
docker-compose*
LICENSE
LICENSE.txt
Makefile
helm-charts
.env
Expand Down
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ PUBLIC_COOKIE_KEY=""
# Our secret...
PRIVATE_JWT_SECRET_KEY=""

# WebSocket server with event messages
PUBLIC_WEBSOCKET_URL="ws://localhost:4002"

# Example of local DB
DATABASE_URL="postgresql://postgres:postgres@localhost:6432/db?schema=public&connect_timeout=300"
9 changes: 4 additions & 5 deletions .github/workflows/test-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1

- run: bun install
- run: npm ci --legacy-peer-deps

- name: ESLint
run: bun run lint
run: npm run lint

- name: Find circular dependencies
run: bun run lint:deps
run: npm run lint:deps

- name: Check Svelte files
run: bun run check
run: npm run check
51 changes: 14 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,17 @@
FROM oven/bun:1 as base
WORKDIR /usr/src/app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json .
RUN npm ci --legacy-peer-deps
COPY . .
RUN npx prisma generate
RUN npm run build
RUN npm prune --omit=dev --legacy-peer-deps

# [optional] tests & build
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/build build/
COPY --from=builder /app/node_modules node_modules/
COPY package.json .
EXPOSE 3000
ENV NODE_ENV=production
# RUN bun test
RUN bunx prisma generate
RUN bun run build

# copy dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/dev/node_modules node_modules
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/node_modules node_modules
COPY --from=prerelease /usr/src/app/build .

ARG PORT=3000
ENV PORT=$PORT

USER bun
EXPOSE $PORT/tcp
ENTRYPOINT [ "bun", "run", "start" ]
CMD [ "node", "build" ]
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
🤔 Imagine procedurally generated world where you and your viewers can:

- 💬 **Use commands** in chat to see actions in real time
- 🗺️ **Travel** with the Machine
- 🗺️ **Travel** with the Wagon
- 🦄 **Complete** main and side quests from game characters
- 💎 **Gather** a variety of materials
- 🏗️ **Construct** buildings
Expand All @@ -26,7 +26,6 @@ Let's build a similar world together! ⭐️ Become a Stargazer ⭐️
- [Prisma](https://www.prisma.io/): Next-generation Node.js and TypeScript ORM.
- [Howler.js](https://howlerjs.com/): Audio library for the modern web.
- [Lucide Svelte](https://lucide.dev/guide/packages/lucide-svelte): An open-source icon library.
- [Bun](https://bun.sh/): An all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager.
- [TypeScript](https://www.typescriptlang.org/): A strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.
- [ESLint](https://eslint.org/): Statically analyzes a code to quickly find problems.

Expand All @@ -36,10 +35,10 @@ Clone this repo and use standard commands:

```shell
git clone https://github.com/hmbanan666/chat-game
bun install
bun run dev
npm install
npm run dev
```

## 🪀 License

This project is licensed under the MIT License - see the [**MIT License**](https://github.com/hmbanan666/chat-game/blob/main/LICENSE) file for details.
This project is licensed under the MIT License - see the [**MIT License**](https://github.com/hmbanan666/chat-game/blob/main/LICENSE.txt) file for details.
Binary file removed bun.lockb
Binary file not shown.
Loading

0 comments on commit 91b8cd8

Please sign in to comment.