Setup production environment
This commit is contained in:
parent
7480da4b69
commit
87b759ee77
7 changed files with 50 additions and 25 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,7 +1,7 @@
|
||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
**/node_modules
|
||||||
/.pnp
|
/.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
|
|
||||||
|
|
18
Dockerfile
18
Dockerfile
|
@ -1,16 +1,22 @@
|
||||||
FROM oven/bun
|
FROM oven/bun
|
||||||
|
|
||||||
|
# Build client
|
||||||
|
WORKDIR /app/client
|
||||||
|
COPY client .
|
||||||
|
RUN bun install
|
||||||
|
RUN bunx --bun vite build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json .
|
RUN mv client/build public
|
||||||
COPY bun.lockb .
|
RUN rm -rf client
|
||||||
|
|
||||||
|
COPY server src
|
||||||
|
RUN mv src/package.json package.json
|
||||||
|
COPY tsconfig.json .
|
||||||
|
|
||||||
RUN bun install --production
|
RUN bun install --production
|
||||||
|
|
||||||
COPY src src
|
|
||||||
COPY tsconfig.json .
|
|
||||||
# COPY public public
|
|
||||||
|
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
CMD ["bun", "src/index.ts"]
|
CMD ["bun", "src/index.ts"]
|
||||||
|
|
||||||
|
|
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
2
client
2
client
|
@ -1 +1 @@
|
||||||
Subproject commit 337d394fd33496d9aff23ef847ce56b1464deee6
|
Subproject commit 616163ad796cc91d2e7077fef629fea932dd9d82
|
17
package.json
17
package.json
|
@ -3,22 +3,15 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "bun run server/index.ts",
|
|
||||||
"dev": "conc npm:dev:server npm:dev:client",
|
"dev": "conc npm:dev:server npm:dev:client",
|
||||||
"dev:server": "bun run --watch server/index.ts",
|
"dev:server": "bun run --watch server/index.ts",
|
||||||
"dev:client": "bunx --bun vite client",
|
"dev:client": "bunx --bun vite client",
|
||||||
"build": "bunx --bun vite build client",
|
"build": "bunx --bun vite build client",
|
||||||
"test": "vitest run -r client",
|
"test": "bunx --bun vitest run -r client",
|
||||||
"testw": "vitest -r client"
|
"testw": "bunx --bun vitest -r client"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@bogeychan/elysia-oauth2": "^0.0.19",
|
"client": "file:./client",
|
||||||
"elysia": "latest",
|
"server": "file:./server"
|
||||||
"profectus": "file:./client"
|
}
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"bun-types": "latest",
|
|
||||||
"concurrently": "^8.2.2"
|
|
||||||
},
|
|
||||||
"module": "server/index.js"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { Elysia, t } from "elysia";
|
|
||||||
import oauth2 from "@bogeychan/elysia-oauth2";
|
import oauth2 from "@bogeychan/elysia-oauth2";
|
||||||
|
import { staticPlugin } from '@elysiajs/static';
|
||||||
import { Database } from "bun:sqlite";
|
import { Database } from "bun:sqlite";
|
||||||
import { randomBytes } from "crypto";
|
import { randomBytes } from "crypto";
|
||||||
|
import { Elysia, t } from "elysia";
|
||||||
|
|
||||||
|
|
||||||
import { migrateDatabase } from "./migrations";
|
|
||||||
import { clientToServerEvents } from "../common/events";
|
import { clientToServerEvents } from "../common/events";
|
||||||
|
import { migrateDatabase } from "./migrations";
|
||||||
|
|
||||||
const db = new Database("db.sqlite", { create: true });
|
const db = new Database("db.sqlite", { create: true });
|
||||||
migrateDatabase(db);
|
migrateDatabase(db);
|
||||||
|
@ -101,8 +101,16 @@ const app = new Elysia()
|
||||||
|
|
||||||
// Update avatar and display name from mbin, fallback to userinfo
|
// Update avatar and display name from mbin, fallback to userinfo
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.listen(3000);
|
|
||||||
|
if (Bun.env.NODE_ENV === "production") {
|
||||||
|
app.use(staticPlugin({
|
||||||
|
alwaysStatic: true,
|
||||||
|
prefix: ""
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
app.listen(3000);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`🦊 Chromatic Lattice server is running at ${app.server?.url.href}`
|
`🦊 Chromatic Lattice server is running at ${app.server?.url.href}`
|
||||||
|
|
18
server/package.json
Normal file
18
server/package.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "chromatic-lattice-server",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"start": "bun run server/index.ts"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@bogeychan/elysia-oauth2": "^0.0.19",
|
||||||
|
"@elysiajs/static": "^0.8.1",
|
||||||
|
"elysia": "latest"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"bun-types": "latest",
|
||||||
|
"concurrently": "^8.2.2"
|
||||||
|
},
|
||||||
|
"module": "server/index.js"
|
||||||
|
}
|
Loading…
Reference in a new issue