Skip to content

Commit b146c01

Browse files
authored
Merge pull request #45 from hacksu/feat/37-move-to-bun
Move to Bun
2 parents 60be4ed + 8f72ec7 commit b146c01

File tree

8 files changed

+854
-2409
lines changed

8 files changed

+854
-2409
lines changed

.github/workflows/build_and_deploy.yml

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,10 @@ jobs:
2222
cancel-in-progress: true
2323

2424
name: Deploy
25-
outputs:
26-
run_build: ${{ steps.check_build.outputs.run_build }}
2725

2826
# Steps represent a sequence of tasks that will be executed as part of the job
2927
steps:
30-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
31-
- name: Checkout
32-
uses: actions/checkout@v4
33-
with:
34-
fetch-depth: 2
35-
- name: Determine Build Requirement
36-
id: check_build
37-
run: |
38-
echo "========== Modified Files =========="
39-
git diff --name-only HEAD^ HEAD
40-
echo "===================================="
41-
if grep -q "src" <<< $(git diff --name-only HEAD^ HEAD); then
42-
echo "Build Required"
43-
echo "::set-output name=run_build::true"
44-
else
45-
echo "::set-output name=run_build::false"
46-
fi
47-
48-
- name: Deploying
28+
- name: Deploy to server
4929
uses: appleboy/ssh-action@master
5030
with:
5131
host: ${{ secrets.REMOTE_HOST }}
@@ -59,31 +39,7 @@ jobs:
5939
git fetch
6040
echo "Pulling Changes from Github"
6141
git pull
62-
echo "Installing Modules"
63-
yarn install
64-
echo "Restarting Application"
65-
pm2 restart hacksu-2021
66-
echo "Finished"
67-
exit
68-
69-
build:
70-
name: Build
71-
needs: deploy
72-
if: github.event_name == 'workflow_dispatch' || needs.deploy.outputs.run_build == 'true'
73-
runs-on: ubuntu-latest
74-
steps:
75-
- name: Building Vue
76-
uses: appleboy/ssh-action@master
77-
with:
78-
host: ${{ secrets.REMOTE_HOST }}
79-
username: ${{ secrets.REMOTE_USER }}
80-
key: ${{ secrets.KEY }}
81-
port: ${{ secrets.PORT }}
82-
#passphrase: ${{ secrets.KEY_PASSPHRASE }}
83-
script: |
84-
cd /var/www/hacksu-2021
85-
yarn build # goes to dist2 by default
86-
ls dist2
87-
rm -rf dist
88-
mv dist2 dist
89-
exit
42+
echo "Take down docker compose stack"
43+
docker compose down
44+
echo "Start docker compose stack and rebuild"
45+
docker compose up --build -d

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM oven/bun:latest
2+
WORKDIR /app
3+
4+
COPY . .
5+
RUN bun install
6+
RUN bun run build
7+
8+
EXPOSE 8000
9+
10+
ENV NODE_ENV=production
11+
CMD ["bun", "./server/index.js"]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ Note that you can edit some of the site's content without changing its source co
44

55
## Guide to development
66

7-
Install [Node.js](https://nodejs.org/en) and [yarn](https://yarnpkg.com/).
7+
Install [Node.js](https://nodejs.org/en) and [Bun](https://bun.sh).
88

99
### Install dependencies
1010

1111
Run this before attempting to start the site:
1212

1313
```
14-
yarn install
14+
bun install
1515
```
1616

1717
### The configuration file
@@ -48,15 +48,15 @@ The Discord application whose client ID and secret are currently used in the ser
4848
### Run a server in debug mode with hot-reloading for development
4949

5050
```
51-
yarn dev
51+
bun dev
5252
```
5353

5454
Then go to the localhost URL that shows up in the browser console.
5555

5656
### Bundle for production
5757

5858
```
59-
yarn build
59+
bun build
6060
```
6161

6262
This step uses [vite-ssg](https://github.com/antfu-collective/vite-ssg) to save the site's content as HTML. Keep this step in mind when developing the site; if you write code in a Vue component that directly accesses objects that are provided by a browser, like `window`, this step will crash, since this initial build is not run in a browser. You can usually move code that accesses browser-y stuff to a callback like `onMounted` to avoid this.

bun.lock

Lines changed: 789 additions & 0 deletions
Large diffs are not rendered by default.

docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "hacksu-website"
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
labels:
9+
- "traefik.enable=true"
10+
- "traefik.http.routers.hacksu-website.rule=Host(`hacksu.com`)"
11+
- "traefik.http.routers.hacksu-website.entrypoints=websecure"
12+
- "traefik.http.routers.hacksu-website.tls.certresolver=letsencrypt"
13+
- "traefik.http.services.hacksu-website.loadbalancer.server.port=8000"
14+
networks:
15+
- traefik
16+
17+
networks:
18+
traefik:
19+
external: true

package.json

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,42 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"serve": "cross-env NODE_ENV=production node server/index.js",
7+
"serve": "cross-env NODE_ENV=production bun server/index.js",
88
"dev": "nodemon --watch server --watch db --ignore \"db/*.json\" server/index.js",
9-
"build": "vite-ssg build -c src/vite.config.js",
10-
"preview": "vite preview",
11-
"update": "git fetch && git pull && npm run build && pm2 restart hacksu"
9+
"build": "bunx vite-ssg build -c src/vite.config.js",
10+
"preview": "bunx --bun vite preview",
11+
"update": "git fetch && git pull && bun run build && pm2 restart hacksu"
1212
},
1313
"browser": {
1414
"markdown-it": false
1515
},
1616
"dependencies": {
17-
"@unhead/vue": "^1.9.8",
17+
"@unhead/vue": "^1.11.20",
1818
"@vueuse/head": "^1.3.1",
19-
"body-parser": "^1.19.0",
19+
"body-parser": "^1.20.3",
2020
"cross-env": "^7.0.3",
21-
"express": "^4.17.1",
22-
"express-session": "^1.17.3",
21+
"express": "^4.21.2",
22+
"express-session": "^1.18.1",
2323
"i": "^0.3.7",
2424
"markdown-it": "^13.0.2",
25-
"multer": "^1.4.5-lts.1",
25+
"multer": "^1.4.5-lts.2",
2626
"passport": "^0.6.0",
2727
"passport-discord": "^0.1.4",
28-
"remult": "^0.22.9",
28+
"remult": "^0.22.12",
2929
"sharp": "^0.32.6",
30-
"vite-ssg": "^0.22.1",
31-
"vue": "^3.0.0",
32-
"vue-advanced-cropper": "^2.8.8",
33-
"vue-router": "^4.0.0-0"
30+
"vite-ssg": "^0.22.2",
31+
"vue": "^3.5.16",
32+
"vue-advanced-cropper": "^2.8.9",
33+
"vue-router": "^4.5.1"
3434
},
3535
"devDependencies": {
36-
"@vitejs/plugin-vue": "^4.4.0",
37-
"nodemon": "^3.0.1",
38-
"sass": "^1.26.5",
39-
"vite": "^4.4.11"
40-
}
36+
"@vitejs/plugin-vue": "^4.6.2",
37+
"nodemon": "^3.1.10",
38+
"sass": "^1.89.2",
39+
"vite": "^4.5.14"
40+
},
41+
"trustedDependencies": [
42+
"@parcel/watcher",
43+
"sharp"
44+
]
4145
}

src/vite.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { defineConfig } from 'vite';
2-
import path from 'path';
31
import vue from '@vitejs/plugin-vue';
2+
import path from 'path';
3+
import { defineConfig } from 'vite';
44

55
// https://vitejs.dev/config/
66
export default defineConfig({
@@ -27,8 +27,7 @@ export default defineConfig({
2727
}
2828
},
2929
build: {
30-
// files are moved to dist by github actions cd
31-
outDir: "../dist2"
30+
outDir: "../dist"
3231
},
3332
server: {
3433
watch: {

0 commit comments

Comments
 (0)