Skip to content

Commit

Permalink
Merge pull request #14 from gabeklavans/feature/revert-bun
Browse files Browse the repository at this point in the history
Feature/revert-bun
  • Loading branch information
gabeklavans authored Sep 17, 2023
2 parents bdb32fd + 218b1ce commit ca7e0f4
Show file tree
Hide file tree
Showing 10 changed files with 3,231 additions and 45 deletions.
9 changes: 6 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/shyim/devcontainers-features/bun:0": {}
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
Expand All @@ -21,4 +23,5 @@

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"runArgs": ["--network=host"]
}
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
FROM oven/bun:latest
FROM node:18-alpine

RUN apk update && apk upgrade && \
apk add --no-cache git
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY ./ /usr/src/app
RUN bun install --production
RUN npm install --production=false
RUN npm run build
# only keep what's needed for prod
RUN rm -rf node_modules && npm install --production && npm cache clean --force
ENV NODE_ENV production
ENV PORT 80


EXPOSE 80

CMD [ "bun", "start" ]
CMD [ "npm", "start" ]
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ For each supported game, there will be a folder under `src/server` that contains
Each game is intended to be a completely separately hosted website. This backend server will handle sending the right URL for the requested game to the user, and will process the game logic for each session of each game. Every game's site should have a URL that points back to this server so that it knows where to send the updates for the game session.

## Environment
- Runs on latest [bun](https://bun.sh/) (1.0.1 as of writing; will hopefully run on all future releases) ~~Should run on the latest LTS `node` version (if it doesn't, please update and make a PR!)~~
- Should run on the latest LTS `node` version (if it doesn't, please update and make a PR!)
- Copy the `.example-env` to `.env` in the root and remove comments/update env values to whatever fits your needs
- Make sure the URLs that are meant to point to the web-games are valid (otherwise this Bot won't know what to send when users request a game)

Expand All @@ -40,20 +40,20 @@ Each game is intended to be a completely separately hosted website. This backend
## Start Development Server
- Install dependencies with:
```sh
bun install
npm install
```
- Start bun in "watch" mode
- Tell `nodemon` to spin up a local server in watch mode that can run the typescript source code directly
```sh
bun run dev
npm run dev
```
- You can then take the URL that the server prints out after starting and set that as the backend URL (port included) on all the game sites that you host locally.

## Deploy
- Install only the production packages
## Build & Deploy
- Transpile and build the app to the `dist` directory
```sh
bun install --production
npm run build
```
- Run the entrypoint file
- Then run the built app
```sh
bun start
npm start
```
Binary file removed bun.lockb
Binary file not shown.
Loading

0 comments on commit ca7e0f4

Please sign in to comment.